From 9ce65b7d3573d92e1d98a13b58a5d5763ba073c5 Mon Sep 17 00:00:00 2001 From: Julian Blake Kongslie Date: Sun, 5 Jun 2022 15:34:23 -0700 Subject: Working L1 cache. --- hdl/defs.svh | 2 +- hdl/fifo.sv | 4 +-- hdl/mem_cache.sv | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ hdl/top.sv | 51 ++++++++++++++++++++++---- 4 files changed, 156 insertions(+), 9 deletions(-) create mode 100644 hdl/mem_cache.sv (limited to 'hdl') diff --git a/hdl/defs.svh b/hdl/defs.svh index f4590c8..f8b1032 100644 --- a/hdl/defs.svh +++ b/hdl/defs.svh @@ -5,7 +5,7 @@ `define PDP_ADDRESS_BITS 15 -`define NUM_PDPS 16 +`define NUM_PDPS 1 `define UART_BYTE_BITS 8 diff --git a/hdl/fifo.sv b/hdl/fifo.sv index 19877c4..9399006 100644 --- a/hdl/fifo.sv +++ b/hdl/fifo.sv @@ -1,6 +1,6 @@ module fifo #( WIDTH_BITS = 1 - , DEPTH_BITS = 10 + , DEPTH_BITS = 8 ) ( input bit clock_in , input bit clock_out @@ -21,7 +21,7 @@ module fifo typedef bit [DEPTH_BITS-1:0] addr_t; typedef bit [DEPTH_BITS:0] grey_t; - data_t data [DEPTH-1:0]; + (* ramstyle = "no_rw_check, M9K" *) data_t data [DEPTH-1:0]; addr_t oldest, youngest; bit oldest_wrap, youngest_wrap; diff --git a/hdl/mem_cache.sv b/hdl/mem_cache.sv new file mode 100644 index 0000000..5f3db73 --- /dev/null +++ b/hdl/mem_cache.sv @@ -0,0 +1,108 @@ +`include "defs.svh" + +module mem_cache + #( SET_BITS = 8 + ) + ( input bit clock + , input bit reset + + , output bit core_command_ready + , input bit core_command_valid + , input pdp_command_t core_command_data + + , input bit ram_command_ready + , output bit ram_command_valid + , output pdp_command_t ram_command_data + + , output bit ram_response_ready + , input bit ram_response_valid + , input pdp_read_response_t ram_response_data + + , input bit core_response_ready + , output bit core_response_valid + , output pdp_read_response_t core_response_data + ); + + localparam ADDRESS_TAG_LO = $clog2(`RAM_LINE_WORDS)+SET_BITS; + + typedef bit [`PDP_ADDRESS_BITS-1:ADDRESS_TAG_LO] address_tag_t; + typedef bit [ADDRESS_TAG_LO-1:$clog2(`RAM_LINE_WORDS)] set_t; + + typedef struct packed { + bit valid; + address_tag_t address; + } tag_t; + + typedef struct packed { + tag_t tag; + ram_line_t data; + } cache_entry_t; + + (* ramstyle = "no_rw_check, M9K" *) cache_entry_t cache [(1<