Commit Graph

158 Commits

Author SHA1 Message Date
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
Stephen Williams 5d05d97eb0 Repair handling of attributes attached to variables. 2012-05-09 10:56:52 -07:00
Stephen Williams e55af496e5 Merge branch 'master' of github.com:steveicarus/iverilog 2012-04-10 15:31:32 -07:00
Stephen Williams 13348ba7ac Ranges are ranges, not expression lists.
This is a cleanup in preparation for better support of range lists.
(cherry picked from commit 8f7cf3255acad55841f8b3725e3786ef49daad68)

Conflicts:

	PTask.h
	elab_scope.cc
	elab_sig.cc
	parse.y
	pform.cc
	pform.h
	pform_types.h

Signed-off-by: Stephen Williams <steve@icarus.com>
2012-04-10 14:29:28 -07:00
Larry Doolittle bb1036b55c Spelling refresh 2012-04-09 16:19:02 -07:00
Stephen Williams b0d61813b2 Get the scope of class methods right
Class methods belong in a class scope, not the containing module.
So create a lexical scope that carries tasks and functions and
create a PClass to represent classes.
2012-03-11 13:18:24 -07:00
Stephen Williams da743c3b2c Bunches more SystemVerilog syntax. 2012-03-09 18:54:05 -08:00
Stephen Williams f749867369 Rework rules for variable_dimensions, and support more syntax. 2012-03-02 18:34:43 -08:00
Stephen Williams 410350ae5a Rework data_type parsing to bring integer vectors into data_type_t method.
This adds the vector_type_t and real_type_t types to handle
vector and real types in tf_port items. This cleans up a lot
of the parsing for these items.
2012-02-25 22:05:00 -08:00
Stephen Williams f8e346f108 Implement increment/decrement statements.
During parse/pform processing, convert increment statements to
the equivalent compressed assignment statement. This is less weird
for elaboration processing and better expresses what is going on.
2012-02-19 18:54:58 -08:00
Stephen Williams 6b4251626b Parse array literals / rearrange task declaration rules. 2012-02-19 17:31:15 -08:00
Stephen Williams 8456252c0c More class syntax
Part of ongoing parser work to support SystemVerilog classes.
2012-02-19 10:29:50 -08:00
Stephen Williams 950e7a632c Parse multi-dimension packed arrays to pform. 2012-02-04 16:19:27 -08:00
Stephen Williams 42b3e6f268 Implement simple typedefs, and parse type identifiers.
This gets me to the point where the parser stashes a defined type,
and the lexical analyzer uses the type names to differentiate
IDENTIFIER and TYPE_IDENTIFIER.
2012-02-02 16:18:50 -08:00
Stephen Williams e14628193a Parse simple typedefs
Parse typedefs with structs and enums, but give a sorry message,
because they are not yet supported. Rearrange some of the parse
rules for variables in order to increase comonality with the
typedef rules.
2012-02-02 16:18:50 -08:00
Stephen Williams e9e2fb33e9 Handle nets that are packed structures. 2012-02-02 16:18:49 -08:00
Stephen Williams d362c8dba0 Parse support for struct variables. 2012-02-02 16:18:49 -08:00
Prasad Joshi 2cb9a2360c Add support for SystemVerilog style time literals
SystemVerilog has support for time literals. The time literal for
example #10ns, adds a delay of 10ns no matter the time unit currently
in effect. For more details please refer to
http://iverilog.wikia.com/wiki/Projects#SystemVerilog_Style_Time_Literals

Tested-by: Oswaldo Cadenas <oswaldo.cadenas@gmail.com>
Signed-off-by: Prasad Joshi <prasadjoshi124@gmail.com>
2011-07-14 18:43:55 -07:00
Cary R eb81d2fe94 Fix some bugs in task integer/real arguments.
This patch fixes the following problem in the compiler:

  An integer task argument should be marked as an integer port.

  An implicit register can be converted to either a reg or an integer.

  An old style task port should default to <no type> unless reg or some
  other type is provided. ANSI style is always defined. For example:
    input ri;
    output ro;
    inout rio;
    real ri, ro, rio;
  should define all three task ports to be of type real.
2011-01-31 11:27:11 -08:00
Stephen Williams 27dfdf99dd Enumeration element values can be expressions
Allow more complex enumeration expressions, which means putting
off the evaluation of the expression values until elaboration.
2010-11-12 18:47:06 -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 cced1e771b Remove some uses of the svector template.
I'm adding more uses of the make_range_from_width function, so
it seems like time to get rid of its use of the svector template.
This thread led to a lot of other uses of svector that had to
also be removed.
2010-10-25 19:36:44 -07:00
Stephen Williams eb4ed82893 Finish up parser code for enum types
This gets the parser syntax actions done, up to the pform code.
It is ready for generating pform structures.
2010-10-24 11:21:17 -07:00
Stephen Williams e03ff763fb Parse support for SystemVerilog atom2 types. 2010-10-10 10:06:26 -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 b7264d21d5 Fix some definition/implementation name differences.
Update some of the definition argument names to match the recent
implementation name changes
2010-06-08 11:03:11 -07:00
Cary R 1993bf6f69 Remove malloc.h support and for C++ files use <c...> include files.
The functions (malloc, free, etc.) that used to be provided in
malloc.h are now provided in cstdlib for C++ files and stdlib.h for
C files. Since we require a C99 compliant compiler it makes sense
that malloc.h is no longer needed.

This patch also modifies all the C++ files to use the <c...>
version of the standard C header files (e.g. <cstdlib> vs
<stdlib.h>). Some of the files used the C++ version and others did
not. There are still a few other header changes that could be done,
but this takes care of much of it.
2010-06-01 08:56:30 -07:00
Stephen Williams 79f8b8fcfd Remove Link::strength_t and PGate::strength_t types.
These types are useless repetition of the ivl_drive_t type.
This is also another chapter in the series to push ivl_target
generation further upstream.
2010-03-16 15:16:53 -07:00
Stephen Williams 47e68e21b1 Detect generate regions within generate schemes.
Generate schemes may nest freely, but generate regions
(an anachronistic concept from 1364-2001) cannot nest,
not within schemes or other regions. Have the parser detect
the nesting and print an error message.
2010-03-11 16:06:02 -08:00
Stephen Williams 70fc742c9d Add support for primitive types of ports.
The infrastructure is already there, all that's missing is the
syntax in the parser.
2010-03-11 12:22:41 -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
Stephen Williams 7b102b18fd Add function to define parameter from command line
This patch is based on one from "bruce <bruce1914@gmail.com>".
I've applied all but the elaboration code, which I rewrote to
properly work with the elaboration work queue. I also constrained
the implementation so that the parameter name must have exactly
two components: the root scope name and the parameter name. This
is necessary to keep the defparm processing sane. The comments
from bruce's original patch are as follows:
--
This patch would provide function to define parameter from command
line. This serves the same functionality as 'defparam' in Verilog
source code, but provide much more ease for using. Parameter
definition can be write in command file, with following syntax:

    +parameter+<scope>.<parameter>=<val>

*Do not apply any space between them*
The scope name should be full hierachical name with root name at
the begining. The following example would override test.T1 with
new value 2'b01:

    +parameter+test.T1=2'b01

'test' here is the root module name. The parameter value here
should be constant. Parameter definition can also be write in
the command line:

    iverilog -Ptest.T1=2'b01

This serves the same functionality with the previous example.
If we define the same parameter in command file and command line,
the one in command line would over-write all others.
2009-08-06 14:42:13 -07:00
Cary R 9dce6496fb Fix up original SV timeunit/timeprecision patch.
This patch modifies the original SystemVerilog timeunit/timeprecision
patch in the following way:

Removed trailing space.

Reworked some code to use standard spacing rules.

Added some comments.

Combined some code.

Major rework of local/global timeunit/timeprecision logic.

Major rework of timeunit/timeprecision declaration/check code.
This was needed to remove the shift/reduce warnings.

Add a number of checks for invalid combinations.
2009-07-28 19:18:09 -07:00
Sreeraj R c2feeb03df System Verilog timeunit and timeprecision addition
This patch adds timeunit and timeprecision keywords.Use -gsystem-verilog
generation flag to use this feature
2009-07-28 19:18:01 -07:00
Cary R d06f6dfc51 Add support for unconnected_drive.
Icarus has recognized this directive, but it did not do anything
with the information. This patch adds the functionality for most
common cases. It adds this by changing the input net type from
wire/tri to tri1 or tri0 depending on the pull. The issue is that
if the input net is not a wire or tri this is not safe and should
really be done as an external pull gate connected to the input.
We will need to handle this is it ever comes up. For now a sorry
message is printed.
2009-06-07 16:14:52 -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
Stephen Williams 17b937740a Merge branch 'master' into verilog-ams 2008-11-28 16:29:50 -08:00
Stephen Williams bd754b24f4 Support direct nesting of conditional generate schemes.
Verilog generate schemes support a special case where conditional
generate schemes that contain only a nested conditional generate
scheme do not create a new scope. Instead, it relies on the nested
generate scheme to generate the scope.
2008-11-27 19:45:22 -08:00
Stephen Williams e98f29e96f Merge branch 'master' into verilog-ams 2008-11-16 18:42:06 -08:00
Cary R 407ce5e152 Add support for the 1364-2001 generate of a named block.
This is obsolete in 1364-2005, but is supported 1364-2001.
Icarus already supported generate with unnamed block.
2008-11-15 08:08:29 -08:00
Stephen Williams eb240ddb73 Bring discipline natures all the way to the ivl_target API.
The natures of disciplines were already available, this just brings
the information forward to the ivl_target.h API and exposes them via
access functions.
2008-11-03 21:10:10 -08:00
Stephen Williams ddb2c60701 Remove svector class from Module.h
The goal is to completely remove the svector class because the standard
vector class works perfectly well. This removes the uses in the Module.h
header file.
2008-11-02 20:08:38 -08:00
Stephen Williams f4687757f1 Bring signal discipline all the way to the ivl_target API.
Signals may have VMA disciplines attached. Make the attached discipline
visible through the ivl_target.h API. Also, re-arrange the internal
handling of the discipline structure so that we can expose disciplines
through the ivl_target C API without creating new structures. The
t-dll-api implementations of the discipline access functions can look
at the elaborated discipline structure directly. This is possible since
the discipline parse and elaboration are very simple.
2008-11-02 08:10:41 -08:00
Stephen Williams 68fbb94b3a Basic elaboration of analog contribution statements.
Get at least basic elaboration of analog processes and contribution
statements. Bring the statements and analog statements together and
net future elaboration work sort out which statements are valid in
a given context. This makes sense because there really is a lot of
syntactic overlap, and analog behavioral code is processed somewhat
sequentially.
2008-10-22 21:56:00 -07:00
Stephen Williams 5aa810dde7 Infrastructure for elaborating analog statements.
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.
2008-10-21 22:15:49 -07:00
Martin Whitaker 082e06edb0 Remove checks for constant expressions from the parser.
This patch removes all the checks for constant expressions performed
during the parsing phase, as these checks are (mostly) repeated during
elaboration. It adds the missing check in the elaboration phase (the
RHS of a register initialisation), and improves the error reporting
and error recovery in other checks.

This patch fixes pr2132552, which was caused by a fault in the parser
constant expression checking.
2008-10-09 11:11:32 -07:00
Martin Whitaker a4973c217d Support parameter, localparam, and event declarations in any scope.
Currently, parameters and localparams declared in tasks, functions,
generate blocks, and named blocks are placed in the parent module
scope. Event declarations in these scopes are not permitted (a
syntax error is reported). This patch corrects this behaviour, so
that all the above declarations are accepted and are placed in the
scope in which they are declared.

Note that the IEEE standard does not permit parameter declarations
in generate blocks. This patch causes the parser to reject such
declarations.
2008-09-19 20:23:14 -07:00
Stephen Williams 6f002935d7 Parse attributes on statements within event statements.
Statements can have attributes attached to them. Handle a few cases in
the parser where attributes may be attached to statements, and get them
as far as the pform.
2008-09-04 21:27:21 -07:00