Commit Graph

366 Commits

Author SHA1 Message Date
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
Stephen Williams 8803eb3288 Handle numeric literals with no digits. 2015-09-22 16:15:41 -07:00
Martin Whitaker 027e060865 Fix for br992 - prevent assertion/crash on declarations outside a module.
parse.y has been updated to allow declarations outside a module (legal
in SystemVerilog), but not all types of declaration are supported yet.
Output a sorry or error message as appropriate.
2015-08-21 00:02:42 +01:00
Larry Doolittle 29478eba4c Squelch just a few trailing spaces in source code 2015-08-17 11:44:45 -07:00
Martin Whitaker 428f059c58 Fix shadow warning introduced by MVSE 2015 hacks. 2015-08-07 23:05:02 +01:00
Frederick C. Kurz fc976bdb97 Changes for pform.cc
First area of Change for "Microsoft Visual Studio Express 2015 RC Web" was for compiling with error when NDEBUG defined.  The second and third areas of change for "Microsoft Visual Studio Express 2015 RC Web", the dynamic_cast has to come first so parpkg_test.v, parpkg_test1.v, parpkg_test2.v would pass.
2015-07-22 09:22:26 -07:00
Martin Whitaker 4068c172f4 Fix overzealous detection of duplicate net/variable declarations.
As reported by Larry Doolittle on iverilog-devel.
2015-06-07 08:48:33 +01:00
Martin Whitaker 578a2543f7 Fix for br975 - assertion failure due to duplicate declaration of struct var.
Added proper error handling for duplicate declarations of all variable
types.
2015-05-17 20:54:53 +01:00
Martin Whitaker c6e618350d Fix for GitHub issue #60 (part 1) - reject numeric constant with zero size. 2015-04-26 11:04:02 +01:00
Maciej Suminski 46c41f9be2 ivl: Enum type can be used in port declarations. 2015-02-05 17:17:33 +01:00
Maciej Suminski bcca3cf395 ivl: Unpacked array typedefs are correctly recognized when used in function parameters. 2015-02-04 15:58:12 +01:00
Maciej Suminski b6e16aea6b ivl: Typedefs may use unpacked arrays. 2015-01-12 11:08:31 +01:00
Martin Whitaker bca84d9dbb Added parser support for SV modport declarations. 2015-01-10 11:10:41 +00:00
Martin Whitaker b400532169 Added support for interface declaration and instantiation.
modport and extern tf declarations are not yet supported.
2014-12-19 23:10:14 +00:00
Stephen Williams 8fd1ead082 Revert "ivl: Allow to initialize variables with other variables (since Verilog-2001)."
This reverts commit 610ca95cbe.
It turns out that the new feature is actually a bug.
2014-12-03 08:27:01 -08:00
Maciej Suminski 610ca95cbe ivl: Allow to initialize variables with other variables (since Verilog-2001). 2014-11-27 17:36:23 +01:00
Cary R 632e15a55c Catch enumerations with the same name. 2014-10-31 20:06:28 -07:00
Cary R c25538d750 Pass the integer type for enumerations to the IVL target stage 2014-10-31 18:09:19 -07:00
Stephen Williams 23238aa7ac Handle functions in $root scope. 2014-10-02 15:04:14 -07:00
Stephen Williams c5fee8bdb9 Elaborate root tasks/functions. 2014-09-30 16:06:32 -07:00
Stephen Williams fa21527e9f Classes in $root scope up to elaboration. 2014-09-15 17:37:30 -07:00
Stephen Williams 853512868b Merge branch 'x-mil15' 2014-09-08 21:10:14 -07:00
Cary R ec2793c9b0 Warn that classes defined in the compilation unit scope are not supported 2014-09-08 16:59:18 -07:00
Stephen Williams 9fa764285a foreach multiple indices through the pform. 2014-08-30 10:18:57 -07:00
Maciej Suminski a67f18f8ef ivl: Do not delete range objects right after setting range for a net. 2014-08-28 10:02:56 +02:00
Stephen Williams 5de83906f7 Sorry message for multi-dimension foreach loop indices. 2014-08-21 20:34:55 -07:00
Stephen Williams f602ae84ab Elaborate foreach loops as synthetic for loops.
Create an implicit scope to hold the index variable, and
generate a for loop to perform the functionality of the
foreach.
2014-08-21 16:44:46 -07:00