Skip to content

Multidimensional indicies are not properly supported. #1277

@avgsurfman

Description

@avgsurfman

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) ()

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions