From 45aa8742d82000a60073d70e90adcb50e42fb75b Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Thu, 17 Dec 2009 20:58:14 -0500 Subject: [PATCH] Internals: Rename implicit_typeE to match Verilog-Perl --- src/V3Number.cpp | 9 +++++++++ src/V3Number.h | 4 ++++ src/verilog.y | 47 ++++++++++++++++++++++++----------------------- 3 files changed, 37 insertions(+), 23 deletions(-) diff --git a/src/V3Number.cpp b/src/V3Number.cpp index 0024d79aa..67e558d2a 100644 --- a/src/V3Number.cpp +++ b/src/V3Number.cpp @@ -558,6 +558,15 @@ bool V3Number::isUnknown() const { } return false; } +bool V3Number::isLt(const V3Number& rhs) const { + for (int bit=0; bitwidth(),rhs.width()); bit++) { + if (this->bitIs1(bit) && rhs.bitIs0(bit)) { return 1; } + if (rhs.bitIs1(bit) && this->bitIs0(bit)) { return 0; } + if (this->bitIsXZ(bit)) { return 0; } + if (rhs.bitIsXZ(bit)) { return 0; } + } + return 0; +} int V3Number::minWidth() const { for(int bit=width()-1; bit>0; bit--) { diff --git a/src/V3Number.h b/src/V3Number.h index 225328bdb..f96511900 100644 --- a/src/V3Number.h +++ b/src/V3Number.h @@ -141,6 +141,7 @@ public: bool isEqOne() const; bool isEqAllOnes(int optwidth=0) const; bool isCaseEq(const V3Number& rhsp) const; // operator== + bool isLt(const V3Number& rhsp) const; // operator< void width(int width, bool sized=true); void isSigned(bool ssigned) { m_signed=ssigned; } bool isUnknown() const; @@ -153,6 +154,9 @@ public: uint32_t countOnes() const; uint32_t mostSetBitP1() const; // Highest bit set plus one, IE for 16 return 5, for 0 return 0. + // Operators + bool operator<(const V3Number& rhs) const { return isLt(rhs); } + // STATICS static int log2b(uint32_t num); diff --git a/src/verilog.y b/src/verilog.y index 0cfae89d0..24139780d 100644 --- a/src/verilog.y +++ b/src/verilog.y @@ -113,6 +113,7 @@ public: return pkgp; } AstNodeDType* addRange(AstBasicDType* dtypep, AstRange* rangesp) { + // If dtypep isn't basic, then call createArray() instead if (!rangesp) { return dtypep; } else { @@ -769,24 +770,24 @@ port: // ==IEEE: port //UNSUP portDirNetE signingE rangeList '.' portSig '(' portAssignExprE ')' sigAttrListE { UNSUP } //UNSUP portDirNetE /*implicit*/ '.' portSig '(' portAssignExprE ')' sigAttrListE { UNSUP } // - portDirNetE data_type portSig variable_dimensionListE sigAttrListE + portDirNetE data_type portSig variable_dimensionListE sigAttrListE { $$=$3; VARDTYPE($2); $$->addNextNull(VARDONEP($$,$4,$5)); } - | portDirNetE yVAR data_type portSig variable_dimensionListE sigAttrListE + | portDirNetE yVAR data_type portSig variable_dimensionListE sigAttrListE { $$=$4; VARDTYPE($3); $$->addNextNull(VARDONEP($$,$5,$6)); } - | portDirNetE yVAR implicit_type portSig variable_dimensionListE sigAttrListE + | portDirNetE yVAR implicit_typeE portSig variable_dimensionListE sigAttrListE { $$=$4; VARDTYPE($3); $$->addNextNull(VARDONEP($$,$5,$6)); } - | portDirNetE signingE rangeList portSig variable_dimensionListE sigAttrListE + | portDirNetE signingE rangeList portSig variable_dimensionListE sigAttrListE { $$=$4; VARDTYPE(GRAMMARP->addRange(new AstBasicDType($3->fileline(), LOGIC_IMPLICIT, $2), $3)); $$->addNextNull(VARDONEP($$,$5,$6)); } - | portDirNetE /*implicit*/ portSig variable_dimensionListE sigAttrListE + | portDirNetE /*implicit*/ portSig variable_dimensionListE sigAttrListE { $$=$2; /*VARDTYPE-same*/ $$->addNextNull(VARDONEP($$,$3,$4)); } // - | portDirNetE data_type portSig variable_dimensionListE sigAttrListE '=' constExpr + | portDirNetE data_type portSig variable_dimensionListE sigAttrListE '=' constExpr { $$=$3; VARDTYPE($2); $$->addNextNull(VARDONEP($$,$4,$5)); $$->addNextNull(GRAMMARP->newVarInit($6,$$,$7)); } - | portDirNetE yVAR data_type portSig variable_dimensionListE sigAttrListE '=' constExpr + | portDirNetE yVAR data_type portSig variable_dimensionListE sigAttrListE '=' constExpr { $$=$3; VARDTYPE($3); $$->addNextNull(VARDONEP($$,$5,$6)); $$->addNextNull(GRAMMARP->newVarInit($7,$$,$8)); } - | portDirNetE yVAR implicit_type portSig variable_dimensionListE sigAttrListE '=' constExpr + | portDirNetE yVAR implicit_typeE portSig variable_dimensionListE sigAttrListE '=' constExpr { $$=$3; VARDTYPE($3); $$->addNextNull(VARDONEP($$,$5,$6)); $$->addNextNull(GRAMMARP->newVarInit($7,$$,$8)); } - | portDirNetE /*implicit*/ portSig variable_dimensionListE sigAttrListE '=' constExpr + | portDirNetE /*implicit*/ portSig variable_dimensionListE sigAttrListE '=' constExpr { $$=$3; /*VARDTYPE-same*/ $$->addNextNull(VARDONEP($$,$3,$4)); $$->addNextNull(GRAMMARP->newVarInit($5,$$,$6)); } ; @@ -898,13 +899,13 @@ parameter_declaration: // IEEE: parameter_declaration ; local_parameter_declarationFront: // IEEE: local_parameter_declaration w/o assignment - varLParamReset implicit_type { /*VARRESET-in-varLParam*/ VARDTYPE($2); } + varLParamReset implicit_typeE { /*VARRESET-in-varLParam*/ VARDTYPE($2); } | varLParamReset data_type { /*VARRESET-in-varLParam*/ VARDTYPE($2); } //UNSUP varLParamReset yTYPE { /*VARRESET-in-varLParam*/ VARDTYPE($2); } ; parameter_declarationFront: // IEEE: parameter_declaration w/o assignment - varGParamReset implicit_type { /*VARRESET-in-varGParam*/ VARDTYPE($2); } + varGParamReset implicit_typeE { /*VARRESET-in-varGParam*/ VARDTYPE($2); } | varGParamReset data_type { /*VARRESET-in-varGParam*/ VARDTYPE($2); } //UNSUP varGParamReset yTYPE { /*VARRESET-in-varGParam*/ VARDTYPE($2); } ; @@ -985,7 +986,7 @@ port_declaration: // ==IEEE: port_declaration list_of_variable_decl_assignments { $$ = $5; } | port_directionReset port_declNetE yVAR data_type { VARDTYPE($4); } list_of_variable_decl_assignments { $$ = $6; } - | port_directionReset port_declNetE yVAR implicit_type { VARDTYPE($4); } + | port_directionReset port_declNetE yVAR implicit_typeE { VARDTYPE($4); } list_of_variable_decl_assignments { $$ = $6; } | port_directionReset port_declNetE signingE rangeList { VARDTYPE(GRAMMARP->addRange(new AstBasicDType($4->fileline(), LOGIC_IMPLICIT, $3),$4)); } list_of_variable_decl_assignments { $$ = $6; } @@ -999,10 +1000,10 @@ tf_port_declaration: // ==IEEE: tf_port_declaration // // Used inside function; followed by ';' // // SIMILAR to port_declaration // - port_directionReset data_type { VARDTYPE($2); } list_of_tf_variable_identifiers ';' { $$ = $4; } - | port_directionReset implicit_type { VARDTYPE($2); } list_of_tf_variable_identifiers ';' { $$ = $4; } - | port_directionReset yVAR data_type { VARDTYPE($3); } list_of_tf_variable_identifiers ';' { $$ = $5; } - | port_directionReset yVAR implicit_type { VARDTYPE($3); } list_of_tf_variable_identifiers ';' { $$ = $5; } + port_directionReset data_type { VARDTYPE($2); } list_of_tf_variable_identifiers ';' { $$ = $4; } + | port_directionReset implicit_typeE { VARDTYPE($2); } list_of_tf_variable_identifiers ';' { $$ = $4; } + | port_directionReset yVAR data_type { VARDTYPE($3); } list_of_tf_variable_identifiers ';' { $$ = $5; } + | port_directionReset yVAR implicit_typeE { VARDTYPE($3); } list_of_tf_variable_identifiers ';' { $$ = $5; } ; integer_atom_type: // ==IEEE: integer_atom_type @@ -1173,7 +1174,7 @@ constE: // IEEE: part of data_declaration //UNSUP yCONST__ETC { UNSUP } ; -implicit_type: // IEEE: part of *data_type_or_implicit +implicit_typeE: // IEEE: part of *data_type_or_implicit // // Also expanded in data_declaration /* empty */ { $$ = NULL; } | signingE rangeList { $$ = GRAMMARP->addRange(new AstBasicDType($2->fileline(), LOGIC_IMPLICIT, $1),$2); } @@ -1187,10 +1188,10 @@ type_declaration: // ==IEEE: type_declaration // // Combines into above "data_type id" rule // // Verilator: Not important what it is in the AST, just need to make sure the yaID__aTYPE gets returned | yTYPEDEF id ';' { $$ = NULL; $$ = new AstTypedefFwd($1, *$2); SYMP->reinsert($$); } - //UNSUP yTYPEDEF yENUM idAny ';' { $$ = NULL; $$ = new AstTypedefFwd($1, *$2); SYMP->reinsert($$); } - //UNSUP yTYPEDEF ySTRUCT idAny ';' { $$ = NULL; $$ = new AstTypedefFwd($1, *$2); SYMP->reinsert($$); } - //UNSUP yTYPEDEF yUNION idAny ';' { $$ = NULL; $$ = new AstTypedefFwd($1, *$2); SYMP->reinsert($$); } - //UNSUP yTYPEDEF yCLASS idAny ';' { $$ = NULL; $$ = new AstTypedefFwd($1, *$2); SYMP->reinsert($$); } + //UNSUP yTYPEDEF yENUM idAny ';' { $$ = NULL; $$ = new AstTypedefFwd($1, *$3); SYMP->reinsert($$); } + //UNSUP yTYPEDEF ySTRUCT idAny ';' { $$ = NULL; $$ = new AstTypedefFwd($1, *$3); SYMP->reinsert($$); } + //UNSUP yTYPEDEF yUNION idAny ';' { $$ = NULL; $$ = new AstTypedefFwd($1, *$3); SYMP->reinsert($$); } + //UNSUP yTYPEDEF yCLASS idAny ';' { $$ = NULL; $$ = new AstTypedefFwd($1, *$3); SYMP->reinsert($$); } ; //************************************************ @@ -2128,14 +2129,14 @@ tf_port_itemFront: // IEEE: part of tf_port_item, which has the data type | signingE rangeList { VARDTYPE(GRAMMARP->addRange(new AstBasicDType($2->fileline(), LOGIC_IMPLICIT, $1), $2)); } | signing { VARDTYPE(new AstBasicDType($1, LOGIC_IMPLICIT, $1)); } | yVAR data_type { VARDTYPE($2); } - | yVAR implicit_type { VARDTYPE($2); } + | yVAR implicit_typeE { VARDTYPE($2); } // | tf_port_itemDir /*implicit*/ { VARDTYPE(NULL); /*default_nettype-see spec*/ } | tf_port_itemDir data_type { VARDTYPE($2); } | tf_port_itemDir signingE rangeList { VARDTYPE(GRAMMARP->addRange(new AstBasicDType($3->fileline(), LOGIC_IMPLICIT, $2),$3)); } | tf_port_itemDir signing { VARDTYPE(new AstBasicDType($2, LOGIC_IMPLICIT, $2)); } | tf_port_itemDir yVAR data_type { VARDTYPE($3); } - | tf_port_itemDir yVAR implicit_type { VARDTYPE($3); } + | tf_port_itemDir yVAR implicit_typeE { VARDTYPE($3); } ; tf_port_itemDir: // IEEE: part of tf_port_item, direction