-
Notifications
You must be signed in to change notification settings - Fork 177
smem read port always reads address 0 #913
Comments
This is most certainly a bug, and so far, I'm only more confused, I generated the following with Chisel:
The only difference is an aggregate IO, and yet this works: reg [1:0] mem__T_16_addr_pipe_0;
assign mem__T_16_addr = mem__T_16_addr_pipe_0;
assign mem__T_16_data = mem[mem__T_16_addr];
wire _GEN_0;
assign _GEN_0 = 1'h1;
always @(posedge clock) begin
if (_GEN_0) begin
mem__T_16_addr_pipe_0 <= io_raddr;
end
end |
WorkaroundThe issue comes from using a non-aggregate input as a read address. You can work around this by assigning the read address input to an intermediate node or wire and then using that wire as the address for the memory. For example:
DiagnosisPossibly related to #840 This appears to be due to logic introduced over two years ago in #203. The difference between my code that works, and the given code that doesn't is the non-working code follows this code path: https://github.com/freechipsproject/firrtl/blob/ceac36d7ce1223078ca47bc097884532faacd7e1/src/main/scala/firrtl/passes/RemoveCHIRRTL.scala#L144 I think this code path is used for R/W port inference. In this case, a read port enable cannot be set to It appears this issue was fixed for aggregate ports by #226 but this looks like a corner case that slipped through that fix. I would also bet that #203 (ie. R/W port inference) does not work with fields of aggregate wires being used as memory read port addresses. I can patch this error, but I think similar such errors lurk in RemoveCHIRRTL, the real fix is #727 |
I ran into this same issue where the address was created by Cat, and was able to use the workaround of having an intermediate wire. |
Just stumbled over the same bug.
gets lowered to:
Adding a node fixes that:
lowers to
|
Closed and absorbed into #727 |
Type of issue: bug report
I'm having problems with
smem
memories. Consider this circuit as an example:When I convert this to Verilog (using firrtl git HEAD, commit ed70957), I get the following (trimmed for clarity):
Because of the
assign _GEN_0 = 1'h0
, themem__T_1_addr_pipe_0
is never written to, so the circuit always reads from the memory address 0 (or whatevermem__T_1_addr_pipe_0
is initialized to).This looks like a bug, but it's hard to say exactly because
smem
memories are not documented. Any insights into this?The text was updated successfully, but these errors were encountered: