-
Notifications
You must be signed in to change notification settings - Fork 582
Open
Labels
Description
Trying to create byte-enabled memory, like this: (link)
...
// [shw][sby][dat] [ word_count ]
logic [1:0][1:0][7:0] mem[2**MEM_WIDTH-1:0]; // same as [31:0]
always_ff@(posedge clk_i) begin : mem_write
// Unfortunately implicit bit truncation will crash your simulation,
// hence the 7 magic constant instead of 31:2.
err = 1'b0;
if(we) begin
case(be)
// sw
4'b1111: mem[a[7:2]] <= wd; // this is fine
// sh zone
4'b1100: mem[a[7:2]][a[1]] <= wd[31:16]; //this works too
4'b0011: mem[a[7:2]][a[0]] <= wd[15:0];
// sb zone
4'b1000: mem[a[7:2]][a[1]][a[1]] <= wd[31:24]; //throws an iverilog error but works in other simulators
...
Compiles just fine with verilator with no warnings.
Version: Icarus Verilog version 13.0 (devel) ()