diff options
| author | Alejandro Soto <alejandro@34project.org> | 2023-09-24 20:58:04 -0600 |
|---|---|---|
| committer | Alejandro Soto <alejandro@34project.org> | 2023-09-24 22:14:57 -0600 |
| commit | 15230c6cd2190a1efd61c2758bf56de37f3fe8da (patch) | |
| tree | 9d8a04daadb4192cf4aeb44b8e86389a9ba130d3 /rtl/cache/sram.sv | |
| parent | 146168ca340e435eae6e30e99c06d752719089e3 (diff) | |
rtl/cache: implement
Diffstat (limited to '')
| -rw-r--r-- | rtl/cache/sram.sv | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/rtl/cache/sram.sv b/rtl/cache/sram.sv new file mode 100644 index 0000000..2e6c6ce --- /dev/null +++ b/rtl/cache/sram.sv @@ -0,0 +1,49 @@ +`include "cache/defs.sv" + +module cache_sram +( + input logic clk, + rst_n, + + input addr_index index_rd, + index_wr, + input logic write_data, + write_state, + input addr_tag tag_wr, + input line data_wr, + input line_state state_wr, + + output addr_tag tag_rd, + output line data_rd, + output line_state state_rd +); + + // Existe un mito que habla de true dual-ports con byte-enables, dudo mucho que sea real: + // https://www.intel.com/content/www/us/en/docs/programmable/683082/21-3/ram-with-byte-enable-signals.html + + localparam DEPTH = 1 << $bits(addr_index); + + line data_file[DEPTH]; + addr_tag tag_file[DEPTH]; + line_state state_file[DEPTH]; + + always_ff @(posedge clk) begin + if (write_data) begin + tag_file[index_wr] <= tag_wr; + data_file[index_wr] <= data_wr; + end + + if (write_state) + state_file[index_wr] <= state_wr; + + tag_rd <= tag_file[index_rd]; + data_rd <= data_file[index_rd]; + state_rd <= state_file[index_rd]; + end + + //FIXME: rst_n para state_file? + initial + for (int i = 0; i < DEPTH; ++i) + state_file[i] = INVALID; + +endmodule |
