Fix concats with no argments mis-sign extending, bug759.

This commit is contained in:
Wilson Snyder 2014-05-03 20:20:15 -04:00
parent 48d393d8f5
commit 4a58e859a4
5 changed files with 28 additions and 4 deletions

View File

@ -11,9 +11,10 @@ indicates the contributor was also the author of the fix; Thanks!
** Support streaming operators, bug649. [Glen Gibb]
** Fix expression problems with -Wno-WIDTH, bug729, bug736, bug737. [Clifford Wolf]
** Fix expression problems with -Wno-WIDTH, bug729, bug736, bug737, bug759.
Where WIDTH warnings were ignored this might result in different
warning messages and results, though it should better match the spec.
[Clifford Wolf]
*** Add --no-trace-params.

View File

@ -4164,6 +4164,8 @@ struct AstConcat : public AstNodeBiop {
virtual int instrCount() const { return widthInstrs()*2; }
};
struct AstReplicate : public AstNodeBiop {
// Also used as a "Uniop" flavor of Concat, e.g. "{a}"
// Verilog {rhs{lhs}} - Note rhsp() is the replicate value, not the lhsp()
private:
void init() {
if (lhsp()) {
@ -4173,7 +4175,6 @@ private:
}
}
public:
// Verilog {rhs{lhs}} - Note rhsp() is the replicate value, not the lhsp()
AstReplicate(FileLine* fl, AstNode* lhsp, AstNode* rhsp)
: AstNodeBiop(fl, lhsp, rhsp) { init(); }
AstReplicate(FileLine* fl, AstNode* lhsp, uint32_t repCount)

View File

@ -3003,7 +3003,8 @@ exprNoStr<nodep>: // expression with string removed
exprOkLvalue<nodep>: // expression that's also OK to use as a variable_lvalue
~l~exprScope { $$ = $1; }
// // IEEE: concatenation/constant_concatenation
| '{' cateList '}' { $$ = $2; }
// // Replicate(1) required as otherwise "{a}" would not be self-determined
| '{' cateList '}' { $$ = new AstReplicate($1,$2,1); }
// // IEEE: assignment_pattern_expression
// // IEEE: [ assignment_pattern_expression_type ] == [ ps_type_id /ps_paremeter_id/data_type]
// // We allow more here than the spec requires

View File

@ -18,6 +18,7 @@ module t (/*AUTOARG*/);
reg signed [4:0] w5_s;
reg [3:0] w4_u;
reg [4:0] w5_u;
reg signed [8:0] w9_s;
real r;
initial begin
// verilator lint_off WIDTH
@ -93,7 +94,11 @@ module t (/*AUTOARG*/);
// bug754
w5_u = 4'sb0010 << -2'sd1; // << 3
`ifdef VCS
`checkh(w5_u, 5'b00000); // VCS E-2014.03 bug
`else
`checkh(w5_u, 5'b10000); // VCS E-2014.03 bug
`endif
w5_u = 4'sb1000 << 0; // Sign extends
`checkh(w5_u, 5'b11000);
@ -112,6 +117,22 @@ module t (/*AUTOARG*/);
default: $stop;
endcase
// bug759
w5_u = { -4'sd7 };
`checkh(w5_u, 5'b01001);
w5_u = {2{ -2'sd1 }};
`checkh(w5_u, 5'b01111);
// Don't break concats....
w5_u = {{0{1'b1}}, -4'sd7 };
`checkh(w5_u, 5'b01001);
w9_s = { -4'sd7, -4'sd7 };
`checkh(w9_s, 9'b010011001);
{w5_u, {w4_u}} = 9'b10101_1100;
`checkh(w5_u, 5'b10101);
`checkh(w4_u, 4'b1100);
{w4_u} = 4'b1011;
`checkh(w4_u, 4'b1011);
if (fail) $stop;
$write("*-* All Finished *-*\n");
$finish;

View File

@ -15,7 +15,7 @@ compile (
'%Warning-WIDTHCONCAT: t/t_param_concat.v:\d+: Unsized numbers/parameters not allowed in concatenations.
%Warning-WIDTHCONCAT: Use "/\* verilator lint_off WIDTHCONCAT \*/" and lint_on around source to disable this message.
%Warning-WIDTHCONCAT: t/t_param_concat.v:\d+: Unsized numbers/parameters not allowed in replications.
%Error: Exiting due to.*',
.*%Error: Exiting due to.*',
);
ok(1);