• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
      • Gl
      • Esim
      • Vl2014
      • Sv
      • Fgl
      • Vwsim
      • Vl
        • Syntax
          • Vl-module
          • Vl-vardecl
          • Vl-fundecl
          • Vl-interface
          • Vl-design
          • Vl-assign
          • Vl-modinst
          • Vl-gateinst
          • Vl-taskdecl
          • Vl-portdecl
          • Vl-commentmap
          • Vl-dpiimport
          • Vl-ansi-portdecl
          • Vl-package
          • Vl-paramdecl
          • Vl-dpiexport
          • Vl-class
          • Vl-sort-blockitems-aux
          • Vl-plainarglist->exprs
          • Vl-taskdecllist->names
          • Expressions-and-datatypes
          • Vl-fundecllist->names
          • Vl-udp
          • Vl-port
          • Vl-genelement
          • Vl-clkdecl
          • Vl-parse-temps
          • Vl-bind
          • Vl-namedarg
          • Vl-exprdist
          • Vl-clkassign
          • Vl-range
          • Vl-propport
          • Vl-typedef
          • Vl-gatedelay
          • Vl-dimension
          • Vl-sequence
          • Vl-clkskew
          • Vl-program
          • Vl-gatestrength
          • Vl-property
          • Vl-config
          • Vl-always
          • Vl-import
          • Vl-repeateventcontrol
          • Vl-timeliteral
          • Vl-initial
          • Vl-eventcontrol
          • Vl-final
          • Vl-udpsymbol-p
          • Vl-maybe-clkskew
          • Vl-function-specialization
          • Vl-alias
          • Vl-maybe-nettypename
          • Vl-maybe-gatedelay
          • Vl-letdecl
          • Vl-direction-p
          • Vl-modelement
          • Vl-maybe-timeprecisiondecl
          • Vl-maybe-scopeid
          • Vl-maybe-gatestrength
          • Vl-maybe-direction
          • Vl-maybe-delayoreventcontrol
          • Vl-gclkdecl
          • Vl-fwdtypedef
          • Vl-maybe-udpsymbol-p
          • Vl-maybe-timeunitdecl
          • Vl-maybe-timeliteral
          • Vl-maybe-parse-temps
          • Vl-maybe-cstrength
          • Vl-arguments
          • Vl-maybe-module
          • Vl-maybe-design
          • Vl-covergroup
          • Vl-udpline
          • Vl-timeunitdecl
          • Vl-genvar
          • Vl-defaultdisable
          • Vl-context1
          • Vl-timeprecisiondecl
          • Vl-sort-blockitems
          • Vl-elabtask
          • Vl-udpedge
          • Vl-delaycontrol
          • Vl-context
          • Vl-ctxelement
          • Vl-ctxelement->loc
          • Vl-modelement->loc
          • Statements
            • Vl-stmt
              • Vl-assignstmt
              • Vl-blockstmt
              • Vl-stmt-p
              • Vl-casestmt
              • Vl-forstmt
              • Vl-foreachstmt
                • Make-vl-foreachstmt
                • Vl-foreachstmt->loopvars
                • Vl-foreachstmt->vardecls
                • Vl-foreachstmt->body
                • Vl-foreachstmt->atts
                • Vl-foreachstmt->array
                • Change-vl-foreachstmt
              • Vl-callstmt
              • Vl-stmt-case
              • Vl-waitstmt
              • Vl-repeatstmt
              • Vl-whilestmt
              • Vl-assertstmt
              • Vl-ifstmt
              • Vl-eventtriggerstmt
              • Vl-timingstmt
              • Vl-dostmt
              • Vl-deassignstmt
              • Vl-cassertstmt
              • Vl-nullstmt
              • Vl-stmt-kind
              • Vl-returnstmt
              • Vl-foreverstmt
              • Vl-disablestmt
              • Vl-stmt-equiv
              • Vl-continuestmt
              • Vl-breakstmt
              • Vl-stmt-fix
              • Vl-stmt-count
            • Vl-cassertion
            • Vl-assertion
            • Vl-stmtlist
            • Vl-caselist
          • Vl-blockitem
          • Vl-vardecllist
          • Vl-interface->ifports
          • Vl-syntaxversion
          • Vl-nettypename-p
          • Vl-module->ifports
          • Vl-lifetime-p
          • Vl-paramdecllist
          • Vl-modelementlist->genelements
          • Vl-importlist
          • Vl-typedeflist
          • Vl-gatetype-p
          • Vl-cstrength-p
          • Vl-port->name
          • Vl-genelement->loc
          • Vl-delayoreventcontrol
          • Vl-udpentry-p
          • Vl-portdecllist
          • Vl-elabtask->loc
          • Property-expressions
          • Vl-taskdecllist
          • Vl-port->loc
          • Vl-fundecllist
          • Vl-sequencelist
          • Vl-propertylist
          • Vl-portlist
          • Vl-dpiimportlist
          • Vl-dpiexportlist
          • Vl-classlist
          • Vl-arguments->args
          • Vl-alwaystype-p
          • Vl-modinstlist
          • Vl-importpart-p
          • Vl-importpart-fix
          • Vl-bindlist
          • Vl-initiallist
          • Vl-genvarlist
          • Vl-gclkdecllist
          • Vl-function-specialization-map
          • Vl-finallist
          • Vl-elabtasklist
          • Vl-defaultdisablelist
          • Vl-clkdecllist
          • Vl-cassertionlist
          • Vl-blockstmt-p
          • Vl-assignlist
          • Vl-assertionlist
          • Vl-alwayslist
          • Vl-aliaslist
          • Vl-udptable
          • Vl-udplist
          • Vl-udpentrylist
          • Vl-propportlist
          • Vl-programlist
          • Vl-packagelist
          • Vl-namedarglist
          • Vl-modulelist
          • Vl-modportlist
          • Vl-modport-portlist
          • Vl-letdecllist
          • Vl-interfacelist
          • Vl-gateinstlist
          • Vl-fwdtypedeflist
          • Vl-covergrouplist
          • Vl-configlist
          • Vl-clkassignlist
          • Vl-blockitemlist
          • Vl-ansi-portdecllist
          • Vl-regularportlist
          • Vl-paramdecllist-list
          • Vl-modelementlist
          • Vl-interfaceportlist
          • Vl-casekey-p
          • Sv::maybe-4veclist
        • Loader
        • Warnings
        • Getting-started
        • Utilities
        • Printer
        • Kit
        • Mlib
        • Transforms
      • X86isa
      • Svl
      • Rtl
    • Software-verification
    • Math
    • Testing-utilities
  • Vl-stmt

Vl-foreachstmt

Representation of foreach statements.

This is a product type, introduced by deftagsum in support of vl-stmt.

Fields
array — vl-scopeexpr
loopvars — vl-maybe-string-list
vardecls — vl-vardecllist
body — vl-stmt
atts — vl-atts

General form

foreach( <array> [ <var1>, ..., <varN> ] ) statement

See SystemVerilog-2012 section 12.7.3. The <array> should be a (possibly hierarchical) reference to an array variable, which we just represent with an expression.

The variable list allows us to introduce name variables corresponding to certain dimensions of the array. It should not mention more variables than the dimensions of the array. Variable names may also be omitted to indicate that we don't want to iterate through that particular dimension of the array. We represent these with a vl-maybe-exprlist so that you can tell when a variable has been omitted.

We infer a vl-vardecl from each loop variable. These will be integer variables. This arguably contradicts the standard, which suggests (12.7.3) that each loop variable is ``implicitly declared to be consistent with the type of array index.'' In other words, the standard seems to suggest that code like:

logic [3:0][7:0][15:0] arr;
foreach (arr [i,j,k]) begin
  $display("Size of i is %d", $bits(i));
  $display("Size of j is %d", $bits(j));
  $display("Size of k is %d", $bits(k));
end

should report sizes such as 2, 3, and 4. But commercial tools seem to report a size of 32 bits for all of these variables, so we think that in practice these are interpreted as integers.

Subtopics

Make-vl-foreachstmt
Basic constructor macro for vl-foreachstmt structures.
Vl-foreachstmt->loopvars
Get the loopvars field from a vl-foreachstmt.
Vl-foreachstmt->vardecls
Get the vardecls field from a vl-foreachstmt.
Vl-foreachstmt->body
Get the body field from a vl-foreachstmt.
Vl-foreachstmt->atts
Get the atts field from a vl-foreachstmt.
Vl-foreachstmt->array
Get the array field from a vl-foreachstmt.
Change-vl-foreachstmt
Modifying constructor for vl-foreachstmt structures.