Skip to content

Commit

Permalink
Move memories into modules for PNR power routing (#198)
Browse files Browse the repository at this point in the history
* bender: add new module files to bender

* hw: add new moduled icaches

* hw: use updated module caches

* hw: take out comments

* bender: add data mem sv

* hw: use data mem sv

* hw: add data memory
  • Loading branch information
rgantonio authored Jul 22, 2024
1 parent b6e9ab0 commit 5ad7aa2
Show file tree
Hide file tree
Showing 6 changed files with 215 additions and 73 deletions.
3 changes: 3 additions & 0 deletions Bender.yml
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ sources:
# Level 0
- hw/snitch_icache/src/snitch_icache_pkg.sv
# Level 1
- hw/snitch_icache/src/snitch_icache_data.sv
- hw/snitch_icache/src/snitch_icache_tag.sv
- hw/snitch_icache/src/snitch_icache_l0.sv
- hw/snitch_icache/src/snitch_icache_refill.sv
- hw/snitch_icache/src/snitch_icache_lfsr.sv
Expand Down Expand Up @@ -256,6 +258,7 @@ sources:
# snitch_cluster
- files:
# Level 0
- hw/snitch_cluster/src/snitch_data_mem.sv
- hw/snitch_cluster/src/snitch_amo_shim.sv
- hw/snitch_cluster/src/snitch_cluster_peripheral/snitch_cluster_peripheral_reg_pkg.sv
- hw/snitch_cluster/src/snitch_cluster_peripheral/snitch_cluster_peripheral_reg_top.sv
Expand Down
67 changes: 36 additions & 31 deletions hw/snitch_cluster/src/snitch_cluster.sv
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ module snitch_cluster
localparam int unsigned TCDMAddrWidth = $clog2(TCDMSize);
localparam int unsigned BanksPerSuperBank = WideDataWidth / NarrowDataWidth;
localparam int unsigned NrSuperBanks = NrBanks / BanksPerSuperBank;
localparam int unsigned NumTotalBanks = BanksPerSuperBank*NrSuperBanks;

localparam int unsigned NrTCDMPortsCores = get_tcdm_port_offs(NrCores);
localparam int unsigned NumTCDMIn = NrTCDMPortsCores + 1;
Expand Down Expand Up @@ -879,6 +880,35 @@ module snitch_cluster
// ----------------
// Memory Subsystem
// ----------------
logic [NumTotalBanks-1:0] mem_cs;
logic [NumTotalBanks-1:0] mem_wen;
tcdm_mem_addr_t [NumTotalBanks-1:0] mem_add;
strb_t [NumTotalBanks-1:0] mem_be;
data_t [NumTotalBanks-1:0] mem_wdata;
data_t [NumTotalBanks-1:0] mem_rdata;

snitch_data_mem #(
.TCDMDepth ( TCDMDepth ),
.NarrowDataWidth ( NarrowDataWidth ),
.NumTotalBanks ( NumTotalBanks ),
.sram_cfg_t ( sram_cfg_t ),
.sram_cfgs_t ( sram_cfgs_t ),
.tcdm_mem_addr_t ( tcdm_mem_addr_t ),
.strb_t ( strb_t ),
.data_t ( data_t )
) i_snitch_data_mem (
.clk_i ( clk_i ),
.rst_ni ( rst_ni ),
.sram_cfgs_i ( sram_cfgs_i ),
.mem_cs_i ( mem_cs ),
.mem_add_i ( mem_add ),
.mem_wen_i ( mem_wen ),

.mem_be_i ( mem_be ),
.mem_wdata_i ( mem_wdata ),
.mem_rdata_o ( mem_rdata )
);

for (genvar i = 0; i < NrSuperBanks; i++) begin : gen_tcdm_super_bank

mem_req_t [BanksPerSuperBank-1:0] amo_req;
Expand Down Expand Up @@ -906,31 +936,6 @@ module snitch_cluster
// generate banks of the superbank
for (genvar j = 0; j < BanksPerSuperBank; j++) begin : gen_tcdm_bank

logic mem_cs, mem_wen;
tcdm_mem_addr_t mem_add;
strb_t mem_be;
data_t mem_rdata, mem_wdata;

tc_sram_impl #(
.NumWords (TCDMDepth),
.DataWidth (NarrowDataWidth),
.ByteWidth (8),
.NumPorts (1),
.Latency (1),
.impl_in_t (sram_cfg_t)
) i_data_mem (
.clk_i,
.rst_ni,
.impl_i (sram_cfgs_i.tcdm),
.impl_o ( ),
.req_i (mem_cs),
.we_i (mem_wen),
.addr_i (mem_add),
.wdata_i (mem_wdata),
.be_i (mem_be),
.rdata_o (mem_rdata)
);

data_t amo_rdata_local;

// TODO(zarubaf): Share atomic units between mutltiple cuts
Expand All @@ -951,12 +956,12 @@ module snitch_cluster
.is_core_i ( amo_req[j].q.user.is_core ),
.rdata_o ( amo_rdata_local ),
.amo_i ( amo_req[j].q.amo ),
.mem_req_o ( mem_cs ),
.mem_add_o ( mem_add ),
.mem_wen_o ( mem_wen ),
.mem_wdata_o ( mem_wdata ),
.mem_be_o ( mem_be ),
.mem_rdata_i ( mem_rdata ),
.mem_req_o ( mem_cs[i*BanksPerSuperBank+j] ),
.mem_add_o ( mem_add [i*BanksPerSuperBank+j]),
.mem_wen_o ( mem_wen[i*BanksPerSuperBank+j] ),
.mem_wdata_o ( mem_wdata[i*BanksPerSuperBank+j] ),
.mem_be_o ( mem_be[i*BanksPerSuperBank+j] ),
.mem_rdata_i ( mem_rdata[i*BanksPerSuperBank+j] ),
.dma_access_i ( sb_dma_req[i].q_valid ),
// TODO(zarubaf): Signal AMO conflict somewhere. Socregs?
.amo_conflict_o ( )
Expand Down
54 changes: 54 additions & 0 deletions hw/snitch_cluster/src/snitch_data_mem.sv
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Copyright 2024 KU Leuven.
// Solderpad Hardware License, Version 0.51, see LICENSE for details.
// SPDX-License-Identifier: SHL-0.51

// Ryan Antonio <[email protected]>

// The actual data memory. This memory is made into a module
// to support multiple power domain needed by the floor plan tool

module snitch_data_mem #(
parameter int unsigned TCDMDepth = 1024,
parameter int unsigned NarrowDataWidth = 64,
parameter int unsigned NumTotalBanks = 32,
// Memory configuration input types; these vary depending on implementation.
parameter type sram_cfg_t = logic,
parameter type sram_cfgs_t = logic,
parameter type tcdm_mem_addr_t = logic,
parameter type strb_t = logic,
parameter type data_t = logic
)(
input logic clk_i,
input logic rst_ni,
input sram_cfgs_t sram_cfgs_i,
input logic [NumTotalBanks-1:0] mem_cs_i,
input tcdm_mem_addr_t [NumTotalBanks-1:0] mem_add_i,
input logic [NumTotalBanks-1:0] mem_wen_i,
input strb_t [NumTotalBanks-1:0] mem_be_i,
input data_t [NumTotalBanks-1:0] mem_wdata_i,
output data_t [NumTotalBanks-1:0] mem_rdata_o
);

for (genvar i = 0; i < NumTotalBanks; i++) begin: gen_banks
tc_sram_impl #(
.NumWords ( TCDMDepth ),
.DataWidth ( NarrowDataWidth ),
.ByteWidth ( 8 ),
.NumPorts ( 1 ),
.Latency ( 1 ),
.impl_in_t ( sram_cfg_t )
) i_data_mem (
.clk_i ( clk_i ),
.rst_ni ( rst_ni ),
.impl_i ( sram_cfgs_i.tcdm ),
.impl_o ( /*Unused*/ ),
.req_i ( mem_cs_i[i] ),
.we_i ( mem_wen_i[i] ),
.addr_i ( mem_add_i[i] ),
.be_i ( mem_be_i[i] ),
.wdata_i ( mem_wdata_i[i] ),
.rdata_o ( mem_rdata_o[i] )
);
end

endmodule
47 changes: 47 additions & 0 deletions hw/snitch_icache/src/snitch_icache_data.sv
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright 2024 KU Leuven.
// Solderpad Hardware License, Version 0.51, see LICENSE for details.
// SPDX-License-Identifier: SHL-0.51

// Ryan Antonio <[email protected]>

// The actual cache memory. This memory is made into a module
// to support multiple power domain needed by the floor plan tool

module snitch_icache_data #(
parameter snitch_icache_pkg::config_t CFG = '0,
/// Configuration input types for SRAMs used in implementation.
parameter type sram_cfg_data_t = logic
)(
input logic clk_i,
input logic rst_ni,
input sram_cfg_data_t sram_cfg_data_i,
input logic [ CFG.SET_COUNT-1:0] ram_enable_i,
input logic ram_write_i,
input logic [CFG.COUNT_ALIGN-1:0] ram_addr_i,
input logic [ CFG.SET_COUNT-1:0][CFG.LINE_WIDTH-1:0] ram_wdata_i,
output logic [ CFG.SET_COUNT-1:0][CFG.LINE_WIDTH-1:0] ram_rdata_o
);

for (genvar i = 0; i < CFG.SET_COUNT; i++) begin: g_cache_data_sets
tc_sram_impl #(
.NumWords ( CFG.LINE_COUNT ),
.DataWidth ( CFG.LINE_WIDTH ),
.ByteWidth ( 8 ),
.NumPorts ( 1 ),
.Latency ( 1 ),
.impl_in_t ( sram_cfg_data_t )
) i_data (
.clk_i ( clk_i ),
.rst_ni ( rst_ni ),
.impl_i ( sram_cfg_data_i ),
.impl_o ( /*Unused*/ ),
.req_i ( ram_enable_i[i] ),
.we_i ( ram_write_i ),
.addr_i ( ram_addr_i ),
.wdata_i ( ram_wdata_i ),
.be_i ( '1 ),
.rdata_o ( ram_rdata_o[i] )
);
end

endmodule
70 changes: 28 additions & 42 deletions hw/snitch_icache/src/snitch_icache_lookup.sv
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ module snitch_icache_lookup #(
// write accesses.
logic [CFG.COUNT_ALIGN-1:0] ram_addr ;
logic [CFG.SET_COUNT-1:0] ram_enable ;
logic [CFG.LINE_WIDTH-1:0] ram_wdata, ram_rdata [CFG.SET_COUNT] ;
logic [CFG.TAG_WIDTH+1:0] ram_wtag, ram_rtag [CFG.SET_COUNT] ;
logic [CFG.SET_COUNT-1:0][CFG.LINE_WIDTH-1:0] ram_wdata, ram_rdata ;
logic [CFG.SET_COUNT-1:0][CFG.TAG_WIDTH+1:0] ram_wtag, ram_rtag ;
logic ram_write ;
logic ram_write_q;
logic [CFG.COUNT_ALIGN:0] init_count_q;
Expand Down Expand Up @@ -144,47 +144,33 @@ module snitch_icache_lookup #(
end

// Instantiate the RAM sets.
for (genvar i = 0; i < CFG.SET_COUNT; i++) begin : g_sets
tc_sram_impl #(
.NumWords (CFG.LINE_COUNT),
.DataWidth (CFG.TAG_WIDTH+2),
.ByteWidth (8),
.NumPorts (1),
.Latency (1),
.impl_in_t (sram_cfg_tag_t)
) i_tag (
.clk_i (clk_i),
.rst_ni (rst_ni),
.impl_i (sram_cfg_tag_i),
.impl_o ( ),
.req_i (ram_enable[i]),
.we_i (ram_write),
.addr_i (ram_addr),
.wdata_i (ram_wtag),
.be_i ('1),
.rdata_o (ram_rtag[i])
);
snitch_icache_data #(
.CFG ( CFG ),
.sram_cfg_data_t ( sram_cfg_data_t )
) i_snitch_icache_data (
.clk_i ( clk_i ),
.rst_ni ( rst_ni ),
.sram_cfg_data_i ( sram_cfg_data_i ),
.ram_enable_i ( ram_enable ),
.ram_write_i ( ram_write ),
.ram_addr_i ( ram_addr ),
.ram_wdata_i ( ram_wdata ),
.ram_rdata_o ( ram_rdata )
);

tc_sram_impl #(
.NumWords (CFG.LINE_COUNT),
.DataWidth (CFG.LINE_WIDTH),
.ByteWidth (8),
.NumPorts (1),
.Latency (1),
.impl_in_t (sram_cfg_data_t)
) i_data (
.clk_i (clk_i),
.rst_ni (rst_ni),
.impl_i (sram_cfg_data_i),
.impl_o ( ),
.req_i (ram_enable[i]),
.we_i (ram_write),
.addr_i (ram_addr),
.wdata_i (ram_wdata),
.be_i ('1),
.rdata_o (ram_rdata[i])
);
end
snitch_icache_tag #(
.CFG ( CFG ),
.sram_cfg_tag_t ( sram_cfg_tag_t )
) i_snitch_icache_tag (
.clk_i ( clk_i ),
.rst_ni ( rst_ni ),
.sram_cfg_tag_i ( sram_cfg_tag_i ),
.ram_enable_i ( ram_enable ),
.ram_write_i ( ram_write ),
.ram_addr_i ( ram_addr ),
.ram_wtag_i ( ram_wtag ),
.ram_rtag_o ( ram_rtag )
);

// Determine which RAM line hit, and multiplex that data to the output.
logic [CFG.TAG_WIDTH-1:0] required_tag;
Expand Down
47 changes: 47 additions & 0 deletions hw/snitch_icache/src/snitch_icache_tag.sv
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright 2024 KU Leuven.
// Solderpad Hardware License, Version 0.51, see LICENSE for details.
// SPDX-License-Identifier: SHL-0.51

// Ryan Antonio <[email protected]>

// The actual cache tag memory. This memory is made into a module
// to support multiple power domain needed by the floor plan tool

module snitch_icache_tag #(
parameter snitch_icache_pkg::config_t CFG = '0,
/// Configuration input types for SRAMs used in implementation.
parameter type sram_cfg_tag_t = logic
)(
input logic clk_i,
input logic rst_ni,
input sram_cfg_tag_t sram_cfg_tag_i,
input logic [ CFG.SET_COUNT-1:0] ram_enable_i,
input logic ram_write_i,
input logic [CFG.COUNT_ALIGN-1:0] ram_addr_i,
input logic [ CFG.SET_COUNT-1:0][CFG.TAG_WIDTH+1:0] ram_wtag_i,
output logic [ CFG.SET_COUNT-1:0][CFG.TAG_WIDTH+1:0] ram_rtag_o
);

for (genvar i = 0; i < CFG.SET_COUNT; i++) begin: g_cache_tag_sets
tc_sram_impl #(
.NumWords ( CFG.LINE_COUNT ),
.DataWidth ( CFG.TAG_WIDTH+2 ),
.ByteWidth ( 8 ),
.NumPorts ( 1 ),
.Latency ( 1 ),
.impl_in_t ( sram_cfg_tag_t )
) i_tag (
.clk_i ( clk_i ),
.rst_ni ( rst_ni ),
.impl_i ( sram_cfg_tag_i ),
.impl_o ( /*Unused*/ ),
.req_i ( ram_enable_i[i] ),
.we_i ( ram_write_i ),
.addr_i ( ram_addr_i ),
.wdata_i ( ram_wtag_i ),
.be_i ( '1 ),
.rdata_o ( ram_rtag_o[i] )
);
end

endmodule

0 comments on commit 5ad7aa2

Please sign in to comment.