vid_framebuf.v 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * vid_framebuf.v
  3. *
  4. * Video framebuffer memory
  5. *
  6. * vim: ts=4 sw=4
  7. *
  8. * Copyright (C) 2021 Sylvain Munaut <tnt@246tNt.com>
  9. * SPDX-License-Identifier: CERN-OHL-P-2.0
  10. */
  11. `default_nettype none
  12. module vid_framebuf (
  13. // Video Read port
  14. input wire [13:0] v_addr_0,
  15. output wire [31:0] v_data_1,
  16. input wire v_re_0,
  17. // Aux R/W port
  18. input wire [13:0] a_addr_0,
  19. output wire [31:0] a_rdata_1,
  20. input wire [31:0] a_wdata_0,
  21. input wire [ 3:0] a_wmsk_0,
  22. input wire a_we_0,
  23. output wire a_rdy_0,
  24. // Clock
  25. input wire clk
  26. );
  27. // Signals
  28. // -------
  29. wire [13:0] ram_addr;
  30. wire [31:0] ram_rdata;
  31. wire [31:0] ram_wdata;
  32. wire [ 7:0] ram_mask_n;
  33. wire ram_we;
  34. // Memory
  35. // ------
  36. SB_SPRAM256KA spram_I[1:0] (
  37. .DATAIN (ram_wdata),
  38. .ADDRESS (ram_addr),
  39. .MASKWREN (ram_mask_n),
  40. .WREN (ram_we),
  41. .CHIPSELECT (1'b1),
  42. .CLOCK (clk),
  43. .STANDBY (1'b0),
  44. .SLEEP (1'b0),
  45. .POWEROFF (1'b1),
  46. .DATAOUT (ram_rdata)
  47. );
  48. // Muxing
  49. // ------
  50. assign ram_addr = v_re_0 ? v_addr_0 : a_addr_0;
  51. assign ram_wdata = a_wdata_0;
  52. assign ram_mask_n = {
  53. ~a_wmsk_0[3], ~a_wmsk_0[3],
  54. ~a_wmsk_0[2], ~a_wmsk_0[2],
  55. ~a_wmsk_0[1], ~a_wmsk_0[1],
  56. ~a_wmsk_0[0], ~a_wmsk_0[0]
  57. };
  58. assign ram_we = a_we_0 & ~v_re_0;
  59. assign a_rdata_1 = ram_rdata;
  60. assign v_data_1 = ram_rdata;
  61. assign a_rdy_0 = ~v_re_0;
  62. endmodule // vid_framebuf