Commit Graph

715 Commits

Author SHA1 Message Date
Lars-Peter Clausen ad23b08a10 Constify scope reference in NetEConstParam and NetECRealParam
Parameter expressions need to remember the scope they have been declared in
so that the code generator backends can insert the right parameter
reference, rather than a constant value.

Currently the scope is stored as a non-const reference. But that is not
needed. Mark the scope reference as const so NetEConstParam and
NetECRealParam can be created when only a const scope reference is
available.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-19 13:00:12 +01:00
Lars-Peter Clausen 892622bf64 Add helper function to get parameter line info
The NetScope class has a method called find_parameter() that looks up the
parameter and returns a iterator to it. This is only ever used to get the
line information of the parameter.

Refactor the function so that it only returns the line info. This will
allow to call this function on a const NetScope object.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-19 12:52:19 +01:00
Lars-Peter Clausen 9f5ad34e35 Track whether a parameter is overridable
Parameters declared in certain scopes behave like local parameters and can
not be overridden. Rather than making those parameters a localparam track
whether a parameter can be overridden.

This allows to generate better error messages when trying to override the
parameter.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-10 11:37:34 +01:00
Lars-Peter Clausen 0ab1ed916f Report error when trying to override non-existing parameter
Overriding a parameter that does not exist will only generate a warning at
the moment. This can hide programming mistakes such as an typo in a
parameter override.

There is nothing in the LRMs to support that this should only be warning,
so elevate this to an error. This is consistent with how an error is
generated when trying to reference a non-existing port or variable.

The generated error message differentiates between whether the parameter
does not exist at all, or whether it is a localparam.

There are two regression tests that rely on that only a warning is
generated, these have been updated to expect an error.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-01 22:50:21 +01:00
Lars-Peter Clausen 9b7c99b8a8 NetEConstEnum: Remove unused scope_ field
The scope_ field of the NetEConstEnum class is initialized in the
constructor, but never used anywhere again. Remove it.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-01-17 20:21:28 +01:00
Martin Whitaker ecbbb60fb6 Remove "using namespace std" from compiler header files and fix the fallout. 2021-11-04 16:55:03 +00:00
Martin Whitaker a17557575d Include typedefs in checks for name collisions.
This requires us to make a copy of the typedefs map when adding it to
a NetScope object, because the pform data is deleted before we are
finished with it.
2021-08-04 14:00:33 +01:00
Martin Whitaker 7445b424f1 Avoid name collisions when naming unnamed generate blocks.
As specified in the IEEE standard, the automatically generated name
must not conflict with any explicitly declared name (not just scope
names).
2021-08-04 12:07:52 +01:00
Cary R 60a77b08d2 Add compiler and the start of vvp support for ->> 2021-02-19 23:21:51 -08:00
Cary R 32787bb973 Add support for SV edge 2021-01-07 01:22:49 -08:00
Cary R da7484eea1 Update compiler with suggestions from cppcheck 2021-01-02 14:04:46 -08:00
Stephen Williams a286764c1d Add support for string parameters
Parameters can have string type and do the usual string stuff,
and also implement some of the string methods on string parameters
so that they evaluate down to constants.
2020-12-27 21:17:57 -08:00
Stephen Williams 16646c547c Rework parsing of parameter types
Use the common data_type_or_implicit rules to support type
definitions for parameters. This eliminates a bunch of special
rules in parse.y, and opens the door for parameters having
more complex types.
2020-12-27 21:17:57 -08:00
Martin Whitaker a019994513 Fix search for class imported from another package (issue #437). 2020-12-23 19:16:14 +00:00
Stephen Williams e5f68d7c89 Handle dynamic queue objects in event context
In the rare cases where DARRAY signals are in the network, handle
them by creating the proper ivl_nexus_t node. This also implements
the receive of vvp_object_t objects bu vvp_fun_anyedge_sa. This
together makes it possible for IVL_VT_DQUEUE objects to be in
wait lists.

This fixes #412
2020-12-13 18:22:34 -08:00
Martin Whitaker 0fada92389 Fix expression type for packed struct member access (GitHub issue #386)
A NetESelect is used for accessing packed struct members and also for
accessing dynamic array elements. In these cases the expr_type() and
enumeration() methods should reflect the member/element type.
2020-11-20 16:50:11 +00:00
Martin Whitaker bd0133b386 Fix GitHub issue #361 - explicit cast check on function return value.
A function call returning an enumeration value can be assigned to an
enumeration variable without an explict cast.
2020-08-14 12:30:05 +01:00
Cary R dd80607ceb Add CA version of the <-> operator 2020-07-09 01:45:43 -07:00
Cary R c003bcc59a Add support for <-> in constant and procedural contexts 2020-07-07 23:29:19 -07:00
Martin Whitaker 3f49dfcd97 Fix translation of module path connection type in vlog95 target.
The target API needed to be changed to pass the connection type
through to the target code generator.
2020-04-02 12:40:59 +01: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 82c8a49573 Fix for issue #281 - the condition operator may return a valid enum type.
If the condition expression is 2-state, the result won't be blended, so
the result will be a valid enum value if both true and false expressions
return the same enum type.
2019-11-09 13:11:16 +00:00
Stephen Williams 7feb26ff6b Cleaner elaboration of void functions.
This fixed githun issue # 281.
2019-11-07 14:25:51 -08:00
Martin Whitaker 16e8563c6e Fix for GitHub issue #277 - incorrect sensitivity calculation.
The fix for the compiler hang when calculating the sensitivity list
for an always_comb construct containing recursive function calls
could cause the compiler to ignore sequential calls to the same
function, and thus not add the arguments of those calls to the
sensitivity list.
2019-10-28 21:01:42 +00:00
Martin Whitaker 1069a0ef02 Don't evaluate built-in system functions if they are overridden.
We don't support evaluating user-defined system functions at compile
time. If possible, defer evaluation until run time. If used in a
constant expression, output a "sorry" message.
2019-10-19 16:12:17 +01:00
Stephen Williams befc91340c Parse and elaborate unique and priority case statements
The unique, unique0, and priority keywords can decorate case statements
to tell the run time (or synthesis) to do extra tests (or make extra
assumptions). These tests are not implemented in the vvp run time, but
now the decorations make it to the code generators.
2019-10-05 16:23:04 -07:00
Martin Whitaker f69eccf903 Merge remote-tracking branch 'origin/master' into package-imports-rework 2019-10-01 09:06:15 +01:00
Cary R ba82ef463e Fix some always_* issues 2019-09-29 16:59:59 -07:00
Martin Whitaker 55219773fd Allow nested scopes to use their parent's imports. 2019-09-27 22:19:30 +01:00
Cary R e6f957b0b6 Add support for a constant $countbits() function 2018-09-03 15:58:57 -07:00
Cary R 1da9b2cea0 Add support for constant $countones, $isunknown, $onehot, $onehot0 2018-09-03 08:32:41 -07:00
Cary R 932241ee87 Check system/user tasks for always_comb/ff/latch synth. 2017-12-27 23:08:32 -08:00
Cary R 2bbd077dc9 Add some synthesis checks for the always_comb/ff/latch blocks 2017-12-27 14:51:17 -08:00
Cary R f17992bcd0 Report the lines that have delay or event control in an always_comb/ff/latch process 2017-12-06 00:22:43 -08:00
Cary R cb0ffd734e Check to see that always_comb/ff/latch do not have delays/events 2017-12-05 22:10:43 -08:00
Cary R 84d0df8a8a Pass to the targets if an implicit T0 trigger event is needed. 2017-12-03 20:17:42 -08:00
Cary R 585a0232cb Add preliminary support for always_comb, always_ff and always_latch 2017-11-20 07:50:05 -08:00
Cary R 3fc9ad2db0 Add support for the wild compare operators ==? and !=? 2017-11-17 19:32:50 -08:00
Martin Whitaker d1487c10f1 Fix shadow warning when using older versions of gcc. 2017-11-08 21:23:22 +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
Cary R 7d78f5b2ea A few updates based on cppcheck results 2017-10-23 00:22:01 -07:00
Henry Wong 1f9bf656ed Adding implementation of NetEvWait::nex_input to handle event controls inside always@(*) blocks 2016-10-20 16:19:55 +01:00
Michele Castellana 9ad46044b4 Cleanup 2016-06-30 17:47:34 +02:00
Larry Doolittle 89edf62206 Capitalize Verilog in a few places 2016-04-01 11:02:24 -07:00
Martin Whitaker 635adfc01e Fully support variable initialization in tasks/functions/named blocks. 2016-03-19 13:04:38 +00:00
Stephen Williams 78a49eacef Merge branch 'master' of github.com:steveicarus/iverilog 2016-03-14 12:26:12 -07:00
Larry Doolittle 1784488096 Spelling and whitespace 2016-03-14 12:25:50 -07:00
Johann Klammer c92b630728 NetLatch class 2016-03-11 23:11:54 +00:00
Martin Whitaker 9d5f4ad048 Add new synthsplit functor.
This provides support for handling synthesis constructs in the vlog95
target.
2016-02-27 16:40:55 +00:00
Martin Whitaker 0199ad129d Fix expression type for compressed assignment statements.
A compressed assignment statement should give exactly the same
result as the equivalent uncompressed statement. This means
that the type (signed/unsigned) of the LHS affects the type of
the RHS expression (unlike in normal assignments). We need to
take care that bit/part selects and concatenations are correctly
identified as unsigned values, even in the cases where they
reduce to a single whole signal.
2016-02-23 16:53:01 +00:00