Unparameterization
Expand away modules with parameters; similar to the idea of
elaboration of the design.
Unparameterization is a Verilog transformation which, given a set
of Verilog modules, is supposed to produce an equivalent, parameter-free set of
modules.
Background on Parameters
See vl-paramtype and vl-paramdecl for background on our
representation of parameter declarations. Parameters can be declared as either
ordinary parameters or as localparams. Parameters may have default
values, and their defaults can refer to other parameters in the module. Some
simple examples of parameters are:
module m (a, b, c) ;
...
parameter size = 4 ;
localparam twosize = 2 * size ;
...
endmodule
Such a module can be instantiated in various ways, e.g.,:
module uses_m (x y z) ;
...
m #(6) m_instance_1 (.a(x), .b(y), .c(z)) ; // size 6
m #(.size(6)) m_instance_2 (.a(x), .b(y), .c(z)) ; // size 6
m m_instance_3 (.a(x), .b(y), .c(z)) ; // size 4
...
endmodule
Local parameters are just like parameters except that they cannot be
assigned to from outside the module. They seem like about the cleanest way to
introduce named constants, as unlike `define they don't pollute the global
namespace.
Parameters can also be given values via the defparam statement, but
this construct is being deprecated (see SystemVerilog-2012 section C.4.1) and
may be removed from future versions of the language. We generally think that
using defparam is bad form. VL does not support defparam, so we do
not consider it here.
Unparameterization
The basic idea behind unparameterization is pretty simple.
Suppose we are dealing with a parameterized module called plus, which
takes a single parameter called size. There may be several modules, say
m1, m2, and m3, which contain instances of plus with
different sizes, say 8, 16, and 32.
Our general goal is to eliminate plus from our module list by replacing
it with three new modules, plus$size=8, plus$size=16, and
plus$size=32, which are copies of plus except that size has been
replaced everywhere with 8, 16, or 32 as suggested by their
names.
At the same time, we need to change the instances of plus throughout
m1, m2, and m3 with appropriate instances of the new modules.
Finally, once all of the instances of the generic plus have been done away
with, we can safely remove plus from our module list.
Subtopics
- Vl-unparameterize-flow
- How the heck does unparameterization/elaboration work?
- Vl-unparam-inst
- Compute the final parameter values for a single module instance.
- Vl-unparam-add-to-ledger
- Generate an instkey for an unparameterized module and add it to the ledger
if it isn't there already.
- Vl-scopeinfo-resolve-params
- Vl-scope-finalize-params
- Vl-create-unparameterized-interface
- Vl-create-unparameterized-module
- Vl-unparam-actualkeys
- (vl-unparam-actualkeys x inst-ss mod-ss) maps vl-unparam-actualkey across a list.
- Vl-make-paramdecloverrides
- Line up parameter arguments with parameter declarations.
- Vl-unparam-class
- Compute the final parameter values for a static class scope invocation
- Vl-unparam-instlist
- Vl-create-unparameterized-class
- Vl-add-lost-interface-warnings
- (vl-add-lost-interface-warnings x) maps vl-add-lost-interface-warning across a list.
- Vl-add-lost-module-warnings
- (vl-add-lost-module-warnings x) maps vl-add-lost-module-warning across a list.
- Vl-unparam-classlist
- Vl-interfacelist->orignames
- (vl-interfacelist->orignames x) maps vl-interface->origname across a list.
- Vl-user-signature
- Vl-interfaceport-default-signature
- Vl-modulelist->orignames
- (vl-modulelist->orignames x) maps vl-module->origname across a list.
- Vl-plainarglist-update-ifports
- Vl-portlist-interface-signatures
- Vl-user-signatures
- Vl-plainarg-update-ifports
- Vl-unparam-inst->instkey
- Vl-toplevel-signatures
- Vl-unparam-basename
- Generate a new name for an unparameterized module.
- Vl-genblob-resolve-rejoin-scopeitems
- Vl-gencase-some-match
- Vl-gencase-match
- Vl-package-elaborate
- Resolve parameters in packages.
- Vl-unparam-signature
- An unparam signature describes a module/parameter combo that needs to be created.
- Vl-unparam-ledger
- Vl-packagelist-elaborate
- Vl-design-elaborate
- Top-level unparameterization transform.
- Vl-unparam-actualkey
- Vl-make-paramdecloverrides-named
- Line up named parameter arguments with parameter declarations.
- Vl-unparameterize-main
- Unparameterize a module and its dependencies.
- Vl-recover-modules-lost-from-elaboration
- Vl-finish-unparameterized-interface
- Vl-paramdecl-set-default
- Vl-genblob-rejoin-scopeitems
- Vl-finish-unparameterized-interfaces
- Vl-unparam-instkey
- Mainly, the type of an element produced by vl-unparam-inst->instkey.
- Vl-finish-unparameterized-module
- Vl-finish-unparameterized-class
- Vl-finish-unparameterized-modules
- Vl-finish-unparameterized-classes
- Vl-genblob-split-scopeitems
- Vl-user-paramsettings-for-top-names
- Vl-string/int-alist-to-namedargs
- Vl-add-lost-interface-warning
- Vl-unparam-basename-exprstring
- Vl-add-lost-module-warning
- Vl-paramdecllist-remove-defaults
- Vl-ifport-alist
- Mapping from interface port portnames to interface names.
- Vl-paramdecl-remove-default
- Vl-ifportexpr->name
- Vl-paramdecllist-all-localp
- Vl-unparam-instkeymap
- An alist mapping vl-unparam-instkey-p to vl-unparam-signature-p.
- Vl-unparam-donelist
- An alist mapping vl-unparam-instkey-p to anything.
- Vl-unparam-instkeylist
- A list of vl-unparam-instkey-p objects.