Expressions
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.
Basic Terminology
Atomic Expressions
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
'x,
- 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.,
$display).
- 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
sizing computations.
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.
Non-Atomic Expressions
A non-atomic expression represents an operator being applied to some
arguments.
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
upon atts.
Valid Expressions
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.
Subtopics
- Vl-atts
- Representation of (* foo = 3, bar *) style attributes.
- Vl-constint
- Representation for constant integer literals with no X or Z bits.
- *vl-ops-table*
- Table binding valid operators to their vl-opinfo structures.
- Vl-weirdint
- Representation for constant integer literals with X or Z bits.
- Vl-expr
- Vl-id
- Representation for simple identifiers.
- Vl-hidpiece
- Represents one piece of a hierarchical identifier.
- Vl-time
- Representation of time amounts.
- Vl-maybe-exprtype
- Recognizer for an vl-exprtype-p or nil.
- Vl-op-p
- Recognizer for valid operators.
- Vl-maybe-expr
- Vl-expr->finaltype
- Get the finaltype from an expression.
- Vl-real
- Representation of real (floating point) literals.
- Vl-expr->finalwidth
- Get the finalwidth from an expression.
- Vl-tagname
- Represents a tagged union member name.
- Vl-sysfunname
- Represents a system function name.
- Vl-string
- Representation for string literals.
- Vl-op-arity
- Look up the arity of an operator.
- Vl-keyguts
- Representation of special, atomic SystemVerilog expressions,
distinguished by keywords such as null, this, super, $,
local, etc.
- Vl-exprtype-p
- Valid types for expressions.
- Vl-typename
- Represents a user-defined type name.
- Vl-funname
- Represents a (non-system) function name.
- Vl-basictype
- Atomic SystemVerilog types, like byte, int. These can be
used, e.g., in casting and streaming concatenation expressions.
- Vl-extint
- Representation for unbased, unsized integer literals, viz. '0,
'1, 'x, and 'z.
- Vl-atomlist-p
- (vl-atomlist-p x) recognizes lists where every element satisfies vl-atom-p.
- Vl-atomguts
- The main contents of a vl-atom-p.
- Vl-nbits-fix
- Vl-atom-p
- Vl-arity-fix
- Vl-arity-ok-p
- Vl-op-text
- Look up the text of an operator.
- Vl-exprlist
- A list of vl-expr-p objects.
- Vl-oplist
- A list of vl-op-p objects.
- Vl-exprlistlist
- A list of vl-exprlist-p objects.
- Vl-ops-table
- *vl-default-expr*