Retain widthSized when simulating

This commit is contained in:
Todd Strader 2019-08-12 08:33:58 -04:00
parent edc0f442e4
commit b947391662
13 changed files with 40 additions and 33 deletions

View File

@ -72,6 +72,12 @@ public:
, m_num(this, width, value) {
initWithNumber();
}
class DtypedValue{}; // for creator type-overload selection
AstConst(FileLine* fl, DtypedValue, AstNodeDType* nodedtypep, uint32_t value)
: AstNodeMath(fl)
, m_num(this, nodedtypep->width(), value, nodedtypep->widthSized()) {
initWithNumber();
}
class StringToParse {}; // for creator type-overload selection
AstConst(FileLine* fl, StringToParse, const char* sourcep)
: AstNodeMath(fl)

View File

@ -140,8 +140,8 @@ public:
// CONSTRUCTORS
explicit V3Number(AstNode* nodep) { init(nodep, 1); }
V3Number(AstNode* nodep, int width) { init(nodep, width); } // 0=unsized
V3Number(AstNode* nodep, int width, uint32_t value) {
init(nodep, width); m_value[0] = value; opCleanThis();
V3Number(AstNode* nodep, int width, uint32_t value, bool sized=true) {
init(nodep, width, sized); m_value[0] = value; opCleanThis();
}
// Create from a verilog 32'hxxxx number.
V3Number(AstNode* nodep, const char* sourcep) { V3NumberCreate(nodep, sourcep, NULL); }
@ -164,14 +164,14 @@ public:
private:
void V3NumberCreate(AstNode* nodep, const char* sourcep, FileLine* fl);
void init(AstNode* nodep, int swidth) {
void init(AstNode* nodep, int swidth, bool sized=true) {
setNames(nodep);
m_signed = false;
m_double = false;
m_isString = false;
m_autoExtend = false;
m_fromString = false;
width(swidth);
width(swidth, sized);
for (int i=0; i<words(); i++) m_value[i] = m_valueX[i] = 0;
}
void setNames(AstNode* nodep);

View File

@ -220,15 +220,14 @@ private:
// It would be more efficient to do this by size, but the extra accounting
// slows things down more than we gain.
AstConst* constp;
AstNodeDType* dtypep = nodep->findLogicDType(nodep->width(), 0, AstNumeric::UNSIGNED);
AstNodeDType* dtypep = nodep->dtypep();
if (!m_constFreeps[dtypep].empty()) {
//UINFO(7,"Num Reuse "<<nodep->width()<<endl);
constp = m_constFreeps[dtypep].back(); m_constFreeps[dtypep].pop_back();
constp->num().nodep(nodep);
} else {
//UINFO(7,"Num New "<<nodep->width()<<endl);
constp = new AstConst(nodep->fileline(), AstConst::WidthedValue(), nodep->width(), 0);
UASSERT_OBJ(dtypep == constp->dtypep(), nodep, "Unexpected dtype");
constp = new AstConst(nodep->fileline(), AstConst::DtypedValue(), nodep->dtypep(), 0);
m_constAllps[constp->dtypep()].push_back(constp);
}
constp->num().isDouble(nodep->isDouble());

View File

@ -7,9 +7,9 @@
a = 32'h7
b = 32'h8
t/t_func_const2_bad.v:21: ... Called from f_add2() with parameters:
a = 32'h7
b = 32'h8
c = 32'h9
a = ?32?h7
b = ?32?h8
c = ?32?h9
localparam SOMEP = f_add2(A, B, 9);
^~~~~~
%Error: Exiting due to

View File

@ -7,28 +7,28 @@
: ... In instance t
t/t_func_const_bad.v:22: ... Location of non-constant VARXREF 'EIGHT': Language violation: Dotted hierarchical references not allowed in constant functions
t/t_func_const_bad.v:20: ... Called from f_bad_dotted() with parameters:
a = 32'h2
a = ?32?h2
localparam B2 = f_bad_dotted(2);
^~~~~~~~~~~~
%Error: t/t_func_const_bad.v:27: Expecting expression to be constant, but can't determine constant for FUNCREF 'f_bad_nonparam'
: ... In instance t
t/t_func_const_bad.v:29: ... Location of non-constant VARREF 'modvar': Language violation: reference to non-function-local variable
t/t_func_const_bad.v:27: ... Called from f_bad_nonparam() with parameters:
a = 32'h3
a = ?32?h3
localparam B3 = f_bad_nonparam(3);
^~~~~~~~~~~~~~
%Error: t/t_func_const_bad.v:35: Expecting expression to be constant, but can't determine constant for FUNCREF 'f_bad_infinite'
: ... In instance t
t/t_func_const_bad.v:37: ... Location of non-constant WHILE: Loop unrolling took too long; probably this is an infinite loop, or set --unroll-count above 1024
t/t_func_const_bad.v:35: ... Called from f_bad_infinite() with parameters:
a = 32'h3
a = ?32?h3
localparam B4 = f_bad_infinite(3);
^~~~~~~~~~~~~~
%Error: t/t_func_const_bad.v:43: Expecting expression to be constant, but can't determine constant for FUNCREF 'f_bad_stop'
: ... In instance t
t/t_func_const_bad.v:45: ... Location of non-constant STOP: $stop executed during function constification; maybe indicates assertion firing
t/t_func_const_bad.v:43: ... Called from f_bad_stop() with parameters:
a = 32'h3
a = ?32?h3
localparam BSTOP = f_bad_stop(3);
^~~~~~~~~~
-Info: "Printing in loop: 0"
@ -40,7 +40,7 @@
: ... In instance t
t/t_func_const_bad.v:54: ... Location of non-constant STOP: $stop executed during function constification; maybe indicates assertion firing
t/t_func_const_bad.v:49: ... Called from f_bad_fatal() with parameters:
a = 32'h3
a = ?32?h3
localparam BFATAL = f_bad_fatal(3);
^~~~~~~~~~~
%Error: Exiting due to

View File

@ -6,9 +6,9 @@
t/t_func_const_packed_array_bad.v:30: ... Called from f_add() with parameters:
params = [0 = 32'h7, 1 = 32'h8]
t/t_func_const_packed_array_bad.v:11: ... Called from f_add2() with parameters:
a = 32'h7
b = 32'h8
c = 32'h9
a = ?32?h7
b = ?32?h8
c = ?32?h9
localparam P24 = f_add2(7, 8, 9);
^~~~~~
%Error: Exiting due to

View File

@ -6,9 +6,9 @@
t/t_func_const_packed_struct_bad.v:32: ... Called from f_add() with parameters:
params = [0 = '{a: 32'h7, b: 32'h22b}, 1 = '{a: 32'h3039, b: 32'h8}]
t/t_func_const_packed_struct_bad.v:13: ... Called from f_add2() with parameters:
a = 32'h7
b = 32'h8
c = 32'h9
a = ?32?h7
b = ?32?h8
c = ?32?h9
localparam P24 = f_add2(7, 8, 9);
^~~~~~
%Error: Exiting due to

View File

@ -6,9 +6,9 @@
t/t_func_const_packed_struct_bad2.v:42: ... Called from f_add() with parameters:
params = [0 = '{a: 32'h7, foo: 6'hb, sub_params: '{b: 32'h37, bar: 8'h6f}}, 1 = '{a: 32'h3039, foo: 6'hc, sub_params: '{b: 32'h8, bar: 8'h70}}]
t/t_func_const_packed_struct_bad2.v:19: ... Called from f_add2() with parameters:
a = 32'h7
b = 32'h8
c = 32'h9
a = ?32?h7
b = ?32?h8
c = ?32?h9
localparam P24 = f_add2(7, 8, 9);
^~~~~~
%Error: Exiting due to

View File

@ -6,9 +6,9 @@
t/t_func_const_struct_bad.v:37: ... Called from f_add() with parameters:
params = '{a: 32'h7, b: 32'h8}
t/t_func_const_struct_bad.v:16: ... Called from f_add2() with parameters:
a = 32'h7
b = 32'h8
c = 32'h9
a = ?32?h7
b = ?32?h8
c = ?32?h9
localparam P24 = f_add2(7, 8, 9);
^~~~~~
%Error: Exiting due to

View File

@ -4,14 +4,14 @@
: ... In instance t.genloop[0].foo_inst
t/t_generate_fatal_bad.v:8: ... Location of non-constant STOP: $stop executed during function constification; maybe indicates assertion firing
t/t_generate_fatal_bad.v:12: ... Called from get_baz() with parameters:
bar = 32'h0
bar = ?32?h0
localparam integer BAZ = get_baz(BAR);
^~~~~~~
%Error: t/t_generate_fatal_bad.v:12: Expecting expression to be constant, but can't determine constant for FUNCREF 'get_baz'
: ... In instance t.genloop[1].foo_inst
t/t_generate_fatal_bad.v:8: ... Location of non-constant STOP: $stop executed during function constification; maybe indicates assertion firing
t/t_generate_fatal_bad.v:12: ... Called from get_baz() with parameters:
bar = 32'h1
bar = ?32?h1
localparam integer BAZ = get_baz(BAR);
^~~~~~~
%Error: t/t_generate_fatal_bad.v:12: Expecting expression to be constant, but can't determine constant for FUNCREF 'get_baz'
@ -46,14 +46,14 @@
: ... In instance t.cond_true.foo_inst3
t/t_generate_fatal_bad.v:8: ... Location of non-constant STOP: $stop executed during function constification; maybe indicates assertion firing
t/t_generate_fatal_bad.v:12: ... Called from get_baz() with parameters:
bar = 32'h6
bar = ?32?h6
localparam integer BAZ = get_baz(BAR);
^~~~~~~
%Error: t/t_generate_fatal_bad.v:12: Expecting expression to be constant, but can't determine constant for FUNCREF 'get_baz'
: ... In instance t.genblk1.foo_inst4
t/t_generate_fatal_bad.v:8: ... Location of non-constant STOP: $stop executed during function constification; maybe indicates assertion firing
t/t_generate_fatal_bad.v:12: ... Called from get_baz() with parameters:
bar = 32'h7
bar = ?32?h7
localparam integer BAZ = get_baz(BAR);
^~~~~~~
%Error: t/t_generate_fatal_bad.v:12: Expecting expression to be constant, but can't determine constant for FUNCREF 'get_baz'

View File

@ -7,7 +7,7 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
$Self->{vlt_all} and unsupported("Verilator unsupported, bug1487.");
$Self->{vlt_all};
scenarios(linter => 1);

View File

@ -26,7 +26,9 @@ module t (/*AUTOARG*/
end
initial begin
for (integer i=0; i < 15; ++i) begin
/* verilator lint_off WIDTH */
ri = i;
/* verilator lint_on WIDTH */
end
end

View File

@ -1,4 +1,4 @@
%Warning-WIDTH: t/t_lint_width_genfor_bad.v:24: Operator ASSIGN expects 4 bits on the Assign RHS, but Assign RHS's CONST '32'h10' generates 32 bits.
%Warning-WIDTH: t/t_lint_width_genfor_bad.v:24: Operator ASSIGN expects 4 bits on the Assign RHS, but Assign RHS's CONST '?32?h10' generates 32 or 5 bits.
: ... In instance t
rg = g;
^