Commit Graph

9943 Commits

Author SHA1 Message Date
Lars-Peter Clausen 9b1ac6ab50 ivtest: Fix `assign` vs `initial` race condition in some tests
The first evaluation of an `assign` statement is scheduled at the same time as
`initial` statements.

There are some test cases that evaluate the result of an `assign` statement
in an `initial` statement. This is an inherent race condition and might
fail depending on the exact order of evaluation.

To fix this add an additional delay in the `initial` block. This will make
sure that all `assign` statements get fully resolved first.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2024-01-20 10:32:02 -08:00
Stephen Williams 192b6aec96
Merge pull request #1070 from larsclausen/ivl_run-escape-char
run_ivl.py: Properly escape `.` in regex
2024-01-19 18:25:46 -08:00
Stephen Williams 8f1fcc988e
Merge pull request #1065 from steveicarus/vvp-undriven-net-initialisation
vvp undriven net initialisation
2024-01-19 18:13:55 -08:00
Lars-Peter Clausen 151a14dfcc
Merge pull request #1072 from larsclausen/iverilog-vpi-fix
iverilog-vpi.sh: Put `IVCXX` in quotes to allow to pass arguments
2024-01-17 05:32:00 -08:00
Lars-Peter Clausen 39daac0d40 iverilog-vpi.sh: Put `IVCXX` in quotes to allow to pass arguments
`IVCXX` which contains the C++ compiler that will be invoked when building
an vpi module might contain additional arguments that get passed to the
compiler. E.g. such as the C++ version (`-std=c++11`). For this to work
properly `IVCXX` needs to be put in quotes.

This fixes intermittent CI failures for the MacOS target.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2024-01-14 19:03:26 -08:00
Lars-Peter Clausen c93e8334a2 run_ivl.py: Properly escape `.` in regex
To escape the `.` in the regex it needs to be prefixed with a `\`. But
since the `\` is a escape character in python strings it needs to be
escaped as well.

Without this some versions of python print the following warning:

      run_ivl.py:36: SyntaxWarning: invalid escape sequence '\.'
        match= re.search(b'Icarus Verilog version ([0-9]+)\.([0-9]+)', text)

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2024-01-14 17:33:23 -08:00
Lars-Peter Clausen b1e602d27c
Merge pull request #1069 from larsclausen/pr1963962-sv-gold
ivtest: Remove outdated pr1963962 SystemVerilog mode gold file
2024-01-14 17:01:07 -08:00
gatk555 fc9fcb0bf8 Regression test for vvp scheduler fix.
This is for the latent bug exposed when testing the original fix for
issue #1041. Contributed by gatk555 in PR #1065.
2024-01-14 22:23:15 +00:00
gatk555 b128508841 vvp: enable main event queue before executing cbStartOfSimulation callbacks.
Before the start of simulation, functor update events resulting from
initial value propagation are added to the initialisation event queue
(schedule_init_list). Once simulation has started, they are added to
the main event queue (sched_list). The cbStartOfSimulation callbacks
are executed after the initialisation event queue has been emptied.
Currently, if these callbacks generate further functor update events,
those events are added to the initialisation event queue, but that
queue is not looked at again. Instead, make sure any new events are
added to the main event queue.

This issue and proposed fix was reported by gatk555 in PR #1065.
2024-01-14 22:12:52 +00:00
Lars-Peter Clausen 26d5cca784 ivtest: Remove outdated pr1963962 SystemVerilog mode gold file
Starting with commit 96df251c95 ("Suppress unnecessary VCD/LXT/LXT2
warnings about packages.") there is no longer a warning printed that the
unit scope can't be printed if it is empty.

Remove the special SystemVerilog mode gold file for the pr1963962 test that
expects this warning.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2024-01-13 19:07:44 -08:00
Lars-Peter Clausen 155ed084b0
Merge pull request #1067 from larsclausen/vvp_part_state_remove_bitsr
vvp: Remove bitsr from struct vvp_fun_part_state_s
2024-01-07 17:55:17 -08:00
Lars-Peter Clausen 9853a5904c vvp: Remove bitsr from struct vvp_fun_part_state_s
The part functor has no real typed state and the bitsr field of the state
struct is unused. Remove it.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2024-01-07 17:38:33 -08:00
Martin Whitaker 7b99cd25ca Add regression tests for suppressed VCD/LXT/LXT2 warnings (issue #710) 2024-01-07 20:34:45 +00:00
Martin Whitaker 96df251c95 Suppress unnecessary VCD/LXT/LXT2 warnings about packages.
Only output a warning if a package contains dumpable items. This is
mainly to avoid the warning about the $unit scope when a design has
been compiled for a SV generation (issue #710).
2024-01-07 20:16:49 +00:00
Martin Whitaker fa2dfe690c Add regression test for synthesisable for loop check (issue #687) 2024-01-07 13:23:36 +00:00
Martin Whitaker 974d2b87ae Improve check for synthesisable for loop.
The condition expression may require the loop variable width to be
expanded. The compiler wraps the NetESignal with a NetESelect to
do this, so we need to handle that when checking that the condition
expression uses the loop variable.

Fixes issue #687 and issue #1004.
2024-01-07 13:14:48 +00:00
Martin Whitaker a9eed015c3 Add regression test for undriven net initialisation (issue #1041). 2024-01-07 09:34:50 +00:00
Martin Whitaker 435c9797b2 vvp: execute undriven net initialisation before time 0.
This ensures the initialisation is done before a VPI cbStartOfSimulation
callback is executed (issue #1041).
2024-01-07 09:34:44 +00:00
Martin Whitaker 94b443a7fe tgt-vvp: inform vvp about undriven constant values.
This causes tgt-vvp to use a lower case 'c' instead of an upper case
'C' as the prefix for constant values used to initialise undriven nets.

For use by the following commit.
2024-01-07 09:34:36 +00:00
Cary R af92bef64f
Merge pull request #1063 from larsclausen/vvp_net_ptr_t-default-destructor
vvp: Reduce overhead of passing vvp_net_ptr_t between functions
2024-01-06 22:14:41 -08:00
Cary R c53b1c0101
Merge pull request #1062 from larsclausen/replicate-for-concat-repeat
Use NetReplicate to implement replication for concat
2024-01-06 22:13:31 -08:00
Lars-Peter Clausen ddcac42b5f vvp: Reduce overhead of passing vvp_net_ptr_t between functions
vvp_net_ptr_t uses vvp_sub_pointer_t to implement a tagged pointer with the
tag containing the port number.

The size of the tagged pointer is that of a normal pointer and could easily
be passed in a register when passing it as an argument to a function.

But since the vvp_sub_pointer_t type has a non-standard destructor it is
instead passed on the stack with the register containing a pointer to the
stack location where the value is stored.

This creates extra boiler plate code when passing a vvp_net_ptr_t to a
function writing and reading the value to and from the stack.

Use the default destructor for vvp_sub_pointer_t to avoid this and have the
value passed in a register.

There isn't much of a performance gain but the change is simple enough to
do anyway.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2024-01-06 20:26:42 -08:00
Lars-Peter Clausen 2d22f43ba7 Use NetReplicate to implement replication for concat
Currently replication in a concatenation is implemented by simply
concatenating the input signals multiple times by the replication amount.

Replace this to use NetReplicate on the concatenation instead. In case
there is only one input vector to the concatenation the replication will directly
connect to the input vector.

This is slightly more efficient in vvp since the replication functor has
only one input while the concatenation has multiple inputs connected to the
same wire. When an update of the input occurs the replication functor will
only receive a single update, while the concatenation will receive multiple
update events, one for each replication.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2024-01-06 19:33:51 -08:00
Lars-Peter Clausen 60864ff1c7 vvp: repeat: Implement partial vector receive
The repeat functor can receive a partial vector. Make sure this is handled.
Since the expectation is that will only happen if the input wire is driven
by a single partial selection the default recv_vec4_pv_() can be used which
replaces the missing bits by `z`.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2024-01-06 19:33:41 -08:00
Cary R 7c25e8506c
Merge pull request #1060 from larsclausen/ident-test-width
Correctly calculate width of nested path identifiers
2024-01-01 12:26:51 -08:00
Cary R 1712b2e8e8
Merge pull request #1059 from larsclausen/invalid-partsel
Detect reversed part select on inner dimensions
2024-01-01 12:25:07 -08:00
Cary R cec7a6452f
Merge pull request #1014 from proppy/add-array-test
ivtest: add array_slice_concat
2024-01-01 11:21:21 -08:00
Cary R 724a88f523
Update array_slice_concat.v
Add delay to avoid race in TB code and DUT code
2024-01-01 11:01:19 -08:00
Lars-Peter Clausen 9a563e9bab Add regression test for nested struct width
Check that expression width is correctly calculated for nested structs.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-12-30 18:30:24 -08:00
Lars-Peter Clausen ca69665b88 Correctly calculate width of nested path identifiers
The current `PEIdent::test_width()` method is only able to calculate width
of a path with up to two elements.

For more complex paths it will not be able to calculate the width. E.g.
 * Nested struct member access
 * function call of a enum member in a struct

To make nested structures work properly walk the whole path tail element
by element updating the type along the way. Also take the indices into
account and update the type if an arrays dimensions have been fully
consumed.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-12-30 18:30:24 -08:00
Johan Euphrosine 0a53b52ed0 ivtest/regress-vvp: add array_slice_concat 2023-12-30 10:57:24 +09:00
Johan Euphrosine 2e00a7d482 ivtests/array_slice_contact: add test manifest 2023-12-30 10:57:24 +09:00
Johan Euphrosine 0b22810a25 ivtests/array_slice_contact: add tb 2023-12-30 10:57:24 +09:00
Johan Euphrosine fbbff9646d ivtest: add array_slice_concat 2023-12-30 10:57:24 +09:00
Lars-Peter Clausen 57f8084d0c Add regression tests for reversed part select indices
Check that reversed part selects result in an error. Check this for both
right-hand and left-hand side expressions as well as for inner and outer
dimensions.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-12-29 16:34:46 -08:00
Lars-Peter Clausen 131e64c53c Detect reversed part select on inner dimensions
The order of the indices of a part select need to match the order in which
the dimension of a packed array has been declared. E.g. if the msb is less
than the lsb in the declaration it also has to be for the part select.

If the order of the part select is the opposite of the declaration this is
an error. This works as expected for part selects on the most outer
dimensions.

But for inner dimensions the current implementation just swaps the msb and
lsb of the part select if they are in the wrong order.

Refactor this so that an error is reported for both the outer and inner
dimensions.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-12-29 16:34:46 -08:00
Lars-Peter Clausen 9a0ce046c7
Merge pull request #1057 from larsclausen/fix-net-array
vvp: Don't schedule initial value propagation for net array ports
2023-12-28 20:18:16 -08:00
Lars-Peter Clausen 90880e86ad vvp: Don't schedule initial value propagation for net array ports
An initial value propagation should only be scheduled for variable array
ports, but not for net array port since those do not contain any values.

This got accidentally broken when fixing support for 2-state variable
array ports.

Add a check that only does the initial value propagation if the port is for
a variable array.

Fixes: 0eb01fff1e ("vvp: Fix initial value propagation for 2-state non-automatic arrays")
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-12-28 20:04:01 -08:00
Cary R b4b8006460 vpiFullname of a package should have a "::" after the name 2023-12-28 18:53:11 -08:00
Cary R 4251ea9553 Remove old V0.8 code in VPI tests 2023-12-28 16:02:47 -08:00
Cary R 1471e7d53d MModule elab should check elab tasks first 2023-12-28 15:26:59 -08:00
Cary R cc829031ff Elaborate system elab tasks in gen blocks 2023-12-28 15:07:37 -08:00
Lars-Peter Clausen 7fb1cabdbb
Merge pull request #1055 from larsclausen/invalid-index-base
Handle invalid vector slice base expressions
2023-12-28 13:38:28 -08:00
Cary R b14c4ca26c add suport for the shortreal conversion functions 2023-12-28 13:30:27 -08:00
Lars-Peter Clausen 8f006a22b4 Add regression tests for invalid part select base expressions
Check that a invalid part select base expression results in a compile
error.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-12-28 13:21:37 -08:00
Lars-Peter Clausen e7e663056a Handle invalid vector slice base expressions
The elaboration of the base expression of a vector slice index can fail and
return a nullptr. Currently this results in a nullptr deref. Handle that
case by exiting the function early.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-12-28 13:21:37 -08:00
Stephen Williams bc119f96a9
Merge pull request #1054 from larsclausen/fix-run_ivl_py
Fix run_ivl.py
2023-12-28 13:17:08 -08:00
Cary R 91b1759602 More test version cleanup 2023-12-28 12:14:44 -08:00
Cary R 57524836f1 Fix space issues 2023-12-28 11:21:09 -08:00
Cary R 691eeeef99 Update fstpi.c to the latest version from GTKWave 2023-12-28 11:20:31 -08:00