• Top
    • Documentation
    • Books
    • Recursion-and-induction
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
      • Gl
      • Esim
      • Vl2014
      • Sv
      • Vwsim
      • Fgl
      • Vl
        • Syntax
          • Vl-module
          • Vl-vardecl
          • Vl-fundecl
            • Vl-fundecl-p
            • Vl-fundecl-fix
            • Make-vl-fundecl
            • Vl-fundecl-equiv
            • Change-vl-fundecl
            • Vl-fundecl->loaditems
            • Vl-fundecl->constraints
            • Vl-fundecl->vardecls
            • Vl-fundecl->typedefs
            • Vl-fundecl->portdecls
            • Vl-fundecl->paramdecls
            • Vl-fundecl->imports
            • Vl-fundecl->function
            • Vl-fundecl->rettype
            • Vl-fundecl->name
            • Vl-fundecl->lifetime
            • Vl-fundecl->loc
            • Vl-fundecl->body
            • Vl-fundecl->atts
          • 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-plainarglist->exprs
          • Vl-class
          • Vl-taskdecllist->names
          • Vl-sort-blockitems-aux
          • Vl-fundecllist->names
          • Expressions-and-datatypes
          • 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-udpsymbol-p
          • Vl-final
          • Vl-maybe-clkskew
          • 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-modelement->loc
          • Vl-ctxelement
          • Vl-ctxelement->loc
          • Statements
          • Vl-interface->ifports
          • Vl-blockitem
          • Vl-vardecllist
          • Vl-module->ifports
          • Vl-lifetime-p
          • Vl-syntaxversion
          • Vl-nettypename-p
          • Vl-paramdecllist
          • Vl-modelementlist->genelements
          • Vl-importlist
          • Vl-gatetype-p
          • Vl-typedeflist
          • Vl-genelement->loc
          • Vl-cstrength-p
          • Vl-port->name
          • Vl-elabtask->loc
          • Vl-delayoreventcontrol
          • Vl-udpentry-p
          • Vl-portdecllist
          • Vl-port->loc
          • Property-expressions
          • Vl-taskdecllist
          • 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-blockstmt-p
          • Vl-bindlist
          • Vl-initiallist
          • Vl-genvarlist
          • Vl-gclkdecllist
          • Vl-finallist
          • Vl-elabtasklist
          • Vl-defaultdisablelist
          • Vl-clkdecllist
          • Vl-cassertionlist
          • 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-casekey-p
          • Vl-blockitemlist
          • Vl-ansi-portdecllist
          • Vl-regularportlist
          • Vl-paramdecllist-list
          • Vl-modelementlist
          • Vl-interfaceportlist
        • Loader
        • Warnings
        • Getting-started
        • Utilities
        • Printer
        • Kit
        • Mlib
        • Transforms
      • X86isa
      • Svl
      • Rtl
    • Software-verification
    • Testing-utilities
    • Math
  • 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.
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.
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.
loc — vl-location
Where this declaration was found in the source code.
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.
function — sv::maybe-svex
The svex expression for the value of the function, if it has been computed, which happens during elaboration
constraints — sv::constraintlist
Constraints that must hold of the function inputs, or the result may be undefined; computed during elaboration
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.
vardecls — vl-vardecllist
Local variable declarations, including ones for the ports and return value (see below).
paramdecls — vl-paramdecllist
Local parameter declarations
typedefs — vl-typedeflist
Local type declarations.
imports — vl-importlist
Local package imports
atts — vl-atts
Any attributes associated with this function declaration.
loaditems — vl-portdecl-or-blockitem-list
Owned by shadowcheck; do not use elsewhere. Declarations within the function, in parse order, before sorting out into imports, vardecls, paramdecls, and typedefs.

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->loaditems
Get the loaditems field from a vl-fundecl.
Vl-fundecl->constraints
Get the constraints field from a vl-fundecl.
Vl-fundecl->vardecls
Get the vardecls field from a vl-fundecl.
Vl-fundecl->typedefs
Get the typedefs field from a vl-fundecl.
Vl-fundecl->portdecls
Get the portdecls field from a vl-fundecl.
Vl-fundecl->paramdecls
Get the paramdecls field from a vl-fundecl.
Vl-fundecl->imports
Get the imports field from a vl-fundecl.
Vl-fundecl->function
Get the function 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->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.