Commit Graph

392 Commits

Author SHA1 Message Date
Martin Whitaker d6e01d0c55 Fix assertion failure when no value supplied with -P option (GitHub issue #377) 2020-10-24 22:48:00 +01:00
Martin Whitaker 33b822d997 Add support for local genvar declaration in generate loops.
As requested in GitHub issue #304.
2020-01-31 20:29:22 +00:00
Martin Whitaker 0023804777 Add support for increment/decrement operators in generate loop iteration.
As requested in GitHub issue #303.
2020-01-30 21:45:04 +00:00
Martin Whitaker 8dc395940d Fix issue #298: elaborate types in the scope where they were declared.
The compiler elaborates types on the fly as they are used. For user-
defined types (typedefs) we must do the elaboration in the scope where
the type was declared, not in the scope where it is used.
2019-12-22 17:29:23 +00:00
Martin Whitaker 732a763188 Record typedef name in data_type_t struct.
This will be used to locate the scope where the type was declared.
2019-12-22 11:21:05 +00:00
Martin Whitaker 95147a2cc2 Record data type for all pform "wires" added the new way.
For unpacked arrays, record both the array type and the base type.
This will be needed to elaborate typedefs in the correct scope.
2019-12-22 11:03:50 +00:00
Martin Whitaker 862010ac19 SV does not require constant expression in variable initialisation. 2019-10-05 20:11:38 +01:00
Stephen Williams 2ced291d33 Replace an assert with an internal error message. 2019-10-03 08:38:36 -07:00
Martin Whitaker ed75bc22ec Fix incorrect loop termination test when searching for typedefs. 2019-10-03 00:32:09 +01:00
Cary R eeae2bfee9 Fix a syntax issue found while compiling with gcc 5.4 2019-10-01 18:58:28 -07:00
Martin Whitaker 7cead04e6a Merge branch 'master' of github.com:steveicarus/iverilog 2019-10-02 00:16:18 +01:00
Stephen Williams 5651adf73a Handle breakage in nested module parsing. 2019-10-01 15:19:46 -07:00
Martin Whitaker 1cc872be8c Downward references may also activate potential imports. 2019-10-01 09:08:15 +01:00
Martin Whitaker 1fca7b41a4 Delay potential imports for task/function calls until end of scope.
A local task/function definition takes precedence, even if it appears
after the call.
2019-10-01 09:08:07 +01:00
Martin Whitaker c5c264400e Add support for package scope resolution for named events. 2019-10-01 09:07:54 +01:00
Martin Whitaker 12fe4f2bf3 Fix handling of wildcard-imported types.
Don't add them to the explicit imports until they are referenced legally.
Stop searching when a matching name is found, even if it isn't a type name.
2019-10-01 09:07:48 +01:00
Martin Whitaker b0142a6406 Add support for named events in packages. 2019-10-01 09:07:39 +01:00
Martin Whitaker 439688fa46 Add anonymous enums to the scope local symbols. 2019-09-27 22:19:30 +01:00
Martin Whitaker 2ae910750b Put generate case item block names in correct scope.
The compiler creates an artificial scope around the case items. We need
to add the block names to the real containing scope.
2019-09-27 22:19:30 +01:00
Martin Whitaker 03c4c63df1 Fix file/line reported for duplicate named blocks. 2019-09-27 22:19:30 +01:00
Martin Whitaker 628f5645bf Fix file/line reported for duplicate parameter declarations.
We need to retain the old parameter information until we have reported
the error.
2019-09-27 22:19:30 +01:00
Martin Whitaker d3bced57cc Correctly handle explicit and wildcard package imports.
Explicit imports should always conflict with local declarations using
the same name. Wildcard imports only conflict if they are referenced
before a local declaration with the same name.

This also unifies the detection of identifier conflicts.
2019-09-27 22:19:30 +01:00
Martin Whitaker 269ec2f042 Remove redundant checks for package imports during parsing.
The find_* and symbol_search functions now handle this.
2019-09-27 22:19:30 +01:00
Martin Whitaker 02ee1c65d0 Support dynamic array initialisation in variable declarations. 2019-09-16 20:35:27 +01:00
Martin Whitaker 89cbc42094 Reset parser tracking variables when starting a new compilation unit.
This fixes the problem reported in GitHub issue #254, where if the
parser aborted on one compilation unit, spurious errors were reported
for the next compilation unit.
2019-07-23 22:18:39 +01:00
Stefan Biereigel 7f5145d758 emit only warning for primitive redefinition 2019-05-17 15:20:49 +02:00
Martin Whitaker f8a2a4816c Enable parameter/localparameter definitions in the compilation unit scope. 2018-02-18 19:21:18 +00:00
Martin Whitaker 2a21fe77ac Output an error message when a SV variable declaration reuses a name.
Assertion failures are not the right way to handle user code errors.
2018-02-18 17:51:56 +00:00
Martin Whitaker caf83b02c1 Enable variable declarations/initialisations in the compilation unit scope. 2018-02-18 14:09:03 +00:00
Cary R 585a0232cb Add preliminary support for always_comb, always_ff and always_latch 2017-11-20 07:50:05 -08:00
Martin Whitaker f83e01847a Fix a couple of minor bugs in the timescale parsing rework. 2017-11-06 00:37:56 +00:00
Martin Whitaker 479af09cc3 Fix trailing whitespace. 2017-11-05 22:28:53 +00:00
Martin Whitaker fd807a7700 Rework handling of timescales in parser.
This implements and enforces the full set of rules for determining
timescales in SystemVerilog. The previous relaxation of the rules
that allowed timescales to be redefined within the compilation unit
scope has been removed. Time unit and precision redeclarations are
now recognised after a nested module declaration.
2017-11-05 17:50:05 +00:00
Martin Whitaker 988816c0b1 Support separate compilation units in SystemVerilog.
The compilation unit scope is now treated as a specialised form of
package (with an automatically generated name). All items declared
outside a design element are added to the current compilation unit
package. Apart from when searching for a symbol, once we get into
elaboration we can treat these just like any other package.
2017-10-31 20:38:59 +00:00
Martin Whitaker dfddbea26b First step towards supporting separate compilation units in SV.
This adds a -u option to the driver to allow the user to specify that
they want each source file to be treated as a separate compilation
unit, and modifies the compiler to accept a list of files (either on
the command line or via a file specified by a new -F option). This
list of files is then preprocessed and parsed separately, causing all
compiler directives (including macro definitions) to only apply to the
file containing them, as required by the SystemVerilog standard.
2017-10-31 20:36:27 +00:00
Martin Whitaker 87cddf33dc Fix for GitHub issue #98 and #167
Two fixes needed:
  - when searching for a base class, we need to look in the root scope
    if the base class isn't found in the scope hierarchy
  - the classes in the root scope need to be stored in an ordered
    list, not a map, to ensure they are elaborated in the order they
    were declared. Without this, the compiler may try elaborating an
    extended class before its base class is known about.
2017-10-08 21:15:11 +01:00
Martin Whitaker 8a5cbd4415 Fix for GitHub issue #152 - segfault on gate connection syntax error.
If there is a syntax error in the source code, pform_makegate may be
passed a null list of port connections. The error is already reported,
so we just need to ignore it.
2017-04-21 21:37:17 +01:00
Vamsi Vytla cfd3b893be Add support to handle attributes at module instantiation sites.
(* my_fancy_attribute *)
foobar1 foobar (clk(clk), rst(rst) ...);

  - Modifies PGModule to hold the attribute map (can be verified with pform_dump)
  - pform_make_modgate(s) bind the attributes from the parser to the above map
  - The attributes from PGModule are inserted into the NetScope of that module
    PGModule::elaborate_scope_mod_instances_
  - Currently these attributes automatically make it into netlist
  - These attributes are accessible via ivl_scope_attr_cnt and ivl_scope_attr_val
    from ivl_target.h
2017-03-16 07:41:10 -07:00
Martin Whitaker 3c91630b53 Improved error checking for defparam values supplied on the command line.
Fixes GitHub issue #139 plus various assertion failures when invalid
values are specified.
2017-01-29 20:13:01 +00:00
Cary R 5853e32f82 Fix some cppcheck warning issues 2016-09-13 23:45:25 -07:00
Martin Whitaker 3c9b39846c Use gn_system_verilog() where appropriate.
Replace explicit comparisons against generation_flag with calls to
the gn_system_verilog helper function, both for code clarity and
to fix a couple of bugs. Also simplify the implementation of the
function, as we already rely on the generation_flag enumeration
being an ordered list.
2016-09-08 23:00:48 +01:00
Cary R 1d4230472a Fix getting timeunit outside of module to use a defined check value 2016-08-14 17:26:23 -07:00
Martin Whitaker 7bed181f68 Support timescales in design units that aren't inside a module.
SystemVerilog allows tasks, functions, and classes to be defined at the
root level or inside packages, so we can't rely on an enclosing module
being present to provide the timescale.
2016-07-22 22:48:20 +01:00
Martin Whitaker b8f9ed27c5 Fix for br1003 - prevent segfault when delays are used outside a module. 2016-07-21 08:40:45 +01:00
Cary R 45fbf55806 Add basic support for parameters using typedefs 2016-05-14 10:34:50 -07:00
Martin Whitaker 6ba2bee977 Fix for br974 - support SV types in non-ansi port declarations. 2016-04-04 20:40:30 +01:00
Martin Whitaker 9538c81d34 Add check for explicit lifetime when initialising static variables.
If a static variable declared in a task, function, or block has an
initialisation expression, SystemVerilog requires the declaration to
have an explicit static lifetime. This is supposed to be a compile
error, but for now just output a warning.

Implementing this required adding support in the parser for explicit
lifetimes in variable declarations. For now, just output an error if
the user asks for a lifetime that isn't the default for that scope.
2016-03-19 20:44:36 +00:00
Martin Whitaker 6e718c2e0c Added support for default subroutine lifetimes (SystemVerilog). 2016-03-19 17:27:27 +00:00
Martin Whitaker 635adfc01e Fully support variable initialization in tasks/functions/named blocks. 2016-03-19 13:04:38 +00:00
Cary R 3b7ebf6aa2 If ret is already defined then don't overwrite it. 2015-12-20 12:28:29 -08:00