Commit Graph

9970 Commits

Author SHA1 Message Date
Martin Whitaker 82516c28e2 Enforce rules for non-4-state wires (issue #1087)
When using the Icarus extension for wire types, only logic (4-state)
wires may have multiple drivers (as documented in extensions.rst).
Other types of wire should be treated as unresolved wires.

When the Icarus extension is disabled, only 4-state wires are
allowed (IEEE 1800-2017 section 6.7.1).
2024-01-28 14:14:10 +00:00
Martin Whitaker 18720fe060 Enable the sv_literals test, now that it is fixed (issue #1082) 2024-01-28 12:23:45 +00:00
Martin Whitaker f31d0dcbc5 Zero-extend unsized signed based literal numbers when < integer_width bits.
Whilst the wording in the IEEE standards is ambiguous, discussions on
the standards committee mailing lists clarify that an unsized literal is
supposed to be the same size as an integer (as shown in IEEE 1364-2005
table 5-22). The token following the base format character is specified
to be an unsized number. So to maintain compatibility with the standards
and with other tools, if the unsigned number part of an unsized signed
based literal can be represented in less than integer_width bits and the
MSB is a '1', we need to add a leading zero to ensure it is zero-extended
when used in an expression.

This fixes issue #1082.
2024-01-28 11:51:42 +00:00
Martin Whitaker 8ee1d56e1a Enable the sv_parameter_type test, now it is fixed (issue #1083) 2024-01-27 16:23:40 +00:00
Martin Whitaker fbb2d91927 Add regression tests for issue #1074. 2024-01-27 16:17:31 +00:00
Martin Whitaker ab275a0841 Set undriven bits to zero when only driving one part of a 2-state net.
Arguably this should be done in the target code generator, as the code
generator can infer the value for undriven bits from the net type. But
in practice it is quite hard to do this in the vvp code generator. So
adapt the cprop functor that concatenates part selects to do this as
well.

This fixes issue #1047 and issue #1083.
2024-01-27 15:42:14 +00:00
Martin Whitaker b037d6aef9 Fix cprop merging of part selects to be 2-state aware.
When driving a 2-state net, any undriven bits in the concatenation
of part selects should be driven to '0', not 'z'. This saves having
to cast the result.
2024-01-27 13:34:36 +00:00
Martin Whitaker d0af41442b Add a make_const_0() function to create an all-zero constant net.
Factor out the common code with make_const_x() and make_const_z().
2024-01-27 13:18:40 +00:00
Cary R 01e64861da
Merge pull request #1086 from flaviens/patch-1
Fix typo in README.md
2024-01-24 19:13:11 -08:00
Flavien Solt 9e48bab746
Fix typo in README.md 2024-01-24 16:54:18 +01:00
Stephen Williams 0db1a0cc67
Merge pull request #1085 from steveicarus/steveicarus/readmempath-tests
Move tests pr2509349a/b to the new test format.
2024-01-21 16:13:59 -08:00
Stephen Williams 71b9c551df Move tests pr2509349a/b to the new test format.
This removes the regress-msys2.list file, fixes the output from the
pr2509349a.v test to not be different on different systems, and
documents the $readmempath task.
2024-01-21 15:49:09 -08:00
Stephen Williams ed7cac914c
Merge pull request #1077 from steveicarus/steveicarus/remove-sv-regress
Remove the sv_regress.list file
2024-01-21 13:37:59 -08:00
Stephen Williams 5e97884ccd Remove the sv_regress.list file
This file contained some SystemVerilog tests that are not yet supported.
Move the tests to the regress-vvp.list format, and mark them as NI so
that we know what's going on.
2024-01-20 18:51:43 -08:00
Cary R 38058400f7 Update docs Copyright 2024-01-20 18:10:30 -08:00
Cary R dc047799d6 Update displayed Copyright 2024-01-20 17:52:04 -08:00
Cary R 099e04ec16 Update man page dates 2024-01-20 17:46:02 -08:00
Cary R 33edcda800 Ignore new ivtest output files in git 2024-01-20 17:44:59 -08:00
Cary R b3e5337260 Update fstapi.c file from GTKWAve 2024-01-20 17:44:51 -08:00
Cary R 5c9ec105d9 Fix some compile issues 2024-01-20 12:42:55 -08:00
Cary R d42f97ecbe Cleanup space issues 2024-01-20 11:26:06 -08:00
Cary R f781940444 Update files from GTKWave 2024-01-20 11:18:35 -08:00
Lars-Peter Clausen 6d1a9181bb
Merge pull request #1066 from larsclausen/vvp-concat-performance
vvp: Improve concat performance
2024-01-20 10:49:20 -08:00
Lars-Peter Clausen 5b509e69f6 vvp: concat: Defer update to end of the current simulation cycle
A concat typically has multiple inputs. Whenever one of the input values
change the output value of the concat is updated and propagated to its
downstream consumers.

When multiple inputs change within the same cycle each input will cause a
update propagation. Depending of the overall structure of the design this
can cause a significant performance penalty.

E.g. the following synthetic structure has a exponential runtime increase
based on the value of N.

```
reg [N-1:0] x;
generate for (genvar i = 0; i < N - 1; i++)
  assign x[i+1] = ^{x[i],x[i]};
endgenerate
```

To improve this defer the value propagation of the concat to the end of the
current cycle, this allows multiple input updates to be included in a
single output update.

For the example in report #1052 this reduced the runtime from 2 minutes to
essentially 0.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2024-01-20 10:32:55 -08:00
Lars-Peter Clausen 4637b39953 vvp: concat: Avoid using individual bit access
The concat functors use individual bit access to initialize and copy
values.

For initialization pass the initial bit value to the constructor and for
coping use set_vec() instead. Both can be a fair bit faster since data is
copied word by word rather than bit by bit.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2024-01-20 10:32:55 -08:00
Lars-Peter Clausen bb1d3c9ac6 vvp: Implement concat `recv_vec()` using `recv_vec_pv()`
The implementation for partial receive for concat only differs from the
regular receive in that it takes an additional offset.

The regular receive can easily be implemented by calling the partial
receive with an offset of 0. This allows to remove some duplicated code.

The overhead of this is negligible, but to help the compiler to optimize this
a bit better mark the `recv_vec()` and `recv_vec_pv()` functions as final.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2024-01-20 10:32:55 -08:00
Lars-Peter Clausen 2d611c4347 ivtest: pr1002: Avoid race condition
The pr1002 test has a always block with the `dataout` in its sensitivity
list. It compares `dataout` to `expected_dataout`.

Both `dataout` and `expected_dataout` depend on `datain` and are updated in
the same cycle. This means there is no guarantee in which order they are
updated and the always block might get scheduled before `expected_dataout`
has been updated. This can lead to a test failure.

To avoid this slightly change the test to use a task to perform the
comparison and add an explicit delay before the task is executed so that
all updates have a chance to be fully resolved

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2024-01-20 10:32:55 -08:00
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