soc_spram.v 718 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * soc_spram.v
  3. *
  4. * vim: ts=4 sw=4
  5. *
  6. * Copyright (C) 2020 Sylvain Munaut <tnt@246tNt.com>
  7. * SPDX-License-Identifier: CERN-OHL-P-2.0
  8. */
  9. `default_nettype none
  10. module soc_spram #(
  11. parameter integer AW = 14
  12. )(
  13. input wire [AW-1:0] addr,
  14. output wire [31:0] rdata,
  15. input wire [31:0] wdata,
  16. input wire [ 3:0] wmsk,
  17. input wire we,
  18. input wire clk
  19. );
  20. wire [7:0] msk_nibble = {
  21. wmsk[3], wmsk[3],
  22. wmsk[2], wmsk[2],
  23. wmsk[1], wmsk[1],
  24. wmsk[0], wmsk[0]
  25. };
  26. ice40_spram_gen #(
  27. .ADDR_WIDTH(AW),
  28. .DATA_WIDTH(32)
  29. ) spram_I (
  30. .addr(addr),
  31. .rd_data(rdata),
  32. .rd_ena(1'b1),
  33. .wr_data(wdata),
  34. .wr_mask(msk_nibble),
  35. .wr_ena(we),
  36. .clk(clk)
  37. );
  38. endmodule // soc_spram