New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support unpacked array parameters in functions with complex assign #2639
Comments
Looking at the error source, this suggests the localparam is declared inside a function - is it? If so, move to outside the function into the module itself. |
Hi @wsnyder it's not, these defines are part of a package that's imported at the top of the module in a local scope. |
Can you please convert this into a standalone test case and I'll take a look. Thanks. |
Tks @wsnyder package test_pkg;
localparam [31:0] test_arr [4][11:0] = '{
'{'h0000, 'h1000, 'h2000, 'h3000, 'h4000, 'h5000, 'h6000, 'h7000, 'h8000, 'h9000, 'hA000, 'hB000},
'{'h0FFF, 'h1FFF, 'h2FFF, 'h3FFF, 'h4FFF, 'h5FFF, 'h6FFF, 'h7FFF, 'h8FFF, 'h9FFF, 'hAFFF, 'hBFFF},
'{ 'd0, 'd0, 'd0, 'd0, 'd1, 'd1, 'd1, 'd1, 'd2, 'd2, 'd2, 'd2},
'{ 'd0, 'd1, 'd2, 'd3, 'd0, 'd1, 'd2, 'd3, 'd0, 'd1, 'd2, 'd3}
};
typedef struct packed{
logic [7:0] val_1;
logic [7:0] val_2;
} test_ret_t;
endpackage
module tb import test_pkg::*; ();
logic clk;
initial begin : clk_gen
clk = 0;
forever clk = #5 ~clk;
end
function automatic test_ret_t test_f(logic [31:0] val);
test_ret_t temp;
temp = test_ret_t'(0);
for (int i=0;i<12;i++) begin
if (val >= test_arr[0][i] && val <= test_arr[1][i]) begin
temp.val_1 = test_arr[2][i];
temp.val_2 = test_arr[3][i];
end
end
return temp;
endfunction
test_ret_t temp;
logic [31:0] random;
initial begin
for (int i=0;i<10;i++) begin
random <= $urandom_range(0,'hbfff);
temp <= test_f(random);
$display("rand: %h / Values -> val_1: %d / val_2: %d",random,temp.val_1,temp.val_2);
@(posedge clk);
end
$finish;
end
endmodule |
Thanks, that makes sense, probably multidimensional arrays need some extra work in V3Simulate.h. Would you be willing to take a look at patching this? |
Hey @wsnyder I don't know if I have enough bkg to change such scope but I can take a look for sure, just let me know which file specific that deals with array manip. |
btw, is there any diff if it's packed vs unpacked for verilator compatibility on this example? |
Packed should work fine, it's forming the unpacked array that causes the error. Let me run it and suggest a path. |
Turned out just the assertion was broken. Fixed. Thanks for the test. |
Hi all,
I'd like to understand from the snippet below what's the unsupported feature I'm trying to use cause there's nothing special on the implementation. It only iterates through the array defined as a localparam in a function based on an input parameter...
The text was updated successfully, but these errors were encountered: