* test:Add more tests for checking split_var for unpacked array. * Fix range calculation of SliceSel and change to UASSERT_OBJ because the range check is done in V3Width beforehand.
This commit is contained in:
parent
16547077a1
commit
6acd5847e7
|
|
@ -275,10 +275,6 @@ public:
|
|||
return m_index;
|
||||
}
|
||||
AstNode* context() const { return m_contextp; }
|
||||
std::pair<int, int> range() const {
|
||||
UASSERT_OBJ(VN_IS(m_nodep, SliceSel), m_nodep, "not slice sel");
|
||||
return std::make_pair(m_msb, m_lsb);
|
||||
}
|
||||
bool lvalue() const { return m_lvalue; }
|
||||
bool ftask() const { return m_ftask; }
|
||||
bool operator<(const UnpackRef& other) const {
|
||||
|
|
@ -584,16 +580,16 @@ class SplitUnpackedVarVisitor : public AstNVisitor, public SplitVarImpl {
|
|||
if (AstVarRef* refp = isTargetVref(nodep->fromp())) {
|
||||
AstUnpackArrayDType* dtypep
|
||||
= VN_CAST(refp->varp()->dtypep()->skipRefp(), UnpackArrayDType);
|
||||
if (dtypep->lsb() <= nodep->declRange().lo()
|
||||
&& nodep->declRange().hi() <= dtypep->msb()) { // Range is ok
|
||||
UINFO(4, "add " << nodep << " for " << refp->varp()->prettyName() << "\n");
|
||||
m_refs.tryAdd(m_contextp, refp, nodep, nodep->declRange().hi(),
|
||||
nodep->declRange().lo(), m_inFTask);
|
||||
} else {
|
||||
nodep->v3warn(SPLITVAR, refp->prettyNameQ()
|
||||
<< notSplitMsg << "index if out of range.\n");
|
||||
m_refs.remove(refp->varp());
|
||||
}
|
||||
// declRange() of AstSliceSel is shifted by dtypep->declRange().lo() in V3WidthSel.cpp
|
||||
// restore the original decl range here.
|
||||
const VNumRange selRange{nodep->declRange().hi() + dtypep->declRange().lo(),
|
||||
nodep->declRange().lo() + dtypep->declRange().lo(),
|
||||
nodep->declRange().littleEndian()};
|
||||
UASSERT_OBJ(dtypep->lsb() <= selRange.lo() && selRange.hi() <= dtypep->msb(), nodep,
|
||||
"Range check for AstSliceSel must have been finished in V3Width.cpp");
|
||||
UINFO(4, "add " << nodep << " for " << refp->varp()->prettyName() << "\n");
|
||||
m_refs.tryAdd(m_contextp, refp, nodep, nodep->declRange().hi(),
|
||||
nodep->declRange().lo(), m_inFTask);
|
||||
} else {
|
||||
iterateChildren(nodep);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,6 @@ execute(
|
|||
);
|
||||
|
||||
file_grep($Self->{stats}, qr/SplitVar,\s+Split packed variables\s+(\d+)/i, 13);
|
||||
file_grep($Self->{stats}, qr/SplitVar,\s+Split unpacked arrays\s+(\d+)/i, 23);
|
||||
file_grep($Self->{stats}, qr/SplitVar,\s+Split unpacked arrays\s+(\d+)/i, 27);
|
||||
ok(1);
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -381,6 +381,39 @@ module through #(parameter WIDTH = 8)
|
|||
|
||||
endmodule
|
||||
|
||||
module delay (input wire clk);
|
||||
logic unpack_sig0 [10:16] /*verilator split_var*/;
|
||||
logic unpack_sig1 [13:16] /*verilator split_var*/;
|
||||
logic unpack_sig2 [16:10] /*verilator split_var*/;
|
||||
logic unpack_sig3 [16:13] /*verilator split_var*/;
|
||||
|
||||
always @(posedge clk) begin
|
||||
if (c <= 5) begin
|
||||
unpack_sig0[13] <= 1'b1;
|
||||
unpack_sig1[13] <= 1'b1;
|
||||
unpack_sig0 [13+1:16] <= unpack_sig0[13:16-1];
|
||||
unpack_sig1 [13+1:16] <= unpack_sig1[13:16-1];
|
||||
unpack_sig2[13] <= 1'b1;
|
||||
unpack_sig3[13] <= 1'b1;
|
||||
unpack_sig2 [16:13+1] <= unpack_sig2[16-1:13];
|
||||
unpack_sig3 [16:13+1] <= unpack_sig3[16-1:13];
|
||||
end
|
||||
end
|
||||
|
||||
int c = 0;
|
||||
always @(posedge clk) begin
|
||||
c <= c + 1;
|
||||
if (c >= 4) begin
|
||||
if (!unpack_sig0[16] || !unpack_sig1[16]) $stop;
|
||||
if (!unpack_sig2[16] || !unpack_sig3[16]) $stop;
|
||||
end else begin
|
||||
if (unpack_sig0[16] || unpack_sig1[16]) $stop;
|
||||
if (unpack_sig2[16] || unpack_sig3[16]) $stop;
|
||||
end
|
||||
end
|
||||
endmodule
|
||||
|
||||
|
||||
module t(/*AUTOARG*/ clk);
|
||||
input clk;
|
||||
localparam DEPTH = 3;
|
||||
|
|
@ -403,6 +436,7 @@ module t(/*AUTOARG*/ clk);
|
|||
barshift_1d_packed_struct shifter7(.in(in), .out(out[7]), .shift(shift));
|
||||
barshift_bitslice #(.DEPTH(DEPTH)) shifter8(.in(in), .out(out[8]), .shift(shift));
|
||||
through #(.WIDTH(WIDTH)) though0 (.in(out[8]), .out(through_tmp));
|
||||
delay delay0(.clk(clk));
|
||||
var_decl_with_init i_var_decl_with_init();
|
||||
t_array_rev i_t_array_rev(clk);
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -25,7 +25,7 @@ execute(
|
|||
|
||||
vcd_identical("$Self->{obj_dir}/simx.vcd", $Self->{golden_filename});
|
||||
file_grep($Self->{stats}, qr/SplitVar,\s+Split packed variables\s+(\d+)/i, 12);
|
||||
file_grep($Self->{stats}, qr/SplitVar,\s+Split unpacked arrays\s+(\d+)/i, 23);
|
||||
file_grep($Self->{stats}, qr/SplitVar,\s+Split unpacked arrays\s+(\d+)/i, 27);
|
||||
|
||||
ok(1);
|
||||
1;
|
||||
|
|
|
|||
Loading…
Reference in New Issue