From ae4a2614638db88937677da6fba7886321236953 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Fri, 8 Jul 2011 06:03:07 -0400 Subject: [PATCH] Internals: Rename UnaryMin to Negate. No functional change. --- include/verilated.h | 26 +++++++++++++------------- nodist/vtree_importer | 2 +- src/V3AstNodes.h | 10 +++++----- src/V3Cast.cpp | 2 +- src/V3Const.cpp | 2 +- src/V3Expand.cpp | 5 ++--- src/V3Number.cpp | 24 ++++++++++++------------ src/V3Number.h | 2 +- src/V3Number_test.cpp | 6 +++--- src/V3Premit.cpp | 12 ++++++------ src/V3Signed.cpp | 2 +- src/V3Width.cpp | 2 +- src/verilog.y | 2 +- test_verilated/vgen.pl | 8 ++++---- 14 files changed, 52 insertions(+), 53 deletions(-) diff --git a/include/verilated.h b/include/verilated.h index dbbc2c2c8..692627a44 100644 --- a/include/verilated.h +++ b/include/verilated.h @@ -948,11 +948,11 @@ static inline WDataOutP VL_SUB_W(int words, WDataOutP owp,WDataInP lwp,WDataInP // Optimization bug in GCC 2.96 and presumably all-pre GCC 3 versions need this workaround, // we can't just -//# define VL_UNARYMIN_I(data) (-(data)) -static inline IData VL_UNARYMIN_I(IData data) { return -data; } -static inline QData VL_UNARYMIN_Q(QData data) { return -data; } +//# define VL_NEGATE_I(data) (-(data)) +static inline IData VL_NEGATE_I(IData data) { return -data; } +static inline QData VL_NEGATE_Q(QData data) { return -data; } -static inline WDataOutP VL_UNARYMIN_W(int words, WDataOutP owp,WDataInP lwp){ +static inline WDataOutP VL_NEGATE_W(int words, WDataOutP owp,WDataInP lwp){ QData carry = 0; for (int i=0; i sub { p "TRACE what{";p1;p ",";p2;p ",";p3;p ",";p4;p ",";p5;p "}";nl; }, 'UCFUNC' => sub { p '$c(';p1;p ",";p2;p ",";p3;p ",";p4;p ",";p5;p ")"; }, 'UCSTMT' => sub { p '$c(';p1;p ",";p2;p ",";p3;p ",";p4;p ",";p5;p ");";nl; }, - 'UNARYMIN' => sub { p " -";p1; }, + 'NEGATE' => sub { p " -";p1; }, 'VAR' => sub { p_var(); }, 'VARPIN' => sub { p "VARPIN what{";p1;p ",";p2;p ",";p3;p ",";p4;p ",";p5;p "}";nl; }, 'VARREF' => sub { a1; }, diff --git a/src/V3AstNodes.h b/src/V3AstNodes.h index 83978cfed..8b384e0c0 100644 --- a/src/V3AstNodes.h +++ b/src/V3AstNodes.h @@ -2472,13 +2472,13 @@ struct AstUCFunc : public AstNodeMath { //====================================================================== // Unary ops -struct AstUnaryMin : public AstNodeUniop { - AstUnaryMin(FileLine* fl, AstNode* lhsp) : AstNodeUniop(fl, lhsp) { +struct AstNegate : public AstNodeUniop { + AstNegate(FileLine* fl, AstNode* lhsp) : AstNodeUniop(fl, lhsp) { if (lhsp) widthSignedFrom(lhsp); } - ASTNODE_NODE_FUNCS(UnaryMin, UNARYMIN) - virtual void numberOperate(V3Number& out, const V3Number& lhs) { out.opUnaryMin(lhs); } + ASTNODE_NODE_FUNCS(Negate, NEGATE) + virtual void numberOperate(V3Number& out, const V3Number& lhs) { out.opNegate(lhs); } virtual string emitVerilog() { return "%f(- %l)"; } - virtual string emitC() { return "VL_UNARYMIN_%lq(%lW, %P, %li)"; } + virtual string emitC() { return "VL_NEGATE_%lq(%lW, %P, %li)"; } virtual bool cleanOut() {return false;} virtual bool cleanLhs() {return false;} virtual bool sizeMattersLhs() {return true;} }; diff --git a/src/V3Cast.cpp b/src/V3Cast.cpp index 40e1b032a..4be7091d4 100644 --- a/src/V3Cast.cpp +++ b/src/V3Cast.cpp @@ -135,7 +135,7 @@ private: insureLower32Cast(nodep); nodep->user1(1); } - virtual void visit(AstUnaryMin* nodep, AstNUser*) { + virtual void visit(AstNegate* nodep, AstNUser*) { nodep->iterateChildren(*this); nodep->user1(nodep->lhsp()->user1()); if (nodep->lhsp()->widthMin()==1) { diff --git a/src/V3Const.cpp b/src/V3Const.cpp index 179aa09a5..b43b8bc99 100644 --- a/src/V3Const.cpp +++ b/src/V3Const.cpp @@ -1664,7 +1664,7 @@ private: TREEOP ("AstShiftRS{$lhsp.isZero, $rhsp}", "replaceZero(nodep)"); TREEOP ("AstXor {$lhsp.isZero, $rhsp}", "replaceWRhs(nodep)"); TREEOP ("AstXnor {$lhsp.isZero, $rhsp}", "AstNot{$rhsp}"); - TREEOP ("AstSub {$lhsp.isZero, $rhsp}", "AstUnaryMin{$rhsp}"); + TREEOP ("AstSub {$lhsp.isZero, $rhsp}", "AstNegate{$rhsp}"); TREEOP ("AstAdd {$lhsp, $rhsp.isZero}", "replaceWLhs(nodep)"); TREEOP ("AstAnd {$lhsp, $rhsp.isZero}", "replaceZero(nodep)"); TREEOP ("AstLogAnd{$lhsp, $rhsp.isZero}", "replaceZero(nodep)"); diff --git a/src/V3Expand.cpp b/src/V3Expand.cpp index 75110d5c0..b27152ca2 100644 --- a/src/V3Expand.cpp +++ b/src/V3Expand.cpp @@ -696,8 +696,7 @@ private: int lhswidth = lhsp->widthMin(); if (lhswidth==1) { UINFO(8," REPLICATE(w1) "<fileline(), - lhsp); + newp = new AstNegate (nodep->fileline(), lhsp); } else { UINFO(8," REPLICATE "<rhsp()->castConst(); @@ -731,7 +730,7 @@ private: for (int w=0; wwidthWords(); w++) { AstNode* newp; if (lhswidth==1) { - newp = new AstUnaryMin (nodep->fileline(), lhsp->cloneTree(true)); + newp = new AstNegate (nodep->fileline(), lhsp->cloneTree(true)); newp->width(VL_WORDSIZE,VL_WORDSIZE); } else { newp = newAstWordSelClone (lhsp, w); diff --git a/src/V3Number.cpp b/src/V3Number.cpp index 83f5de8e4..3ae923851 100644 --- a/src/V3Number.cpp +++ b/src/V3Number.cpp @@ -1079,12 +1079,12 @@ V3Number& V3Number::opAbsS (const V3Number& lhs) { // op i, L(lhs) bit return if (lhs.isFourState()) return setAllBitsX(); if (lhs.isNegative()) { - return opUnaryMin(lhs); + return opNegate(lhs); } else { return opAssign(lhs); } } -V3Number& V3Number::opUnaryMin (const V3Number& lhs) { +V3Number& V3Number::opNegate (const V3Number& lhs) { // op i, L(lhs) bit return if (lhs.isFourState()) return setAllBitsX(); V3Number notlhs (lhs.m_fileline, width()); @@ -1112,7 +1112,7 @@ V3Number& V3Number::opSub (const V3Number& lhs, const V3Number& rhs) { // i op j, max(L(lhs),L(rhs)) bit return, if any 4-state, 4-state return if (lhs.isFourState() || rhs.isFourState()) return setAllBitsX(); V3Number negrhs (rhs.m_fileline, rhs.width()); - negrhs.opUnaryMin(rhs); + negrhs.opNegate(rhs); return opAdd(lhs, negrhs); } V3Number& V3Number::opMul (const V3Number& lhs, const V3Number& rhs) { @@ -1140,12 +1140,12 @@ V3Number& V3Number::opMul (const V3Number& lhs, const V3Number& rhs) { V3Number& V3Number::opMulS (const V3Number& lhs, const V3Number& rhs) { // Signed multiply if (lhs.isFourState() || rhs.isFourState()) return setAllBitsX(); - V3Number lhsNoSign = lhs; if (lhs.isNegative()) lhsNoSign.opUnaryMin(lhs); - V3Number rhsNoSign = rhs; if (rhs.isNegative()) rhsNoSign.opUnaryMin(rhs); + V3Number lhsNoSign = lhs; if (lhs.isNegative()) lhsNoSign.opNegate(lhs); + V3Number rhsNoSign = rhs; if (rhs.isNegative()) rhsNoSign.opNegate(rhs); V3Number qNoSign = opMul(lhsNoSign,rhsNoSign); if ((lhs.isNegative() && !rhs.isNegative()) || (!lhs.isNegative() && rhs.isNegative())) { - opUnaryMin(qNoSign); + opNegate(qNoSign); } else { opAssign(qNoSign); } @@ -1169,13 +1169,13 @@ V3Number& V3Number::opDivS (const V3Number& lhs, const V3Number& rhs) { //UINFO(9, ">>divs-start "<divs-mid "<fileline(), - new AstShiftR(nodep->fileline(), - nodep->lhsp()->cloneTree(false), - new AstConst(nodep->fileline(), - nodep->widthMin()-1), - nodep->width())); + constzerop = new AstNegate (nodep->fileline(), + new AstShiftR(nodep->fileline(), + nodep->lhsp()->cloneTree(false), + new AstConst(nodep->fileline(), + nodep->widthMin()-1), + nodep->width())); } else { V3Number zeronum (nodep->fileline(), nodep->width(), 0); constzerop = new AstConst(nodep->fileline(), zeronum); diff --git a/src/V3Signed.cpp b/src/V3Signed.cpp index 9563c6d77..c56d03525 100644 --- a/src/V3Signed.cpp +++ b/src/V3Signed.cpp @@ -120,7 +120,7 @@ private: //======= // Signed: Output signed iff LHS signed; unary operator virtual void visit(AstNot* nodep, AstNUser*) { signed_Olhs(nodep); } - virtual void visit(AstUnaryMin* nodep, AstNUser*) { signed_Olhs(nodep); } + virtual void visit(AstNegate* nodep, AstNUser*) { signed_Olhs(nodep); } virtual void visit(AstShiftL* nodep, AstNUser*) { signed_Olhs(nodep); } virtual void visit(AstShiftR* nodep, AstNUser*) { signed_Olhs(nodep); } diff --git a/src/V3Width.cpp b/src/V3Width.cpp index 304ae9b63..864e94787 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -156,7 +156,7 @@ private: // Widths: out width = lhs width, but upper matters virtual void visit(AstNot* nodep, AstNUser* vup) { width_Olhs_L(nodep,vup); } - virtual void visit(AstUnaryMin* nodep, AstNUser* vup) { width_Olhs_L(nodep,vup); } + virtual void visit(AstNegate* nodep, AstNUser* vup) { width_Olhs_L(nodep,vup); } // Widths: out width = lhs width, upper doesn't matter virtual void visit(AstSigned* nodep, AstNUser* vup) { width_Olhs_Lforce(nodep,vup); } diff --git a/src/verilog.y b/src/verilog.y index 28d6c4214..0a0d0b300 100644 --- a/src/verilog.y +++ b/src/verilog.y @@ -2377,7 +2377,7 @@ expr: // IEEE: part of expression/constant_expression/primary // // // IEEE: unary_operator primary '+' ~r~expr %prec prUNARYARITH { $$ = $2; } - | '-' ~r~expr %prec prUNARYARITH { $$ = new AstUnaryMin ($1,$2); } + | '-' ~r~expr %prec prUNARYARITH { $$ = new AstNegate ($1,$2); } | '!' ~r~expr %prec prNEGATION { $$ = new AstLogNot ($1,$2); } | '&' ~r~expr %prec prREDUCTION { $$ = new AstRedAnd ($1,$2); } | '~' ~r~expr %prec prNEGATION { $$ = new AstNot ($1,$2); } diff --git a/test_verilated/vgen.pl b/test_verilated/vgen.pl index bfd01b557..0bd9026d7 100755 --- a/test_verilated/vgen.pl +++ b/test_verilated/vgen.pl @@ -58,7 +58,7 @@ our $Raise_Weight_Max = 50; 'VREDXNOR'=> {weight=>1&&1, width=>1, signed=>0, sc=>0, terminal=>0, v=>'(^~ %1)', }, 'VREDXOR'=> {weight=>1&&1, width=>1, signed=>0, sc=>0, terminal=>0, v=>'(^ %1)', }, 'VNOT'=> {weight=>1&&3, width=>0, sc=>1, terminal=>0, v=>'(~ %1)', }, - 'VUNARYMIN'=> {weight=>1&&2, width=>0, sc=>1, terminal=>0, v=>'(- %1)', }, + 'VNEGATE'=> {weight=>1&&2, width=>0, sc=>1, terminal=>0, v=>'(- %1)', }, 'VCOUNTONES'=> {weight=>0&&2, width=>32, signed=>0, sc=>0, terminal=>0, v=>'\$countones(%1)', }, # No ncv support 'VONEHOT'=> {weight=>0&&2, width=>1, signed=>0, sc=>0, terminal=>0, v=>'\$onehot(%1)', }, # No ncv support 'VONEHOT0'=> {weight=>0&&2, width=>1, signed=>0, sc=>0, terminal=>0, v=>'\$onehot0(%1)', }, # No ncv support @@ -143,7 +143,7 @@ my %ops2 = 'VREDXOR'=> {pl=>'VREDXOR (%tr,%1v);', rnd=>'%1r=gen_leaf(width=>0);'}, 'VREDXNOR'=> {pl=>'VREDXNOR (%tr,%1v);', rnd=>'%1r=gen_leaf(width=>0);'}, 'VNOT'=> {pl=>'VNOT (%tr,%1v);', rnd=>'%1r=gen_leaf(width=>%tw,signed=>%tg);'}, - 'VUNARYMIN'=> {pl=>'VUNARYMIN(%tr,%1v);', rnd=>'%1r=gen_leaf(width=>%tw,signed=>%tg);'}, + 'VNEGATE'=> {pl=>'VNEGATE (%tr,%1v);', rnd=>'%1r=gen_leaf(width=>%tw,signed=>%tg);'}, 'VCOUNTONES'=> {pl=>'VCOUNTONES(%tr,%1v);', rnd=>'%1r=gen_leaf(width=>0);'}, 'VONEHOT'=> {pl=>'VONEHOT (%tr,%1v);', rnd=>'%1r=gen_leaf(width=>0);'}, 'VONEHOT0'=> {pl=>'VONEHOT0 (%tr,%1v);', rnd=>'%1r=gen_leaf(width=>0);'}, @@ -893,8 +893,8 @@ sub countones { } -sub VLOGNOT { $_[0]{val} = makebool(($_[1]->is_empty)?1:0); } -sub VUNARYMIN { $_[0]{val} = my $o = newsized($_[1]); $o->Negate($_[1]); } +sub VLOGNOT { $_[0]{val} = makebool(($_[1]->is_empty)?1:0); } +sub VNEGATE { $_[0]{val} = my $o = newsized($_[1]); $o->Negate($_[1]); } sub VCOUNTONES { $_[0]{val} = Bit::Vector->new_Dec(32,countones($_[1])); } sub VONEHOT { $_[0]{val} = makebool((countones($_[1])==1)?1:0); } sub VONEHOT0 { $_[0]{val} = makebool((countones($_[1])<=1)?1:0); }