1818// address mapping.
1919// This module is responsible for managing the correct memory addressing
2020//
21+ `include " common_cells/assertions.svh"
2122module mem_multibank_pwrgate # (
2223 parameter int unsigned NumWords = 32'd1024 , // Number of Words in data array
2324 parameter int unsigned DataWidth = 32'd128 , // Data signal width
@@ -85,12 +86,9 @@ module mem_multibank_pwrgate #(
8586
8687 end else begin : gen_logic_bank // block: gen_simple_sram
8788 localparam int unsigned LogicBankSize = NumWords / NumLogicBanks;
88- localparam int unsigned BankSelWidth = (NumLogicBanks > 32'd1 ) ? $clog2 (
89- NumLogicBanks
90- ) : 32'd1 ;
89+ localparam int unsigned BankSelWidth = (NumLogicBanks > 32'd1 ) ?
90+ $clog2 (NumLogicBanks) : 32'd1 ;
9191
92- if (LogicBankSize != 2 ** (AddrWidth - BankSelWidth))
93- $fatal (" Logic Bank size is not a power of two: UNSUPPORTED " );
9492
9593 // Signals from/to logic banks
9694 logic [NumLogicBanks- 1 : 0 ][ NumPorts- 1 : 0 ] req_cut;
@@ -101,8 +99,7 @@ module mem_multibank_pwrgate #(
10199 data_t [NumLogicBanks- 1 : 0 ][ NumPorts- 1 : 0 ] rdata_cut;
102100
103101 // Signals to select the right bank
104- logic [ NumPorts- 1 : 0 ][BankSelWidth- 1 : 0 ] bank_sel;
105- logic [NumPorts- 1 : 0 ][Latency- 1 : 0 ][BankSelWidth- 1 : 0 ] out_mux_sel_d, out_mux_sel_q;
102+ logic [NumPorts- 1 : 0 ][BankSelWidth- 1 : 0 ] bank_sel;
106103
107104 // Identify bank looking at the BankSelWidth-th MSBs of the Address
108105 for (genvar PortIdx = 0 ; PortIdx < NumPorts; PortIdx++ ) begin : gen_bank_sel
@@ -119,6 +116,9 @@ module mem_multibank_pwrgate #(
119116 assign rdata_o[PortIdx] = rdata_cut[bank_sel[PortIdx]][PortIdx];
120117 end
121118 end else begin : gen_read_latency
119+ // Define input/output registers to hold the read value
120+ logic [NumPorts- 1 : 0 ][Latency- 1 : 0 ][BankSelWidth- 1 : 0 ] out_mux_sel_d, out_mux_sel_q;
121+
122122 always_comb begin
123123 for (int PortIdx = 0 ; PortIdx < NumPorts; PortIdx++ ) begin : gen_read_mux_signals
124124 rdata_o[PortIdx] = rdata_cut[out_mux_sel_q[PortIdx][0 ]][PortIdx];
@@ -130,15 +130,21 @@ module mem_multibank_pwrgate #(
130130 end
131131
132132 always_ff @ (posedge clk_i or negedge rst_ni) begin
133- for (int PortIdx = 0 ; PortIdx < NumPorts; PortIdx++ ) begin
134- if (! rst_ni) begin
135- out_mux_sel_q[PortIdx] <= '0 ;
136- end else begin
137- for (int shift_idx = 0 ; shift_idx < Latency; shift_idx++ ) begin
138- out_mux_sel_q[PortIdx][shift_idx] <= out_mux_sel_d[PortIdx][shift_idx];
139- end
140- end
133+ if (! rst_ni) begin
134+ out_mux_sel_q <= '0 ;
135+ end else begin
136+ out_mux_sel_q <= out_mux_sel_d;
141137 end
138+
139+ // for (int PortIdx = 0; PortIdx < NumPorts; PortIdx++) begin
140+ // if (!rst_ni) begin
141+ // out_mux_sel_q[PortIdx] <= '0;
142+ // end else begin
143+ // for (int shift_idx = 0; shift_idx < Latency; shift_idx++) begin
144+ // out_mux_sel_q[PortIdx][shift_idx] <= out_mux_sel_d[PortIdx][shift_idx];
145+ // end
146+ // end
147+ // end
142148 end
143149 end : gen_read_latency
144150
@@ -181,13 +187,18 @@ module mem_multibank_pwrgate #(
181187 .be_i (be_cut[BankIdx]),
182188 .rdata_o (rdata_cut[BankIdx])
183189 );
184- end
190+ end : gen_logic_bank
191+ `ifndef COMMON_CELLS_ASSERTS_OFF
192+ `ASSERT_INIT (pwr2_bank, LogicBankSize == 2 ** (AddrWidth - BankSelWidth),
193+ " Logic Bank size is not a power of two: UNSUPPORTED!" )
194+ `endif
195+
185196 end
186197
187198 // Trigger warnings when power signals (deepsleep_i and powergate_i) are not connected.
188199 // Usually those signals must be linked through the UPF.
189200`ifndef VERILATOR
190- `ifndef TARGET_SYNTHESIS
201+ `ifndef SYNTHESIS
191202 initial begin
192203 assert (! $isunknown (deepsleep_i))
193204 else $warning (" deepsleep_i has some unconnected signals" );
0 commit comments