hub75_gamma.v 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * hub75_gamma.v
  3. *
  4. * vim: ts=4 sw=4
  5. *
  6. * Copyright (C) 2019 Sylvain Munaut <tnt@246tNt.com>
  7. * All rights reserved.
  8. *
  9. * LGPL v3+, see LICENSE.lgpl3
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU Lesser General Public
  13. * License as published by the Free Software Foundation; either
  14. * version 3 of the License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  19. * Lesser General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Lesser General Public License
  22. * along with this program; if not, write to the Free Software Foundation,
  23. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  24. */
  25. `default_nettype none
  26. module hub75_gamma #(
  27. parameter IW = 8,
  28. parameter OW = 10
  29. )(
  30. input wire [IW-1:0] in,
  31. output wire [OW-1:0] out,
  32. input wire enable,
  33. input wire clk
  34. );
  35. reg [15:0] gamma_rom [0:255];
  36. wire [ 7:0] rd_addr;
  37. reg [15:0] rd_data;
  38. initial
  39. $readmemh("gamma_table.hex", gamma_rom);
  40. always @(posedge clk)
  41. begin
  42. // Read
  43. if (enable)
  44. rd_data <= gamma_rom[rd_addr];
  45. end
  46. genvar i;
  47. generate
  48. for (i=0; i<8; i=i+1)
  49. assign rd_addr[7-i] = in[IW-1-(i%IW)];
  50. endgenerate
  51. assign out = rd_data[15:16-OW];
  52. endmodule // hub75_gamma