Increment-elim
Split increment, decrement, and assignment operators out of
expressions and into separate statements.
Introduction
SystemVerilog-2012 adds C-style increment, decrement, and intra-expression
assignment operators. Per Section 11.4.1 and 11.4.2, these expressions are to
behave like blocking assignments.
In this transform, our basic goal is to eliminate these operators by
splitting them out into separate, explicit assignment statements. For
instance, we want to do rewrites like this:
begin begin
a = (i++) + 2; ---> a = i + 2;
end i = i + 1; // post increment
end
Something tricky is that these operators are permitted in all
expressions, but they only make sense in certain contexts like procedural
statements. For instance, it doesn't make any sense to use an increment
operator in a continuous assignment statement like
assign w1 = w2++;
because there's no notion of "before" or "after" this assignment and no
way to control when or how often a continuous assignment gets executed. If
this sort of thing were legal, at best it would do something like increment
w2 by some unknown amount. We find that tools such as NCVerilog and VCS
prohibit many such uses of ++ and --, and we do not want to permit
them either.
So our goal in this transform is actually to do two things. First, we want
to translate any valid uses of these operators into ordinary blocking
assignments. Second, we want to identify any invalid uses of these operators
and, if we find any, cause corresponding fatal warnings.
Even when these operators are used in valid contexts, SystemVerilog may not
guarantee what behavior is supposed to occur. For instance, if we're in some
procedural block and we run across a statement like
i = 5;
j = i++ + (i = i - 1);
then we don't know what value will get assigned to j because
SystemVerilog leaves undefined the relative ordering of the i++ and i =
i - 1 expressions. To reduce the possibility of different interpretations by
different tools, we try to recognize these sorts of situations and cause fatal
errors when there can be confusion.
Subtopics
- Vl-expr-increwrite-aux
- Core routine for eliminating increment, decrement, and assignment
expressions. Doesn't try to defend against ambiguities.
- Vl-maybe-exprlist-increwrite-aux
- Vl-maybe-expr-increwrite-aux
- Vl-exprlist-increwrite
- Main function for rewriting expression lists.
- Vl-expr-increwrite
- Main function for rewriting expressions.
- Vl-modelement-prohibit-incexprs
- Vl-interface-prohibit-incexprs-aux
- Vl-module-prohibit-incexprs-aux
- Vl-portdecl-or-blockitem-list-prohibit-incexprs
- Vl-maybe-exprlist-increwrite
- Vl-function-specialization-map-prohibit-incexprs
- Vl-rhs-increwrite
- Vl-maybe-expr-increwrite
- Vl-maybe-delayoreventcontrol-prohibit-incexprs
- Vl-delayoreventcontrol-prohibit-incexprs
- Vl-portdecl-or-blockitem-prohibit-incexprs
- Vl-function-specialization-prohibit-incexprs
- Vl-design-prohibit-incexprs-aux
- Vl-defaultdisablelist-prohibit-incexprs
- Vl-taskdecl-prohibit-incexprs-aux
- Vl-repeateventcontrol-prohibit-incexprs
- Vl-package-prohibit-incexprs-aux
- Vl-modport-portlist-prohibit-incexprs
- Vl-maybe-exprlist-prohibit-incexprs
- Vl-fundecl-prohibit-incexprs-aux
- Vl-cassertionlist-prohibit-incexprs
- Vl-vardecllist-prohibit-incexprs
- Vl-typedeflist-prohibit-incexprs
- Vl-taskdecllist-prohibit-incexprs
- Vl-sequencelist-prohibit-incexprs
- Vl-propportlist-prohibit-incexprs
- Vl-propertylist-prohibit-incexprs
- Vl-portdecllist-prohibit-incexprs
- Vl-plainarglist-prohibit-incexprs
- Vl-paramtype-prohibit-incexprs
- Vl-paramdecllist-prohibit-incexprs
- Vl-namedarglist-prohibit-incexprs
- Vl-modportlist-prohibit-incexprs
- Vl-modinstlist-prohibit-incexprs
- Vl-maybe-gatedelay-prohibit-incexprs
- Vl-maybe-exprdist-prohibit-incexprs
- Vl-initiallist-prohibit-incexprs
- Vl-gateinstlist-prohibit-incexprs
- Vl-fundecllist-prohibit-incexprs
- Vl-exprdistlist-prohibit-incexprs
- Vl-elabtasklist-prohibit-incexprs
- Vl-dpiimportlist-prohibit-incexprs
- Vl-defaultdisable-prohibit-incexprs
- Vl-clkdecllist-prohibit-incexprs
- Vl-clkassignlist-prohibit-incexprs
- Vl-blockitemlist-prohibit-incexprs
- Vl-blockitem-prohibit-incexprs
- Vl-assertionlist-prohibit-incexprs
- Vl-vardecl-prohibit-incexprs-aux
- Vl-portdecl-prohibit-incexprs-aux
- Vl-modport-port-prohibit-incexprs
- Vl-modinst-prohibit-incexprs-aux
- Vl-maybe-clkskew-prohibit-incexprs
- Vl-interfaceport-prohibit-incexprs
- Vl-incexpr->rhsexpr
- Get a normalized right-hand side expression for an increment,
decrement, or assignment expression.
- Vl-gateinst-prohibit-incexprs-aux
- Vl-finallist-prohibit-incexprs
- Vl-delaycontrol-prohibit-incexprs
- Vl-clkdecl-prohibit-incexprs
- Vl-classlist-prohibit-incexprs
- Vl-assignlist-prohibit-incexprs
- Vl-alwayslist-prohibit-incexprs
- Vl-aliaslist-prohibit-incexprs
- Vl-udplist-prohibit-incexprs
- Vl-typedef-prohibit-incexprs-aux
- Vl-taskdecl-prohibit-incexprs
- Vl-sequence-prohibit-incexprs
- Vl-repetition-prohibit-incexprs
- Vl-regularport-prohibit-incexprs
- Vl-propspec-prohibit-incexprs
- Vl-property-prohibit-incexprs
- Vl-portlist-prohibit-incexprs
- Vl-portdecl-prohibit-incexprs
- Vl-port-prohibit-incexprs-aux
- Vl-paramdecl-prohibit-incexprs-aux
- Vl-paramdecl-prohibit-incexprs
- Vl-maybe-rhs-prohibit-incexprs
- Vl-initial-prohibit-incexprs-aux
- Vl-gateinst-prohibit-incexprs
- Vl-gatedelay-prohibit-incexprs
- Vl-dpiimport-prohibit-incexprs
- Vl-distlist-prohibit-incexprs
- Vl-distitem-prohibit-incexprs
- Vl-clkassign-prohibit-incexprs
- Vl-class-prohibit-incexprs
- Vl-bindlist-prohibit-incexprs
- Vl-assign-prohibit-incexprs-aux
- Vl-arguments-prohibit-incexprs
- Vl-always-prohibit-incexprs-aux
- Vl-alias-prohibit-incexprs-aux
- Vl-vardecl-prohibit-incexprs
- Vl-typedef-prohibit-incexprs
- Vl-propport-prohibit-incexprs
- Vl-port-prohibit-incexprs
- Vl-plainarg-prohibit-incexprs
- Vl-namedarg-prohibit-incexprs
- Vl-modport-prohibit-incexprs
- Vl-modinst-prohibit-incexprs
- Vl-letdecl-prohibit-incexprs
- Vl-initial-prohibit-incexprs
- Vl-fundecl-prohibit-incexprs
- Vl-exprdist-prohibit-incexprs
- Vl-elabtask-prohibit-incexprs
- Vl-clkskew-prohibit-incexprs
- Vl-assign-prohibit-incexprs
- Vl-always-prohibit-incexprs
- Vl-alias-prohibit-incexprs
- Vl-udp-prohibit-incexprs
- Vl-rhs-prohibit-incexprs
- Vl-modelement-increwrite
- Vl-final-prohibit-incexprs
- Vl-expr-prohibit-incexprs
- Vl-bind-prohibit-incexprs
- Vl-function-specialization-map-increwrite
- Vl-expr-incexprs
- Gather all increment/decrement/assignment expressions from an expression.
- Vl-incexpr-post-p
- Recognizer for post increment/decrement operators.
- Vl-incexpr-p
- Recognizer for pre/post increment/decrement and assignment expressions.
- Vl-function-specialization-increwrite
- Vl-interface-increwrite
- Vl-module-increwrite
- Vl-packagelist-prohibit-incexprs
- Vl-interfacelist-prohibit-incexprs
- Vl-design-prohibit-incexprs-top-aux
- Vl-design-increwrite
- Vl-taskdecllist-increwrite
- Vl-packagelist-increwrite
- Vl-package-increwrite
- Vl-modulelist-prohibit-incexprs
- Vl-interfacelist-increwrite
- Vl-interface-prohibit-incexprs
- Vl-initiallist-increwrite
- Vl-incexpr->lhsexpr
- Get the lvalue part from an increment, decrement, or assignment expression.
- Vl-fundecllist-increwrite
- Vl-elabtasklist-increwrite
- Vl-design-prohibit-incexprs
- Vl-package-prohibit-incexprs
- Vl-modulelist-increwrite
- Vl-module-prohibit-incexprs
- Vl-fundecl-increwrite
- Vl-finallist-increwrite
- Vl-design-increment-elim
- Top-level increment-elim transform.
- Vl-classlist-increwrite
- Vl-alwayslist-increwrite
- Vl-taskdecl-increwrite
- Vl-initial-increwrite
- Vl-incexprlist-p
- (vl-incexprlist-p x) recognizes lists where every element satisfies vl-incexpr-p.
- Vl-elabtask-increwrite
- Vl-class-increwrite
- Vl-always-increwrite
- Vl-maybe-exprlist-has-incexprs-p
- Vl-final-increwrite
- Vl-maybe-expr-has-incexprs-p
- Vl-expr-has-incexprs-p
- Check whether there are any increment, decrement, or assignment
expressions within an expression.