memory.sv 349 B

123456789101112131415
  1. module memory(clk, addr, rd_data, wr_data, wr_en);
  2. parameter WORD=8, MEM_SIZE=2**WORD;
  3. input clk, wr_en;
  4. input [WORD-1:0]addr;
  5. input [WORD-1:0]wr_data;
  6. output logic [WORD-1:0]rd_data;
  7. logic [WORD-1:0]memory[MEM_SIZE-1:0];
  8. always_ff@(posedge clk) begin
  9. if(wr_en) memory[addr] <= wr_data;
  10. else rd_data <= memory[addr];
  11. end
  12. endmodule