Representation of Verilog expressions.
One goal of our expression representation was for the recursive
structure of expressions to be as simple as possible. More specifically, I did
not want to have a different representation for a unary expression than for a
binary expression, etc. Instead, I just wanted each operator to take a list of
arguments, each of which were themselves valid subexpressions.
The atomic expressions are recognized by vl-atom-p. Each
atomic expression includes some guts, which refer to either an:
- vl-id-p: a simple, non-hierarchical identifier,
- vl-constint-p: an integer literal with no X or Z bits,
- vl-weirdint-p: an integer literal with some X or Z bits,
- vl-extint-p: an unbased, unsized integer literal like '0 or
- vl-real-p: a "real literal", i.e., a floating point number,
- vl-string-p: a string literal,
- vl-time-p: time literals like 3ns,
- vl-keyguts-p: special atomic expressions like null, this,
super, $, local, etc.
- vl-hidpiece-p: one piece of a hierarchical identifier,
- vl-funname-p: the name of an ordinary function, or
- vl-sysfunname-p: the name of a system function (e.g.,
- vl-basictype-p: simple type names like byte, shortint,
time, logic, etc.
- vl-tagname-p: the name of a tagged union type member.
Some of these are probably not things you would ordinarily think of as
atomic expressions. However, accepting them as atomic expressions lets us
achieve the straightforward recursive structure we desire.
In addition to their guts, each vl-atom-p includes a
Typically, when we have just parsed the modules, these fields are left
nil: their values are only filled in during our expression typing and
Finally, an atom has atts, which is a vl-atts-p. These
attributes are generally nil upon parsing since the Verilog or
SystemVerilog grammars don't really provide anywhere for (* foo = bar, baz
*) style attributes to be attached to atomic expressions. However, we
occasionally find it convenient to put our own attributes on atoms, e.g., it
allows us to record that a particular atom came from a parameter.
A non-atomic expression represents an operator being applied to some
Like atomic expressions, each vl-nonatom-p includes finalwidth and
finaltype fields, which are nil upon parsing and may later be filled
in by our expression typing and sizing computations.
Additionally, each non-atomic expression includes:
- op, the operation being applied. For structural validity, op
must be one of the known operators found in *vl-ops-table*.
- args, the arguments the operation is being applied to. No structural
constraints are imposed upon args.
- atts, which represent any attributes written in the (* foo = bar,
baz *) style that Verilog-2005 permits. No structural constraints are placed
The valid expressions are recognized by vl-expr-p, which extends our
basic structural checks recursively over the expression, and also ensures that
each operator has the proper arity.
- Representation of (* foo = 3, bar *) style attributes.
- Representation for constant integer literals with no X or Z bits.
- Table binding valid operators to their vl-opinfo structures.
- Representation for constant integer literals with X or Z bits.
- Representation for simple identifiers.
- Represents one piece of a hierarchical identifier.
- Representation of time amounts.
- Recognizer for an vl-exprtype-p or nil.
- Recognizer for valid operators.
- Get the finaltype from an expression.
- Representation of real (floating point) literals.
- Get the finalwidth from an expression.
- Represents a tagged union member name.
- Represents a system function name.
- Representation for string literals.
- Look up the arity of an operator.
- Representation of special, atomic SystemVerilog expressions,
distinguished by keywords such as null, this, super, $,
- Valid types for expressions.
- Represents a user-defined type name.
- Represents a (non-system) function name.
- Atomic SystemVerilog types, like byte, int. These can be
used, e.g., in casting and streaming concatenation expressions.
- Representation for unbased, unsized integer literals, viz. '0,
'1, 'x, and 'z.
- (vl-atomlist-p x) recognizes lists where every element satisfies vl-atom-p.
- The main contents of a vl-atom-p.
- Look up the text of an operator.
- A list of vl-expr-p objects.
- A list of vl-op-p objects.
- A list of vl-exprlist-p objects.