Making the scope type NESTED_MODULE was just plain wrong, because it didn't really encapsulate the meaning of program blocks OR nested modules. So instead create nested_module() and program_block() flags and use those to test scope constraints.
This patch extends the compiler to support all specparam declarations allowed by the 1364-2005 standard. For compatibility with other simulators, it allows specparam values to be used in any constant expression, but outputs a warning message and disables run-time annotation of a specparam if it is used in an expression that must be evaluated at compile time.
For a parameter we want to keep the base definition file/line information not the file/line information for the override.
A declaration of the form "parameter signed a = 1.0" causes a compiler crash. The standard is somewhat contradictory on what type "a" should have, but testing with other compilers shows a majority in favour of it being a real value.
The standard allows a parameter (or localparam) declaration of the form "parameter signed my_param = ...". The parser currently rejects this. A small adjustment is also required in the parameter evaluation code to correctly apply the type.
This patch allows the compiler to perform early elaboration of functions if they are encountered in expressions that are elaborated before the function would normally be elaborated. This makes the function available for constant evaluation. Suitable error messages are generated if a function that is used in a constant expression is not a valid constant function.
This patch changes the method used to signal that a constant expression is being elaborated from flags stored in global variables to flags passed down the call chain. It also generates more informative error messages when variable references are found in a constant expression.
The compiler currently performs parameter expression elaboration before performing parameter overrides. This means that the information needed to correctly determine the expression type and width may not be available at the time elaboration is performed. This patch reworks the code to delay elaboration until after all overrides have been performed. It also provides a new -g option that controls how the width of parameter expressions is calculated when the parameter itself is unsized.
This patch changes all the iterator code to use a prefix ++ instead of postfix since it is more efficient (no need for a temporary). It is likely that the compiler could optimize this away, but lets make it efficient from the start.
This patch adds support for passing the delay selection to vvp. It adds a new header :ivl_delay_selection "<value>"; that has the values TYPICAL, MINIMUM or MAXIMUM depending on the -T flag to iverilog. This information is needed by $sdf_annotate to select that appropriate value for a triplet when "TOOL_CONTROL" is specified (default).
This patch adds checks in various places to prevent the user from taking a concatenation of a real value.
This fixes up the elaboration of binary expressions found in parameter expressions. Parameter expressions are special because they elaborate early, before all the other parameters are necessarily completed.
This includes enough API to get the branch nexus bits and signals and show them in the dump. This also includes creating the reference ground for branch access functions that use the implicit ground.
Put together the infrastructure for elaborating analog statements, including create the NetAnalogTop objects that hold analog statements and are in turn held by the design. While doing this, clean up the various unique initial/always enumerations to use the ivl_process_type_t type.
When elaborating a parameter expression fails we need to set the expression to 0 since it has already been partially allocated. Doing this allows us to not evaluate the dummy expression later.
When generate schems and instance arrays are nested, it takes multiple iterations of elaborate scope, defparams and evaluate parameters before everything is worked out. Rework the work item processing so that the loop elaborates scopes and runs defparams in phases. The phases are needed so that we can tell when the remaining defparams are orphaned.
The l-value of a defparam assignment is a hierarchical name that may include array selects to select scopes from module arrays. Therefore it makes no sense to store parsed defparams in a map. Instead, they should go into an ordered list. This also maked more sense because later defparams *may* have the same name as a previous defparam, and will override the previous defparam. So replace the map of parsed defparams with a list of parsed defparams. Also, as soon as the defparam expression is elaborated, the list entry is no longer needed, so delete it. Save memory.
It is possible for defparams to not find their target the first time around, because the elaboration of the target scope is not yet done. So retry the defparams once for each scope by putting it on a work item in the elaborator_work_items list.
This patch adds the time and realtime types to parameters and local parameters. It also makes the width (range) of an integer parameter match the variable "integer_width" (normally 32 bits). It also converts a real value to an integer when a range is implicitly or explicitly given. This all matches what the standard specifies. Fixed an error in converting -1 to a unsized verinum.
When parameters are replaced, the expression that is replaced is deleted so make sure the pointer in the map is properly updated. Also, make sure the defparam expression itself is not deleted because it is used to print messages, such as design dumps.
localparam declarations were messing up the state of parser variables so that the default types of following parameters got messed up.