Commit Graph

92 Commits

Author SHA1 Message Date
Stephen Williams 480668fee6 Add support for classes defined in $root scope. 2014-09-15 17:37:30 -07:00
Stephen Williams 1465fd1570 Class definitions may reference class types in containing scopes.
We need the scope where the class is defined so that it can find
types in that containing scope. Note that most definitions cannot
escape into the the lexical scope of the class, but some can.
2014-09-02 09:22:41 -07:00
Cary R 8c3f7d78b9 Partial fix for br956 (various enumeration bugs)
This patch fixes the following enumeration bugs:

When looking for an enumeration look in the current scope and then
recursively in any parent scope.

Add enumeration definitions to a package scope.
2014-08-28 13:02:42 -07:00
Stephen Williams 2e2317b7c7 Generalize the hname_t to handle n-dimensional scope arrays.
... Not that they actually exist yet. But this fixes some symbol
search issues and makes room for this support in the future.
2014-04-06 08:40:09 -07:00
Stephen Williams fc42f40770 Fix problem with enum types in re-used modules
When a module is instantiated multiple times, the enum
types contained within would cause trouble. This fixes
that by elaborating in proper scope context.
2014-01-11 19:19:15 -08:00
Stephen Williams a3b29dd70b Handle enumeration literals that are in $root. 2014-01-11 19:19:14 -08:00
Stephen Williams 20ee350601 Generalize user defined function return type handling.
I'm gonna need functions to return class objects, so generalize
the output types of user defined functions.
2013-04-20 16:38:35 -07:00
Stephen Williams 17330a3073 Elaborate class task and function methods.
The parse of class methods already works, this patch forms
the methods into their own scopes, and elaborates those scopes.
The "this"
2013-03-24 15:12:35 -07:00
Martin Whitaker 1bcd3a97ad Support disable statements and system task calls in constant functions.
This patch implements the evaluate_function method for the NetDisable
and NetSTask classes. It also makes the checks for a function being
constant work when the function contains nested scopes (named blocks).
2013-03-24 14:42:59 -07:00
Martin Whitaker faece5816c Fix implicit casts in assignments (part 3).
This patch adds support for bool/bit vector types on the LHS of
a parameter declaration and ensures implicit casts in parameter
declarations are performed where necessary.
2013-03-24 13:50:53 -07:00
Stephen Williams 60cb78e4ab Add packages and their own scope.
This makes <pkg>::<name> work properly, and also makes the
package descriptions available through VPI.
2013-02-17 17:00:15 -08:00
Stephen Williams 77d24cd095 Elaborate class_new and (null) expressions
This gets the types right for class_new and null expressions, and
elaborate them down to the ivl_target.h API.
2012-12-10 19:13:43 -08:00
Arun Persaud f5aafc32f9 updated FSF-address 2012-08-29 10:12:10 -07:00
Cary R 7ce8a9b01c Fix some cppcheck warnings in the main directory 2012-08-08 11:28:20 -07:00
Andrew Stevens 9b3d20239a Extend VPI and build to for SIMetrix cosimulation
Added: basic vpiPort VPI Objects for vpiModulkes
    vpiDirection, vpiPortIndex,   vpiName, vpiSize attributes

   Since ports do not exist as net-like entities (nets either side
   module instance boundaries are in effect connect directly in
   the language front-ends internal representation) the port information
   is effectively just meta-data passed through t-dll  interface and
   output as a additional annotation of module scopes in vvp.

Added: vpiLocalParam attribute for vpiParameter VPI objects

Added: support build for 32-bit target on 64-bit host (--with-m32
   option to configure.in and minor tweaks to Makefiles and systemc-vpi).
2012-06-07 08:00:02 -07:00
Stephen Williams 8154ce2a4a Reword how we enforce program block constraints
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.
2012-05-27 18:26:53 -07:00
Stephen Williams dfe7beec31 Allow modules (and program blocks in particular) to nest.
An important advantage of program blocks is its ability to nest
within a module. This winds up also allowing modules to nest, which
is legal but presumably less used feature.
2012-05-27 18:26:53 -07:00
Martin Whitaker 509ec1dcb1 Simplify parameter handling in the elaborated netlist.
A NetScope object currently has two lists of parameters, 'parameters'
and 'localparams'. However, user-declared localparams are stored in
the 'parameters' list, and 'localparams' is only used for adding
genvar values to the parameter list. There seems no good reason to
maintain separate lists, as the lists are merged before being passed
to the target DLL. This is most likely a hang-over from older code.
2012-05-17 16:29:06 -07:00
Martin Whitaker 44c5a37ab8 Allow specparam declarations outside specify blocks.
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.
2012-05-17 16:18:38 -07:00
Jared Casper 9b785031f5 Implement SystemVerilog final statements.
Add a new IVL_PR_FINAL process type.

Add a flag to NetScope in_final_ which is set when elaborating the
statement of a final procedure.

Add checks during statement elaboration for invalid statements in a
final procedure, similar to checks for statements in functions.

Do a final check to make sure no final blocks have delays.

In the vvp runtime, use "$final" as the flag for the thread created by
the final procedure.  During compilation, instead of adding such a
thread to the sched_list, add it to a new schedule_final_list that
mirrors the schedule_init_list, but is run at the end of simulation.
2011-08-11 14:31:38 -07:00
Martin Whitaker 1e9f9685cc First step towards supporting constant user functions.
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.
2011-04-13 18:40:19 -07:00
Cary R 1e3af45335 Pass some module port information and fix a few bugs.
This patch adds some preliminary module port information to the ivl
interface. This may change as I investigate exactly what is needed.
It also fixes a few minor bugs (a missed local variable and spacing)
2011-03-08 19:15:28 -08:00
Martin Whitaker 275dde7712 Rework of parameter expression elaboration.
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.
2010-12-06 14:56:50 -08:00
Stephen Williams cd6c6c7a70 Get the netenum_t base type data from the pform.
The pform propagates the parsed enum base type information
to the elaborator so that the base type can be fully elaborated.
This is necessary to get the types of the enumeration literals
correct.
2010-11-03 20:11:19 -07:00
Stephen Williams 5b5a6b05b7 Test type correctness during elaboration.
Create a netenum_t class to carry the enumeration type in the
netlist.h structures, and use that type to check enumerations
with assignments.
2010-11-02 20:16:42 -07:00
Stephen Williams a14fa038b4 Enum names in r-value expressions
When enum names are used as r-values in expressions, use their
values. Treat the enum names similar to (but not exactly as)
localparams so that they fit into the rest of the elaboration
flow naturally.
2010-10-31 11:26:09 -07:00
Cary R eb525b6c2a Fix some initialization problem found with cppcheck.
This patch adds a few missing initializations to various constructors
and reworks the realloc() error handling code in driver-vpi/main.c.
2010-10-14 17:48:02 -07:00
Stephen Williams ec49f10e2d Revert bad merge from vhdl branch 2010-10-02 11:02:27 -07:00
Cary R 86653ddff9 Remove some cppcheck warnings.
This patch modifies the code to remove some more cppcheck warnings.
2010-07-30 18:50:52 -07:00
Cary R 22f91d2d34 A NULL iterator is not portable.
Trying to return a NULL iterator on failure is not portable. It is
better to assert since we have already verified that a parameter
should exist.
2010-05-17 20:48:27 -07:00
Stephen Williams 8cbff6def0 Cleanup various style issues.
This patch cleans up some style issues: no need to check that a value
is defined before freeing or deleting it, use C++ style casts, make
sure to NULL terminate strncpy(), empty() is faster than size() for
size == 0 or size >= 0 checks, re-scope some variables, etc.
2010-04-13 21:29:15 -07:00
Martin Whitaker f95593716f Fix for pr2924354.
Creation of implicit nets requires knowledge of whether an identifier
has been declared before it is used. Currently implicit nets are
created during elaboration, but by this stage the order of declaration
and use is not known. This patch moves the creation of implicit nets
into the parser stage.
2010-01-23 09:10:00 -08:00
Stephen Williams b1d9d1bda2 Dramatically improve NetScope child lookup.
In physical models, there are often very many child scopes in any
given scope. The lookup for child scope needs to be optimized.
2009-12-08 15:14:55 -08:00
Martin Whitaker da010db739 Fix for pr2842185 and for genvar scopes.
When checking for name collisions, the compiler looks for genvar
declarations in the enclosing module rather than in the current
scope, which leads to false positives. The compiler also places
all genvar declarations in the enclosing module scope, even when
the declarations are inside a generate block which has its own
scope. This patch fixes both these faults. It also fixes some
typos and outdated information in comments.
2009-08-25 10:23:59 -07:00
Cary R 72a98e85cb Add full genvar support and name space checking.
This patch adds genvars to the elaboration process. It adds checks
that a genvar is defined for a generate loop and that a genvar does
not conflict with any other items in its name space.
2009-07-28 20:04:54 -07:00
Cary R 636758f66d Add support for `celldefine, vpiCellInstance
This patch adds real functionality for `celldefine and pushes this
property to the run time which can access this with vpiCellInstance.
This is technically only available for a module, but all scopes
have the property and only modules should return true when the
'endmodule' is between a `celldefine and `endcelldefine directive.
2009-05-23 14:13:47 -07:00
Cary R 192522b3d8 Check for name space collisions.
This patch adds code to check for most of the name space
collisions. genvars are not checked correctly since they
are not completely implemented.
2009-04-27 17:24:36 -07:00
Cary R 5d5c7e88f9 Warn the user if they use both a default and `timescale based delay.
This patch add code to print a warning message if it finds both a
default and `timescale based delays. The -Wall or more specifically
the -Wtimescale flag can be used to find the module with the missing
`timescale directive.
2009-04-17 18:12:27 -07:00
Stephen Williams 27410f5d88 Remove the now obsolete NetNet list in NetScopes.
Now that NetNet objects in NetScopes are kept in a map, remove the
linked list for scanning them. This improves the lookup process from
an O(e**N) process to more like O(log(N)). This matters for very
large designs.
2008-10-26 20:42:11 -07:00
Stephen Williams 0af896a7ff Keep a map of NetNets for fast access.
It turns out that netnets in scopes are accessed a lot, and mapping
them may help with performance.
2008-10-26 16:50:46 -07:00
Larry Doolittle 3adcbb5611 Shadow reduction part 2
Continue cleaning up shadowed variables, flagged by turning on -Wshadow.
No intended change in functionality.  Patch looks right, and is tested
to compile and run on my machine.  No regressions in test suite.
2008-10-13 20:12:47 -07:00
Cary R 11109f519c Push the automatic property for tasks and functions to the code gen.
This patch pushes the automatic property for both tasks and
functions to the code generators. The vvp back end does not
currently support this so it will error out during code
generation. The VHDL back end should be able to use this
property and tgt-stub prints the property. Having this will
also make it easier when we do adding this to the runtime.
2008-08-20 09:23:14 -07:00
Larry Doolittle eed4ff7e2d Spelling fixes
Mostly comments, but includes quite a few
user-visible error, debug, and help messages.
2008-06-13 08:51:28 -07:00
Stephen Williams f132e09475 Fix default parameter type if localparams are present.
localparam declarations were messing up the state of parser variables
so that the default types of following parameters got messed up.
2008-06-05 14:38:56 -07:00
Larry Doolittle deb7b01717 Compatibility with gcc-4.3
Add include statements (<cstdlib> for abort()) and a cast.
Necessary and sufficient for successful compilation with
gcc-4.3 (Debian 4.3.0-4) 4.3.1 20080501 (prerelease)
2008-05-19 18:31:08 -07:00
Stephen Williams c76e88cad5 Add support for explicit parameter types, including real.
Before this, the types of parameters were always logic, only the
width and signed-ness could be controlled. A parameter may take
on implicit real values if the expression were real.

With this patch, the type for the parameter can be explicitly set
to logic or real. This also means that the parameter real valued
expressions need to be more crefully treated, possibly with casting
integral expressions to real values, or real expressions to integral
values.
2008-05-17 16:25:58 -07:00
Stephen Williams 48f934abf7 Get parameter ranges as far as the netlist form.
The pform is now translated/elaborated into NetScope objects. All that
remains is to check the parameter values against the ranges. This is
to be done in the evaluate_parameters() method.
2008-05-13 21:22:52 -07:00
Cary R 4f8b91e65c Add file and line information for parameters, etc.
This patch adds file and line information for parameters and
local parameters. It also adds file/line stubs for signals in
the tgt-* files. It adds the pform code needed to eventually
do genvar checks and passing of genvar file/line information.
It verifies that a genvar does not have the same name as a
parameter/local parameter.
2008-05-06 07:14:27 -07:00
Cary R 86a4025b58 Push file and line information for scopes to the runtime.
This patch adds code to push the file and line information
for scope objects (modules, functions, tasks, etc.) to the
runtime. For modules, this includes the definition fields.
2008-04-29 21:51:34 -07:00
Cary R 3c1e7c4260 A NetScope will get a default nettype from a parent.
The default nettype was not always being set. This patch
modifies the NetScope constructor to get the default
nettype from a parent if it exists. It is set to NONE if
a parent does not exist.
2008-04-04 21:31:14 -07:00