• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
      • Gl
      • Esim
      • Vl2014
        • Warnings
        • Primitives
        • Use-set
        • Syntax
          • Vl-module
          • Vl-vardecl
          • Expressions
          • Vl-fundecl
            • Vl-fundecl-p
            • Vl-fundecl-fix
            • Make-vl-fundecl
            • Vl-fundecl-equiv
            • Change-vl-fundecl
            • Vl-fundecl->portdecls
            • Vl-fundecl->paramdecls
            • Vl-fundecl->blockitems
            • Vl-fundecl->vardecls
            • Vl-fundecl->rettype
            • Vl-fundecl->name
            • Vl-fundecl->lifetime
            • Vl-fundecl->imports
            • Vl-fundecl->loc
            • Vl-fundecl->body
            • Vl-fundecl->atts
          • Vl-assign
          • Vl-gateinst
          • Vl-modinst
          • Vl-commentmap
          • Vl-portdecl
          • Vl-taskdecl
          • Vl-design
          • Vl-interface
          • Vl-plainarglist->exprs
          • Vl-taskdecllist->names
          • Vl-fundecllist->names
          • Vl-package
          • Vl-port
          • Vl-udp
          • Vl-paramdecl
          • Vl-genelement
          • Vl-cycledelayrange
          • Vl-namedarg
          • Vl-sort-blockitems-aux
          • Vl-distitem
          • Vl-gatedelay
          • Vl-repetition
          • Vl-typedef
          • Vl-range
          • Vl-gatestrength
          • Vl-program
          • Vl-config
          • Vl-always
          • Vl-datatype-update-dims
          • Vl-import
          • Vl-enumbasetype
          • Vl-repeateventcontrol
          • Vl-paramargs
          • Vl-initial
          • Vl-eventcontrol
          • Vl-udpsymbol-p
          • Vl-maybe-range
          • Vl-maybe-nettypename
          • Vl-maybe-gatestrength
          • Vl-maybe-gatedelay
          • Vl-maybe-delayoreventcontrol
          • Vl-alias
          • Maybe-string-fix
          • Vl-maybe-packeddimension
          • Vl-fwdtypedef
          • Vl-evatom
          • Vl-packeddimension-p
          • Vl-maybe-udpsymbol
          • Vl-maybe-module
          • Vl-maybe-direction
          • Vl-maybe-datatype
          • Vl-maybe-cstrength
          • Vl-direction-p
          • Vl-arguments
          • Vl-maybe-design
          • Vl-udpline
          • Vl-exprdist
          • Vl-context1
          • Vl-genvar
          • Vl-enumitem
          • Vl-datatype-update-udims
          • Vl-datatype-update-pdims
          • Vl-modelement
          • Vl-udpedge
          • Vl-delaycontrol
          • Vl-context
          • Vl-sort-blockitems
          • Vl-distweighttype-p
          • Vl-ctxelement->loc
          • Vl-blockitem
          • Vl-vardecllist
          • Vl-module->ifports
          • Vl-modelement->loc
          • Vl-ctxelement
          • Vl-coretypename-p
          • Vl-packeddimensionlist
          • Vl-modelementlist->genelements
          • Vl-gatetype-p
          • Vl-paramdecllist
          • Vl-lifetime-p
          • Vl-datatype->udims
          • Vl-datatype->pdims
          • Vl-timeunit-p
          • Vl-repetitiontype-p
          • Vl-port->name
          • Vl-importlist
          • Vl-genelement->loc
          • Vl-delayoreventcontrol
          • Vl-cstrength-p
          • Statements
          • Vl-udpentry-p
          • Vl-packeddimension-fix
          • Vl-nettypename-p
          • Vl-portdecllist
          • Vl-port->loc
          • Vl-enumbasekind-fix
          • Vl-arguments->args
          • Vl-taskdecllist
          • Vl-portlist
          • Vl-importpart-p
          • Vl-importpart-fix
          • Vl-fundecllist
          • Vl-blockstmt-p
          • Vl-assignlist
          • Vl-alwaystype-p
          • Vl-typedeflist
          • Vl-syntaxversion-p
          • Vl-randomqualifier-p
          • Vl-modinstlist
          • Vl-gateinstlist
          • Vl-blockitemlist
          • Vl-udptable
          • Vl-udplist
          • Vl-udpentrylist
          • Vl-programlist
          • Vl-paramvaluelist
          • Vl-packagelist
          • Vl-namedparamvaluelist
          • Vl-namedarglist
          • Vl-modulelist
          • Vl-modportlist
          • Vl-modport-portlist
          • Vl-interfacelist
          • Vl-initiallist
          • Vl-genvarlist
          • Vl-fwdtypedeflist
          • Vl-evatomlist
          • Vl-enumitemlist
          • Vl-distlist
          • Vl-configlist
          • Vl-alwayslist
          • Vl-aliaslist
          • Vl-regularportlist
          • Vl-rangelist-list
          • Vl-rangelist
          • Vl-paramdecllist-list
          • Vl-modelementlist
          • Vl-maybe-range-list
          • Vl-interfaceportlist
          • Vl-argumentlist
          • Data-types
        • Getting-started
        • Utilities
        • Loader
        • Transforms
        • Lint
        • Mlib
        • Server
        • Kit
        • Printer
        • Esim-vl
        • Well-formedness
      • Sv
      • Fgl
      • Vwsim
      • Vl
      • X86isa
      • Svl
      • Rtl
    • Software-verification
    • Math
    • Testing-utilities
  • Syntax

Vl-fundecl

Representation of a single Verilog function.

This is a product type introduced by defprod.

Fields
name — stringp
Name of this function, e.g., lower_bits below.
lifetime — vl-lifetime-p
Indicates whether an explicit automatic or static lifetime was provided. An automatic function is supposed to be reentrant and have its local parameters dynamically allocated for each function call, with various consequences.
rettype — vl-datatype
Return type of the function, e.g., a function might return an ordinary unsigned or signed result of some width, or might return a real value, etc. For instance, the return type of lower_bits below is :vl-unsigned.
portdecls — vl-portdecllist
The arguments to the function, e.g., input [7:0] a below. Functions must have at least one input. We check this in our parser, but we don't syntactically enforce this requirement in the vl-fundecl-p structure. In Verilog-2005, functions may only have inputs (i.e., they can't have outputs or inouts), but our vl-portdecl-p structures have a direction, so in the context of a function declaration this direction should always be :vl-input. In SystemVerilog functions can have other kinds of ports, but functions with output/inout ports have restrictions and can't be used in expressions like normal functions.
imports — vl-importlist
Local package imports
vardecls — vl-vardecllist
Local variable declarations, including ones for the ports and return value (see below).
paramdecls — vl-paramdecllist
Local parameter declarations
blockitems — vl-blockitemlist
The declarations within the function, in parse order. We sort these out into the imports, vardecls, and paramdecls. It appears that these may even contain event declarations, parameter declarations, etc., which seems pretty absurd.
body — vl-stmt
The body of the function. We represent this as an ordinary statement, but it must follow certain rules as outlined in 10.4.4, e.g., it cannot have any time controls, cannot enable tasks, cannot have non-blocking assignments, etc.
atts — vl-atts
Any attributes associated with this function declaration.
loc — vl-location
Where this declaration was found in the source code.

Functions are described in Section 10.4 of the Verilog-2005 standard. An example of a function is:

function [3:0] lower_bits;
  input [7:0] a;
  reg [1:0] lowest_pair;
  reg [1:0] next_lowest_pair;
  begin
    lowest_pair = a[1:0];
    next_lowest_pair = a[3:2];
    lower_bits = {next_lowest_pair, lowest_pair};
  end
endfunction

Note that functions don't have any inout or output ports. Instead, you assign to a function's name to indicate its return value.

To simplify scoping issues, we put "hidden" variables declarations for the ports and return value of the function into its decls. These ports are marked with the VL_HIDDEN_DECL_FOR_TASKPORT attribute. The pretty printer and other code rely on this attribute to produce the correct output. These extra declarations are created automatically by the loader.

Subtopics

Vl-fundecl-p
Recognizer for vl-fundecl structures.
Vl-fundecl-fix
Fixing function for vl-fundecl structures.
Make-vl-fundecl
Basic constructor macro for vl-fundecl structures.
Vl-fundecl-equiv
Basic equivalence relation for vl-fundecl structures.
Change-vl-fundecl
Modifying constructor for vl-fundecl structures.
Vl-fundecl->portdecls
Get the portdecls field from a vl-fundecl.
Vl-fundecl->paramdecls
Get the paramdecls field from a vl-fundecl.
Vl-fundecl->blockitems
Get the blockitems field from a vl-fundecl.
Vl-fundecl->vardecls
Get the vardecls field from a vl-fundecl.
Vl-fundecl->rettype
Get the rettype field from a vl-fundecl.
Vl-fundecl->name
Get the name field from a vl-fundecl.
Vl-fundecl->lifetime
Get the lifetime field from a vl-fundecl.
Vl-fundecl->imports
Get the imports field from a vl-fundecl.
Vl-fundecl->loc
Get the loc field from a vl-fundecl.
Vl-fundecl->body
Get the body field from a vl-fundecl.
Vl-fundecl->atts
Get the atts field from a vl-fundecl.