Commit Graph

10032 Commits

Author SHA1 Message Date
Martin Whitaker fc29e51e41 Fix synthesis of signal and part select to keep signed/unsigned type.
If a signal has been cast to a different type, synthesis needs to
reflect the expression type, not the base signal type.

If a part select selects the entire signal, unless otherwise cast,
the expression is unsigned, regardless of the base signal type.

This fixes the additional issues reported in issue #1099.
2024-02-25 21:48:39 +00:00
Martin Whitaker 3624a54f7f Add regression test for issue #1104. 2024-02-24 13:36:25 +00:00
Martin Whitaker 2799799358 Make compiler return non-zero exit code when include file not found.
Most pre-processor errors are flagged to the main compiler by a comment
at the end of the pre-processed output. But certain errors, such as
failing to find or open an include file, cause the pre-processor to
exit immediately, which bypassed the generation of that comment. So
we need to also generate that comment for all early-exit cases.

This fixes issue #1104.
2024-02-24 13:30:27 +00:00
Martin Whitaker 0679d7c8cf Add regression test for issue #1099 2024-02-24 11:49:46 +00:00
Martin Whitaker 09a134d973 Fix synthesis of concatentation to always make result unsigned.
When there is only one operand, we elide the concatenation during
expression synthesis. But if that operand is signed, we need to
insert an intermediate local signel to cast it to unsigned.

This fixes issue #1099.
2024-02-24 11:39:22 +00:00
Cary R 61943c844d
Merge pull request #1068 from gatk555/libvvp
Configure option --enable-libvvp allows vvp to be used a shared library
2024-02-18 11:33:44 -08:00
Martin Whitaker ccf925a4f7 Remove the legacy version of symbol_search(). 2024-02-18 09:36:23 +00:00
martinwhitaker 202d41a60c
Merge pull request #1098 from steveicarus/vpi-callback-improvements
VPI callback improvements
2024-02-12 17:42:45 +00:00
Martin Whitaker 72e86d396c Add regression test for issue #703. 2024-02-09 22:38:32 +00:00
Martin Whitaker 855dd3a7e6 Fix new GCC warning when building ivlpp.
Using the old buffer pointer value after a realloc to adjust the pointers
into that buffer is technically undefined behaviour.
2024-02-09 11:52:38 +00:00
Martin Whitaker 616afdc4e7 Fix and improve sim_time_cb test.
cb_data.obj must be set to a valid handle when requesting vpiScaledRealTime.

Check the returned time value as well as the actual callback time. Zero
the requested cb_data after registering the callbacks to make sure it
is not used during the callback execution.
2024-02-09 11:07:08 +00:00
ga 9844212649 Add a check that an instance of libvvp is used only once. 2024-02-07 19:17:32 +00:00
Martin Whitaker 851aed6272 Rationalise new VPI callback test names. 2024-02-07 00:02:58 +00:00
Martin Whitaker 3433c92742 Add regression tests for VPI simulation time callbacks with both time types. 2024-02-06 23:42:12 +00:00
Martin Whitaker 8e754d180e vvp: Add support for vpiScaledRealTime in VPI simulation time callbacks.
Factor out the common code for the four different sync callback types
and extend it.
2024-02-06 23:35:05 +00:00
Martin Whitaker c363231b9c vvp: Add support for value change callback on 2-state array word. 2024-02-06 22:04:23 +00:00
Martin Whitaker 8b357d670d vvp: Comprehensively check the time type passed to vpi_register_cb.
NOTE: This removes the ability to request vpiSuppressTime for the
simulation time callbacks (other than cbNextSimTime). Requesting
this is clearly stated to be an error in IEEE 1364-2001 onwards.
2024-02-06 20:08:10 +00:00
Martin Whitaker ad400ac468 vvp: Remove restriction on time types for cbNextSimTime.
IEEE 1364-1995 has different wording to later versions of the standard,
stating "For reason cbNextSimTime, the time structure is ignored." So
it's possible old VPI code might not pass a valid time pointer or time
structure. So remove the checks that the time pointer is non-null and
that the time type is not vpiSuppressTime.

To allow a user to select the time type, we have to assume that if
the time pointer is non-null, it is a valid pointer and not just an
uninitialised field.
2024-02-06 18:47:54 +00:00
Martin Whitaker 9d04809280 libveriuser: Fix calls to vpi_register_cb that had invalid time types.
When registering a cbReadWriteSynch or cbReadOnlySynch callback,
the time type must be either vpiSimTime or vpiScaledRealTime.
vpiSuppressTime is illegal. The required behaviour is a delay of
zero, so use vpiSimTime with the high and low fields set to 0.
2024-02-06 18:12:32 +00:00
Martin Whitaker 5c1ca6eb93 Extend the VPI value change callback tests.
Cover the vpiSuppressTime and null time pointer cases.
2024-02-06 09:04:13 +00:00
Martin Whitaker 1d793ddba8 vvp: Fix time scaling when using vpiScaledRealTime in VPI callbacks.
The old code only worked for VPI objects that represented variables
and nets. For simulation time callbacks, the user might pass an
object that represents a scope.
2024-02-05 23:24:45 +00:00
Martin Whitaker f3f2dddf9a vvp: Factor out and extend code for finding timescale scope for a VPI object. 2024-02-05 23:23:12 +00:00
Martin Whitaker 872fcd13ae vvp: Factor out code to scale time using the timescale of a VPI object. 2024-02-05 23:21:19 +00:00
Martin Whitaker 0c61923636 Add regression tests for VPI value change callback with time reporting. 2024-02-05 22:04:29 +00:00
Martin Whitaker bb0502a827 vvp: Factor out common code for returning the time of a VPI callback.
This adds support for vpiScaledRealTime in various callbacks where it
wasn't previously supported. However this doesn't work properly when
the cb_data.obj field references a scope handle.
2024-02-05 19:41:23 +00:00
Martin Whitaker 5d40f6ecb2 Restructure and simplify the nextsimtime VPI tests.
Add support for properly testing the vpiScaledRealTime time type for
when it's implemented.
2024-02-05 18:17:53 +00:00
Martin Whitaker cae337231c vvp: Optimise the code for walking the NextSimTime callback list. 2024-02-05 17:53:01 +00:00
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