Commit Graph

10055 Commits

Author SHA1 Message Date
Martin Whitaker c0e9b73d1c vvp: Allocate time structures for cbNextSimTime and cbEndOfSimulation.
Previously they were reusing the pointer supplied when the callback
was registered, which is not guaranteed to still be valid.

Note that the IEEE standard states:

    The only fields in the s_cb_data structure that shall need to
    be set up for simulation action or feature callbacks are the
    reason, cb_rtn, and user_data (if desired) fields.

so for cbEndOfSimulation callbacks we cannot rely on the time pointer
being either valid or null. The standard does not require that the
time structure should be filled in when the callback occurs, but for
backwards compatibility continue to do so, returning a vpiSimTime
value.
2024-02-05 17:51:27 +00:00
Cary R 2948e9a89f Update cppcheck to use c++11 2024-02-05 02:21:24 -08:00
Martin Whitaker d364c5e903 Fix indentation and white space. 2024-02-05 08:51:30 +00:00
Jevin Sweval 53e8a139b0 VPI cbNextSimTime: Fill out time and don't call newly generated CBs
Fill out cb_data.time and require it is non-NULL.

Record the last NextSimTime CB so we don't call CBs added during this timestep.

(cherry picked from PR #740)
2024-02-05 08:33:12 +00:00
Martin Whitaker 2299fc1b2b Add regression tests for mixed procedural/continuous assignments. 2024-02-03 22:24:22 +00:00
Martin Whitaker 53b8220b9f Add extra regression tests for multiple drivers on uwires. 2024-02-03 22:23:45 +00:00
Martin Whitaker dd082b849b Improve error message for non-constant bit select in mixed assignment.
Report the conflict with the continuous assignment as the reason this
is not allowed.
2024-02-03 21:58:25 +00:00
Martin Whitaker 3a2a1fb93d Check for mixed assignment conflicts in procedural indexed part selects. 2024-02-03 21:16:57 +00:00
Martin Whitaker d4759e02aa Allow multiple procedural assignents to same part of mixed-mode variables.
If we have a variable which is part driven by a continuous assignment,
the parts that are not driven by that assignment can be the target of
more than one procedural assignment. So we need to only test the cassign
mask, not test and set it, when elaborating the procedural assignments.
2024-02-03 21:12:05 +00:00
Martin Whitaker abb9959339 Factor out code for reporting mixed assignment conflicts.
This makes the error reporting uniform.
2024-02-03 20:24:22 +00:00
Martin Whitaker 9faf8d6b09 Ignore force statements when checking for mixed assignment conflicts.
This was already done in some places. Do it everywhere.
2024-02-03 19:23:15 +00:00
Martin Whitaker 89bb86962f Allow mixed procedural/continuous assignment for array words.
This is legal if the procedural and continuous assignments target
different words.

NOTE: This is not fully compliant with the standard, because vvp
does not know that the nets were originally declared as variables,
so initialises to 'bz instead of 'bx and does not handle release
correctly.
2024-02-03 17:55:32 +00:00
Martin Whitaker cd2d4e9287 Improve error messages when multiple drivers are detected.
Distinguish between nets declared as uwires and variables.
2024-02-03 17:13:53 +00:00
Martin Whitaker 65f552aba3 Mark all words as driven when assigning to an entire uwire array.
This is needed to catch errors if individual words are also separately
driven.
2024-02-03 17:12:08 +00:00
Martin Whitaker 42c5174c8d Improve error messages for mixed procedural/continuous assignments.
We have already eliminated procedural assignments to uwires, so if
we find a l-value of type UNRESOLVED_WIRE, it must be a variable
that has a continuous assignment. Report it as such.
2024-02-03 17:08:44 +00:00
Martin Whitaker 11fc90faf7 Catch procedural assignments to uwires earlier in elaboration.
A uwire is never a valid l-value for a procedural assignment (other
than a force/release), so catch that error as soon as we can. We
then know that any remaining l-values with type UNRESOLVED_WIRE must
be variables which have been coerced by a continuous assignment.
2024-02-03 16:57:36 +00:00
Martin Whitaker a133ae5d9a Add check that entire array isn't both procedurally and continuously assigned.
This fixes issue #1090.
2024-02-03 16:19:22 +00:00
Martin Whitaker 73897b2af6 Refactor code to reduce indentation level.
In preparation for next commit. No functional change.
2024-02-02 22:30:17 +00:00
Martin Whitaker 4667927377 Add flag to NetNet class to indicate a variable has been converted to a uwire.
Internally we convert SystemVerilog variables that have a continuous
assignment into unresolved wires. But from a user's perspective they
are still variables, so we should refer to them as such in error
messages. This new flag lets us distinguish between such variables
and nets that were declared as uwires.
2024-02-02 22:00:57 +00:00
Martin Whitaker 5e139890b6 Add regression test for connecting module output port to array variable (issue #1001). 2024-01-30 23:31:56 +00:00
Martin Whitaker c9d87abc10 Convert unpacked array variable to net when connected to a module output port.
SystemVerilog allows variables to be driven by continuous assignments,
including port connections. Internally we handle this by converting
the NetNet from a REG to an UNRESOLVED_WIRE. Here we handle the case
of an unpacked array variable connected to a module output port.

This fixes issue #1001.
2024-01-30 23:18:03 +00:00
Martin Whitaker 836a9f675e Remove reference to the wiki in the iverilog man page.
The wiki is now obsolete. Use the new documentation site instead.
2024-01-28 23:46:21 +00:00
Martin Whitaker 18a5050c05 Update supported targets in the iverilog man page.
The fpga and vhdl targets are no longer maintained, and the fpga
target is no longer built by default. So best not to advertise
them.
2024-01-28 23:42:11 +00:00
Martin Whitaker e1ba2632d4 Document the -gicarus-misc option in the iverilog man page. 2024-01-28 23:05:21 +00:00
Martin Whitaker 39753da458 Add regression test for disabling binary NAND and NOR operators. 2024-01-28 22:47:46 +00:00
Martin Whitaker 2a2fa059e2 Enable binary NAND and NOR operators with -gicarus-misc (issue #552).
These operators are an Icarus Verilog extension.

Currently -gicarus-misc is enabled by default, so most users won't
see a difference.
2024-01-28 22:41:16 +00:00
Martin Whitaker 6826dbb9cb Fix the pr2966059 regression test.
This test uses 'wire real' but specified the '-gno-xtypes' option.
This is because it named a variable 'wreal' which is a keyword when
that option is enabled.
2024-01-28 19:03:32 +00:00
Martin Whitaker 79c644f550 Update and correct documentation of extended data types (xtypes). 2024-01-28 18:23:29 +00:00
Martin Whitaker 9cccd35e59 Move Icarus Verilog extensions documentation to the usage section.
Also fix the text in the usage section index.
2024-01-28 17:44:23 +00:00
Martin Whitaker 81d7abaf88 Add regression tests for checking wire data types (issue 1087). 2024-01-28 15:53:47 +00:00
Martin Whitaker a8144fd249 Require -gxtypes to use the Icarus extension for wire data types.
e.g. wire bool [1:0]; wire real;

Currently xtypes is enabled by default, so most users won't see a
difference.
2024-01-28 15:48:38 +00:00
Martin Whitaker 56f457d65e Allow force assignments on unresolved wire array words.
A force doesn't require resolution. We already allow this for
individual unresolved wires.
2024-01-28 14:33:17 +00:00
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
ga 95810b2f61 Configure with --enable-libvvp builds a shared library containing
almost all of vvp that may be used by other programs.
The vvp program becomes a small client of libvvp.
2024-01-24 11:46:02 +00:00
ga e6ea9bee83 Restore main.cc, completing copy of main.cc to lib_main.cc. 2024-01-24 10:33:40 +00:00
ga 400bda8bed Copy main.cc to lib_main.cc to prepare for libvvp.so.
To examine older history use "git log --follow lib_main.cc".
2024-01-24 10:31:13 +00: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