132 operator T() {
return *ptr; }
191 static list<CObstack*> stackList;
193 static INT32 evalCount;
195 static map<CNode*,int> labelCache;
196 static int labelCacheEnabled;
211 int LabelBits(
int supressErrorMessages = FALSE );
213 void _EvalVector(
CVector& v );
214 double _EvalReal(
void );
215 void FixedWidth(
int v ) { fixedWidth = v; }
216 int FixedWidth() {
return fixedWidth; }
217 int ConditionalWiden();
220 CNode* GetNLeft(
void ) {
return (
CNode*)left; }
221 CNode* GetNRight(
void ) {
return (
CNode*)right; }
222 static void _LabelBits(
CNode* n,
void* arg );
239 stackList.push_front( stack );
248 MASSERT( evalCount == 0 );
249 stackList.push_front( stack );
256 if( stack == &evalHeap ) {
258 if( evalCount == 0 ) {
259 evalHeap.
Free( NULL );
262 if( stackList.empty() ) {
265 stack = *stackList.begin();
266 stackList.pop_front();
280 labelCacheEnabled = 1;
288 labelCacheEnabled = 0;
289 labelCache.erase( labelCache.begin(), labelCache.end() );
398 int IsNonX(
int integerIsNonX = 0,
char* exclude = NULL );
452 void Dump( FILE* f );
490 int IsScalar(
void ) { LabelBits(TRUE);
return width==1; }
495 int IsVector(
void ) { LabelBits(TRUE);
return width>1; }
500 int IsReal(
void ) { LabelBits(TRUE);
return type==
eR; }
592 return CNode_sp<T>(&GetNLeft()->GetNLeft()->right);
608 return CNode_sp<T>(&GetNLeft()->GetNLeft()->right);
610 return CNode_sp<T>(&GetNLeft()->GetNRight()->left);
612 return CNode_sp<T>(&GetNLeft()->GetNRight()->right);
626 return CNode_sp<T>(&GetNLeft()->GetNLeft()->right);
628 return CNode_sp<T>(&GetNLeft()->GetNRight()->left);
630 return CNode_sp<T>(&GetNLeft()->GetNRight()->right);
632 return CNode_sp<T>(&GetNRight()->GetNLeft()->left);
634 return CNode_sp<T>(&GetNRight()->GetNLeft()->right);
646 return CNode_sp<T>(&GetNLeft()->GetNLeft()->right);
648 return CNode_sp<T>(&GetNLeft()->GetNRight()->left);
650 return CNode_sp<T>(&GetNLeft()->GetNRight()->right);
652 return CNode_sp<T>(&GetNRight()->GetNLeft()->left);
654 return CNode_sp<T>(&GetNRight()->GetNLeft()->right);
656 return CNode_sp<T>(&GetNRight()->GetNRight()->left);
658 return CNode_sp<T>(&GetNRight()->GetNRight()->right);
673 inline void Add(
double* r,
double* a,
double* b )
678 inline void Sub(
double* r,
double* a,
double* b )
683 inline void Mul(
double* r,
double* a,
double* b )
688 inline void Div(
double* r,
double* a,
double* b )
693 inline void Neg(
double* r,
double* a )
698 inline void Plus(
double* r,
double* a )
703 inline void Pow(
double* r,
double* a,
double* b )
712 #define ILLEGAL_OP2(op) \
713 inline void op( double*, double*, double* )\
714 { fatal( NULL, #op " is illegal for reals" ); }
716 #define ILLEGAL_OP1(op) \
717 inline void op( double*, double* )\
718 { fatal( NULL, #op " is illegal for reals" ); }
739 #define DEFINE_CONSTRUCTOR
741 #undef DEFINE_CONSTRUCTOR
772 int len = strlen( s );
826 }
else if( n2 == NULL ) {
872 }
else if( n2 == NULL ) {
875 return cLIST( n1, n2 );
889 return cHOOK(cond,n1,n2);
910 int argNumber, vector<T>& v)
915 switch( n->
GetOp() ) {
917 ArgList2Vector<T>(n->
Arg<
CNode*>(0),op,argNumber,v);
918 ArgList2Vector<T>(n->
Arg<
CNode*>(1),op,argNumber,v);
921 if( n->
GetOp() == op ) {
922 v.push_back(n->
Arg<T>(argNumber));
941 switch( n->
GetOp() ) {
947 if( excludeOps.find(n->
GetOp()) == excludeOps.end() ) {
967 switch( n->
GetOp() ) {
973 if( excludeOps.find(n->
GetOp()) == excludeOps.end() ) {
988 CNode* result = NULL;
989 vector<CNode*>::const_reverse_iterator ptr;
990 for( ptr = v.rbegin(); ptr != v.rend(); ++ptr ) {
992 result =
cELIST(*ptr, result);
1008 CNode* result = NULL;
1009 list<CNode*>::reverse_iterator ptr;
1010 for( ptr = v.rbegin(); ptr != v.rend(); ++ptr ) {
1012 result =
cELIST(*ptr, result);
1034 switch( n->
GetOp() ) {
1041 if( n->
GetOp() == op ) {
1061 switch( n->
GetOp() ) {
1084 inline double s2d(
char* s ) {
1100 snprintf( buffer,
sizeof(buffer),
"%g", d );
1101 char* s = (
char*)heap->
Alloc(strlen(buffer)+1);
1102 strcpy( s, buffer );
1118 CNode* parent = NULL;
1167 *count = count0+count1;
1168 *depth = depth0 > depth1 ? depth0 : depth1;
1182 }
else if( !pr1.
tail ) {
1208 switch( ref->
GetOp() ) {
1211 vector<CNode*> indexes;
1213 set<NodeOp_t>(), indexes );
1214 vector<CNode*>::iterator ptr;
1215 for( ptr = indexes.begin(); ptr != indexes.end(); ++ptr ) {
1222 INT32 value = (*ptr)->EvalINT32();
1223 ostringstream subscript;
1224 subscript <<
'[' << value <<
']';
1225 buffer += subscript.str();
1245 buffer = ref->
Arg<
CDecl*>(0)->GetName();
1259 CNode* result = first;
1261 va_start( ap, first );
1268 result =
cMAX( result, arg );
1277 CNode* result = first;
1279 va_start( ap, first );
1285 result =
cADD( result, arg );
1293 CNode* result = first;
1295 va_start( ap, first );
1301 result =
cMUL( result, arg );
1310 va_start( ap, first );
1315 MASSERT( va_arg(ap,
CNode*) == NULL );
1327 return a1 < a2 ? a2 : a1;
1330 inline int cMAX(
int a1,
int a2,
int a3 )
1348 return (diff < 0 ? -diff : diff)+1;
Declaration object for nets.
Definition: cnet.h:46
CNode * cSUB(CNode *a0, CNode *a1, Coord_t *loc=NULL)
Node construction shortcut for SUB subtract.
Definition: cnode_def.h:2879
int HasAttribute(const char *name, CNode *n=NULL, int init=1)
Determine if node has the given attribute.
Definition: cnode.cc:412
static void DisableAndClearLabelCache()
Disable caching of label info (width and type) and clear all accumulated data.
Definition: cnode.h:286
real constant
Definition: cnode_def.h:654
vector subrange with ascending index select
Definition: cnode_def.h:1152
CNode * Simplify(INT32 newWidth, NodeType_t newType)
Create simplified expression tree with given width and type.
Definition: cnode.cc:337
int cMUL(int a1, int a2)
Definition: cnode.h:1340
static void UseEvalStack(void)
Use evaluation stack.
Definition: cnode.h:238
int Equivalent(CNode *a, CNode *b)
Definition: cnode_def.h:12084
Smart pointer for CNode class Creates safe references to CNode arguments Supports assignment...
Definition: cnode.h:125
CNode * operator->()
Definition: cnode.h:148
Declaration object for genvars.
Definition: cgenvar.h:46
CNode * cELIST(CNode *a0, CNode *a1, Coord_t *loc=NULL)
Node construction shortcut for ELIST expression list.
Definition: cnode_def.h:2788
CNode * RebalanceRight(CNode *n)
Definition: cnode.h:1110
Gate declaration object.
Definition: cgate.h:42
T * Ptr()
Definition: cnode.h:131
int IsScalar(void)
Determine if expression is a 1 bit signed or unsigned value.
Definition: cnode.h:490
CNode * cREAL(double number)
Short cut for creating RCONSTANT node with a given double value.
Definition: cnode.h:808
static void EnableLabelCache()
Enable cache of labeled nodes to be tracked.
Definition: cnode.h:278
int IsEvaluateable()
Checks to see if expression tree can be evaluated.
Definition: cnode_def.h:12632
int ListCount(CNode *n, NodeOp_t op)
Walks a list/elist of nodes and counts the number of node with the specified operation.
Definition: cnode.h:1028
void Add(double *r, double *a, double *b)
Definition: cnode.h:673
int cADD(int a1, int a2)
Definition: cnode.h:1335
Declaration object for specify blocks.
Definition: cspecify.h:47
CNode * cMAX_N(CNode *first,...)
Definition: cnode.h:1257
void SetPreferredBase(int base)
Set preferred base for printing value.
Definition: cvector.h:132
char * d2s(double d, CObstack *stack)
Convert double to char string allocating storage on given heap.
Definition: cnode.h:1096
CNode * second
Definition: cnode.h:163
void Neg(double *r, double *a)
Definition: cnode.h:693
list of nodes
Definition: cnode_def.h:1119
vector constant
Definition: cnode_def.h:644
CNode * cSTRING(const char *s)
Short cut for creating VCONSTANT node with a given string value.
Definition: cnode.h:770
Coord_t * GetCoord()
Get node's file coordinates.
Definition: cnode.h:303
CNode * List2EList(list< CNode * > &v)
Converts a list of CNode* into a linked ELIST of the elements.
Definition: cnode.h:1006
CNode * cMUL_N(CNode *first,...)
Definition: cnode.h:1291
static CObstack * CurrentHeap()
Gets pointer to current heap allocator.
Definition: cnode.h:228
int IsConstant()
Checks expression tree to see if it is constant.
Definition: cnode_def.h:8057
CNode * GetWidthExp(void)
Create expression representing width of expression.
Definition: cnode_def.h:8695
CBlock CScope
Definition: cnode.h:65
CNode * cNEG(CNode *a0, Coord_t *loc=NULL)
Node construction shortcut for NEG negation.
Definition: cnode_def.h:4390
Strength_t s1
Definition: cnode.h:110
void ArgList2Vector(CNode *n, NodeOp_t op, int argNumber, vector< T > &v)
Walks a list of nodes and collects the specified augments of a given node type.
Definition: cnode.h:909
void MeasureDepth(CNode *n, int *count, int *depth)
Definition: cnode.h:1148
void PostVisit1(void(*callback)(CNode *, void *), void *data)
Walk tree invoking callback on each node after children have been visited.
Definition: cnode_def.h:10480
long INT32
Short cut for signed 32 bit integer.
Definition: glue.h:38
int IsReal(void)
Determine if expression is real.
Definition: cnode.h:500
int IsVolatile(void)
Checks to see if expression tree is volatile.
Definition: cnode_def.h:8219
int Precedence()
Get the precedence of the operator represented by the node.
Definition: cnode_def.h:7889
CNode_sp< T > Arg(int index)
Get a node's operand.
Definition: cnode.h:540
Edge_t
Edge values.
Definition: cnode.h:72
reference to port
Definition: cnode_def.h:996
void * Alloc(INT32 size)
Allocate block of storage with given size.
reference to a forward declared variable
Definition: cnode_def.h:1006
static CVector * AllocFromHeap(CObstack *aHeap, int width)
Create vector allocating all storage from given heap.
Definition: cvector.h:85
int operator!=(CNode_pr p)
Definition: cnode.h:153
int operator!=(CNode_sp< T > p)
Definition: cnode.h:136
void List2VectorExclude(CNode *n, const set< NodeOp_t > &excludeOps, vector< CNode * > &v)
Walks an expression list of nodes and collects the subtrees that don't match the given node types...
Definition: cnode.h:962
CNode * operator=(CNode *n)
Definition: cnode.h:147
INT32 EvalINT32()
Evaluates expression tree and returns value as a 32 bit integer.
Definition: cnode.cc:308
CNode * cHOOK(CNode *a0, CNode *a1, CNode *a2, Coord_t *loc=NULL)
Node construction shortcut for HOOK condition expression operator.
Definition: cnode_def.h:4983
T operator=(T n)
Definition: cnode.h:129
static void ResetBuildStack(void)
Restore previous heap.
Definition: cnode.h:255
reference to a genvar
Definition: cnode_def.h:1016
CNode * third
Definition: cnode.h:164
int ArgCount(void)
Get the number of operands for the node.
Definition: cnode_def.h:7567
Helper class for building tail recursive binary CNode trees Used by parser.
Definition: cnode.h:143
int Based()
Get based attribute.
Definition: cvector.h:155
Pair of strengths.
Definition: cnode.h:108
Structure to hold file coordinates.
Definition: cdecl.h:47
Holder for character strings.
Definition: csymbol.h:44
Declaration object for module/function/task ports.
Definition: cport.h:44
CNode * first
Definition: cnode.h:162
Forward reference declaration.
Definition: cfref.h:51
Bulk object allocation object.
Definition: cobstack.h:46
CNode * cABSDIFFPLUS1_N(CNode *first,...)
Definition: cnode.h:1307
reference to net
Definition: cnode_def.h:966
Strength_t
Strength values.
Definition: cnode.h:93
Primary data structure representing parse tree nodes.
Definition: cnode.h:188
int operator==(CNode_sp< T > p)
Definition: cnode.h:135
NodeOp_t
Parse tree opcodes.
Definition: cnode_def.h:625
CNode * cLINK(CNode *n1, CNode *n2)
Short cut for linking together to nodes with a LIST operator.
Definition: cnode.h:868
CNode * cELINK(CNode *n1, CNode *n2)
Link together two nodes with an ELIST operator.
Definition: cnode.h:822
int IsNonX(int integerIsNonX=0, char *exclude=NULL)
Checks expression tree to see if expression can result in an X or Z.
Definition: cnode_def.h:9293
Declaration object for module and gate instances.
Definition: cinstance.h:45
expression list
Definition: cnode_def.h:695
void EvalVector(CVector &v)
Evaluates expression tree evaluated in unconstrainted context.
Definition: cnode.cc:360
CNode * head
Definition: cnode.h:144
void Pow(double *r, double *a, double *b)
Definition: cnode.h:703
CNode * Vector2EList(const vector< CNode * > &v)
Converts a vector array of CNode* into a linked ELIST of the elements.
Definition: cnode.h:986
CNode(Coord_t *aLoc, NodeOp_t aOp)
Constructor for parse node.
Definition: cnode.cc:240
member reference (structure, class or external
Definition: cnode_def.h:2223
CAttr * GetAttribute(const char *name, CNode *n=NULL, int init=1)
Get attribute attached to node with the given attribute.
Definition: cnode.cc:445
void SetAttributes(CNode *attr)
Attach attributes to operation.
Definition: cnode.h:510
CNode_sp(void **np)
Pointer to untyped argument.
Definition: cnode.h:128
static void SetBuildStack(CObstack *aStack)
Set heap to a specific heap.
Definition: cnode.h:247
int operator!=(T v)
Definition: cnode.h:134
CNode * cVECTOR(CVector &vec)
Short cut for creating VCONSTANT node with a given vector value.
Definition: cnode.h:753
CNode * PostSubVisit1(CNode *(*callback)(CNode *, void *), void *data)
Walk tree invoking callback on each node after children have been visited.
Definition: cnode_def.h:11013
void Div(double *r, double *a, double *b)
Definition: cnode.h:688
Definitions for parse tree nodes.
void SetOp(NodeOp_t aOp)
Set node's operation type.
Definition: cnode.h:320
Base class for describing declaration objects.
Definition: cdecl.h:164
CNode * tail
Definition: cnode.h:145
int IsVector(void)
Determine if expression is a multi-bit signed or unsigned value.
Definition: cnode.h:495
void Sub(double *r, double *a, double *b)
Definition: cnode.h:678
int operator==(CNode_pr p)
Definition: cnode.h:152
int Sized()
Get sized attribute.
Definition: cvector.h:143
Declaration object for variables.
Definition: cvar.h:50
external reference
Definition: cnode_def.h:2003
Declaration object for parameters.
Definition: cparam.h:46
Declaration object for holding lists of verilog attributes and their corresponding expressions...
Definition: cattr.h:50
CNode * cINT32(INT32 i)
Short cut for creating VCONSTANT node with a given integer value.
Definition: cnode.h:789
int IsWidthEvaluateable(void)
Evaluates if expression width can be evaluated.
Definition: cnode_def.h:9135
Bit vector class for implementing 4 state verilog signed and unsigned arithmetic. ...
Definition: cvector.h:58
CNode * cGE(CNode *a0, CNode *a1, Coord_t *loc=NULL)
Node construction shortcut for GE greater than or equal.
Definition: cnode_def.h:4511
void PreVisit1(int(*callback)(CNode *, void *), void *data)
Walk tree invoking callback on each node before children have been visited.
Definition: cnode_def.h:9960
INT32 GetWidth(void)
Evaluate width of expression.
Definition: cnode.h:485
Base class for vrq objects.
Definition: cobject.h:41
CNode * cLT(CNode *a0, CNode *a1, Coord_t *loc=NULL)
Node construction shortcut for LT less than.
Definition: cnode_def.h:4544
void Mul(double *r, double *a, double *b)
Definition: cnode.h:683
int IsWidthConstant(void)
Evaluates if expression width is constant.
Definition: cnode_def.h:8381
void EList2VectorExclude(CNode *n, const set< NodeOp_t > &excludeOps, vector< CNode * > &v)
Walks an expression elist of nodes and collects the subtrees that don't match the given node types...
Definition: cnode.h:936
NodeType_t GetNodeType(void)
Get node expression type.
Definition: cnode.h:531
int GetPreferredBase()
Get preferred base for printing value.
Definition: cvector.h:137
void Plus(double *r, double *a)
Definition: cnode.h:698
int operator!=(CNode *v)
Definition: cnode.h:151
INT32 GetWidth(void)
Get vector bit width.
int Signed() const
Get signed attribute.
Definition: cvector.h:178
vector subrange
Definition: cnode_def.h:1141
real - have width 0
Definition: cdatatype.h:101
Declaration object for functions and tasks.
Definition: cfunction.h:50
int operator==(CNode *v)
Definition: cnode.h:150
CNode * cLIST(CNode *a0, CNode *a1, Coord_t *loc=NULL)
Node construction shortcut for LIST list of nodes.
Definition: cnode_def.h:4044
unsigned Hash()
Calculate hash of tree.
Definition: cnode_def.h:11548
int LoadString(const char *string)
Load string value from string.
Declaration object for input/output/inout statements.
Definition: cportdir.h:45
CNode * cMAX(CNode *n1, CNode *n2)
Short cut for creating a expression tree that calculates the maximum of two expressions.
Definition: cnode.h:886
T operator->()
Definition: cnode.h:130
CNode * cADD_N(CNode *first,...)
Definition: cnode.h:1275
CNode * cABS(CNode *a)
Short cut for creating an subtree that calculates the absolute value of an expression.
Definition: cnode.h:839
Strength_t s0
Definition: cnode.h:109
NodeType_t
Expression node type.
Definition: cdatatype.h:99
friend CNode_pr cLINK(CNode_pr pr1, CNode *n2)
Definition: cnode.h:1178
const char * GetOpName()
Return node's operation type as a string.
Definition: cnode.h:313
void Free(void *object)
Free all storage including and after object.
CNode * GetAttributes()
Get attributes attached to operation.
Definition: cnode.h:505
const char * nodeOpName[]
Definition: cnode_def.h:2290
dimensioned reference (array/bit select)
Definition: cnode_def.h:956
NodeOp_t GetOp()
Return node's operation type.
Definition: cnode.h:308
int IsWidthVolatile(void)
Evaluates if expression width is volatile.
Definition: cnode_def.h:8537
void Dump(FILE *f)
Print a compact representation of the parse tree.
Definition: cnode_def.h:15233
Declaration class for block constructs.
Definition: cblock.h:52
int cABSDIFFPLUS1(int a1, int a2)
Definition: cnode.h:1345
DelayMode_t
Timing mode values.
Definition: cnode.h:84
vector subrange with descending index select
Definition: cnode_def.h:1163
Helper class for building tail recursive binary CNode trees Used by parser.
Definition: cnode.h:161
reference to parameter
Definition: cnode_def.h:986
double EvalReal(void)
Evaluates expression tree evaluated in a real context.
Definition: cnode.cc:391
CNode * cABSDIFF(CNode *a, CNode *b)
Short cut for creating an subtree that calculates the absolute difference between two expressions...
Definition: cnode.h:855
int operator==(T v)
Definition: cnode.h:133
string HierarchicalReference2String(CNode *ref)
Definition: cnode.h:1205
double s2d(char *s)
Convert char string to double.
Definition: cnode.h:1084
reference to variable
Definition: cnode_def.h:976
CNode * Clone(CObstack *heap=stack)
Replicate tree.
Definition: cnode_def.h:9464