Skip to content

Commit ee0cab0

Browse files
committed
Decouple TCDM ports with FIFOs
1 parent ba96519 commit ee0cab0

1 file changed

Lines changed: 121 additions & 10 deletions

File tree

src/hwpe/ita_hwpe_wrap.sv

Lines changed: 121 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,6 @@ module ita_hwpe_wrap
6565

6666
hwpe_ctrl_intf_periph #(.ID_WIDTH(IdWidth)) periph (.clk(clk_i));
6767

68-
for(genvar i=0; i<MP; i++) begin: gen_tcdm_binding
69-
assign tcdm_req_o [i] = tcdm.req;
70-
assign tcdm_add_o [i] = tcdm.add + i*(MemDataWidth/8);
71-
assign tcdm_wen_o [i] = tcdm.wen;
72-
assign tcdm_be_o [i] = tcdm.be[i*(MemDataWidth/8)+:(MemDataWidth/8)];
73-
assign tcdm_data_o [i] = tcdm.data[i*MemDataWidth+:MemDataWidth];
74-
end
75-
assign tcdm.gnt = &(tcdm_gnt_i);
76-
assign tcdm.r_valid = &(tcdm_r_valid_i);
77-
assign tcdm.r_data = { >> {tcdm_r_data_i} };
7868
assign tcdm.r_user = '0;
7969
assign tcdm.r_id = '0;
8070
assign tcdm.r_opc = '0;
@@ -105,4 +95,125 @@ module ita_hwpe_wrap
10595
.periph (periph )
10696
);
10797

98+
// Buffer to synchronize the tcdm_req_o and tcdm_gnt_i signals
99+
localparam int unsigned BufferDepth = 8;
100+
101+
typedef struct packed {
102+
logic [31:0] add;
103+
logic wen;
104+
logic [MemDataWidth/8-1:0] be;
105+
logic [MemDataWidth-1:0] data;
106+
} buf_req_t;
107+
108+
typedef struct packed {
109+
logic [MemDataWidth-1:0] data;
110+
} buf_rsp_t;
111+
112+
logic [MP-1:0] buf_req_full, buf_req_empty;
113+
logic [MP-1:0] buf_rsp_full, buf_rsp_empty;
114+
logic [MP-1:0] buf_req_push, buf_req_pop;
115+
logic [MP-1:0] buf_rsp_push, buf_rsp_pop;
116+
logic [MP-1:0][$clog2(BufferDepth):0] buf_req_usage, buf_rsp_usage;
117+
buf_req_t [MP-1:0] buf_req_data_in;
118+
buf_req_t [MP-1:0] buf_req_data_out;
119+
buf_rsp_t [MP-1:0] buf_rsp_data_out;
120+
buf_rsp_t [MP-1:0] buf_rsp_data_in;
121+
122+
logic all_not_full;
123+
124+
always_comb begin
125+
// Default values
126+
buf_req_push = '0;
127+
buf_req_pop = '0;
128+
buf_rsp_push = '0;
129+
buf_rsp_pop = '0;
130+
131+
// Default values for tcdm signals
132+
tcdm.gnt = 1'b0;
133+
tcdm.r_valid = 1'b0;
134+
tcdm.r_data = '0;
135+
136+
all_not_full = 1'b1;
137+
138+
for (int i = 0; i < MP; i++) begin
139+
if (buf_rsp_usage[i] == BufferDepth) begin
140+
all_not_full = 1'b0;
141+
end
142+
end
143+
if (tcdm.req && &(buf_req_full == 1'b0) && all_not_full) begin
144+
tcdm.gnt = 1'b1;
145+
for (int i = 0; i < MP; i++) begin
146+
buf_req_push[i] = 1'b1;
147+
buf_req_data_in[i].add = tcdm.add + i*(MemDataWidth/8);
148+
buf_req_data_in[i].wen = tcdm.wen;
149+
buf_req_data_in[i].be = tcdm.be[i*(MemDataWidth/8)+:(MemDataWidth/8)];
150+
buf_req_data_in[i].data = tcdm.data[i*MemDataWidth+:MemDataWidth];
151+
end
152+
end
153+
154+
for (int i = 0; i < MP; i++) begin
155+
tcdm_req_o[i] = !buf_req_empty[i];
156+
tcdm_add_o[i] = buf_req_data_out[i].add;
157+
tcdm_wen_o[i] = buf_req_data_out[i].wen;
158+
tcdm_be_o[i] = buf_req_data_out[i].be;
159+
tcdm_data_o[i] = buf_req_data_out[i].data;
160+
if (tcdm_req_o[i] && tcdm_gnt_i[i]) begin
161+
buf_req_pop[i] = 1'b1;
162+
end
163+
end
164+
165+
for (int i = 0; i < MP; i++) begin
166+
buf_rsp_push[i] = tcdm_r_valid_i[i];
167+
buf_rsp_data_in[i].data = tcdm_r_data_i[i];
168+
end
169+
170+
if (&(buf_rsp_empty == 1'b0)) begin
171+
tcdm.r_valid = 1'b1;
172+
tcdm.r_data = { >> {buf_rsp_data_out} };
173+
for (int i = 0; i < MP; i++) begin
174+
buf_rsp_pop[i] = tcdm.r_ready;
175+
end
176+
end
177+
end
178+
179+
// generate fifo's with depth BufferDepth and one for each port
180+
for (genvar i = 0; i < MP; i++) begin : gen_hwpe_tcdm_fifo
181+
fifo_v3 #(
182+
.DATA_WIDTH ( $bits(buf_req_t) ),
183+
.DEPTH ( BufferDepth )
184+
) i_fifo_req (
185+
.clk_i,
186+
.rst_ni,
187+
.flush_i (1'b0),
188+
.testmode_i (1'b0),
189+
.full_o (buf_req_full[i]),
190+
.empty_o (buf_req_empty[i]),
191+
.usage_o (buf_req_usage[i]),
192+
// Onehot mask.
193+
.data_i (buf_req_data_in[i]),
194+
.push_i (buf_req_push[i]),
195+
.data_o (buf_req_data_out[i]),
196+
.pop_i (buf_req_pop[i])
197+
);
198+
199+
fifo_v3 #(
200+
.DATA_WIDTH ( $bits(buf_rsp_t) ),
201+
.DEPTH ( BufferDepth+1 )
202+
) i_fifo_rsp (
203+
.clk_i,
204+
.rst_ni,
205+
.flush_i (1'b0),
206+
.testmode_i (1'b0),
207+
.full_o (buf_rsp_full[i]),
208+
.empty_o (buf_rsp_empty[i]),
209+
.usage_o (buf_rsp_usage[i]),
210+
// Onehot mask.
211+
.data_i (buf_rsp_data_in[i]),
212+
.push_i (buf_rsp_push[i]),
213+
.data_o (buf_rsp_data_out[i]),
214+
.pop_i (buf_rsp_pop[i])
215+
);
216+
end
217+
218+
108219
endmodule : ita_hwpe_wrap

0 commit comments

Comments
 (0)