mirror of
https://github.com/verilator/verilator.git
synced 2025-01-01 04:07:34 +00:00
Co-authored-by: Udaya Raj Subedi <075bei047.udaya@pcampus.edu.np>
This commit is contained in:
parent
8c3cc3af8f
commit
2409f32d87
@ -1404,9 +1404,19 @@ class RandomizeVisitor final : public VNVisitor {
|
|||||||
AstVarRef* tempRefp = new AstVarRef{fl, newRandLoopIndxp, VAccess::READ};
|
AstVarRef* tempRefp = new AstVarRef{fl, newRandLoopIndxp, VAccess::READ};
|
||||||
if (VN_IS(tempDTypep, DynArrayDType))
|
if (VN_IS(tempDTypep, DynArrayDType))
|
||||||
tempElementp = new AstCMethodHard{fl, tempExprp, "atWrite", tempRefp};
|
tempElementp = new AstCMethodHard{fl, tempExprp, "atWrite", tempRefp};
|
||||||
else if (VN_IS(tempDTypep, UnpackArrayDType))
|
else if (VN_IS(tempDTypep, UnpackArrayDType)) {
|
||||||
tempElementp = new AstArraySel{fl, tempExprp, tempRefp};
|
AstNodeArrayDType* const aryDTypep = VN_CAST(tempDTypep, NodeArrayDType);
|
||||||
else if (VN_IS(tempDTypep, AssocArrayDType))
|
// Adjust the bitp to ensure it covers all possible indices
|
||||||
|
tempElementp = new AstArraySel{
|
||||||
|
fl, tempExprp,
|
||||||
|
new AstSel{
|
||||||
|
fl,
|
||||||
|
new AstSub{fl, tempRefp,
|
||||||
|
new AstConst{fl, static_cast<uint32_t>(aryDTypep->lo())}},
|
||||||
|
new AstConst{fl, 0},
|
||||||
|
new AstConst{
|
||||||
|
fl, static_cast<uint32_t>(V3Number::log2b(aryDTypep->hi()) + 1)}}};
|
||||||
|
} else if (VN_IS(tempDTypep, AssocArrayDType))
|
||||||
tempElementp = new AstAssocSel{fl, tempExprp, tempRefp};
|
tempElementp = new AstAssocSel{fl, tempExprp, tempRefp};
|
||||||
else if (VN_IS(tempDTypep, QueueDType))
|
else if (VN_IS(tempDTypep, QueueDType))
|
||||||
tempElementp = new AstCMethodHard{fl, tempExprp, "atWriteAppend", tempRefp};
|
tempElementp = new AstCMethodHard{fl, tempExprp, "atWriteAppend", tempRefp};
|
||||||
|
@ -34,10 +34,14 @@ endclass
|
|||||||
class unconstrained_unpacked_array_test;
|
class unconstrained_unpacked_array_test;
|
||||||
|
|
||||||
rand bit [2:0] [15:0] unpacked_array [3][5];
|
rand bit [2:0] [15:0] unpacked_array [3][5];
|
||||||
|
rand int unpacked_array1 [9:3][4:8];
|
||||||
|
rand int unpacked_array2 [3:9][8:4];
|
||||||
function new();
|
function new();
|
||||||
unpacked_array = '{ '{default: '{default: 'h0}},
|
unpacked_array = '{ '{default: '{default: 'h0}},
|
||||||
'{default: '{default: 'h1}},
|
'{default: '{default: 'h1}},
|
||||||
'{default: '{default: 'h2}}};
|
'{default: '{default: 'h2}}};
|
||||||
|
unpacked_array1 = '{default: '{default: 0}};
|
||||||
|
unpacked_array2 = '{default: '{default: 0}};
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function void check_randomization();
|
function void check_randomization();
|
||||||
@ -47,6 +51,12 @@ class unconstrained_unpacked_array_test;
|
|||||||
`check_rand(this, this.unpacked_array[i][j])
|
`check_rand(this, this.unpacked_array[i][j])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
foreach (unpacked_array1[i, j]) begin
|
||||||
|
`check_rand(this, this.unpacked_array1[i][j])
|
||||||
|
end
|
||||||
|
foreach (unpacked_array2[i, j]) begin
|
||||||
|
`check_rand(this, this.unpacked_array2[i][j])
|
||||||
|
end
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
endclass
|
endclass
|
||||||
|
Loading…
Reference in New Issue
Block a user