Commit Graph

10111 Commits

Author SHA1 Message Date
Martin Whitaker 5cbdff202e Add regression tests for checking constant function call scopes. 2024-06-30 11:52:54 +01:00
Martin Whitaker f3092bba93 Correctly identify scopes for constant function calls (issue #1141)
A constant function call may be inside a named block, so we need to
search upwards to find the enclosing module before checking that the
called function is local to that module.

SystemVerilog allows constant function calls to reference functions
in (other) packages or in the $unit scope, so extend the checks to
permit that.
2024-06-30 11:50:59 +01:00
Cary R dc6f9f2049 make exit an alias for finish at the VVP command line 2024-06-17 10:19:44 -07:00
Cary R adb5731ace A package name must have more than three characters 2024-06-17 09:34:13 -07:00
Cary R 0937de3bee Update to the latest GTKWave files 2024-06-17 09:34:03 -07:00
Martin Whitaker 713b002138 vvp: fix regression in behaviour of -N option (issue #1138)
The -N option was broken by PR #1068. This fix modifies and simplifies
the libvvp API that was introduced in that PR.
2024-06-15 10:47:22 +01:00
Cary R 8ac44a38b3
Merge pull request #1136 from gatk555/actions_macos
Revive Action test.yml.
2024-06-13 06:40:20 -07:00
ga 1aa6a159d0 Fix test.yml for Mac by fixing docopt and using Macos-12 runner.
Update the versions of called Actions to prevent warnings.hi and add
"workflow_dispatch" to allow testing.
Unrelated: add "*.so" to .gitignore to hide built libvvp.so.
2024-06-13 10:36:11 +01:00
Martin Whitaker 94d9d19519 Add regression test for issue #1122. 2024-05-06 21:47:18 +01:00
Martin Whitaker 3b61c0088d vvp: handle tranif enable changes that result from island resolution.
The tran island resolution tests and caches the state of all branch
enable inputs before resolving the branch endpoint values. If a
branch enable is connected directly to a branch endpoint, we need
to update the cached stete and rerun the island resolution if any
enable state changed.

This fixes issue #1122.
2024-05-06 21:37:37 +01:00
Martin Whitaker 615a01c6cd Add libvvp.h to the files that are installed when libvvp is enabled. 2024-04-21 15:20:12 +01:00
martinwhitaker 35f344adf9
Merge pull request #1115 from grebe/single_element_array
Update handling of single-element arrays.
2024-04-16 22:00:19 +01:00
Paul Rigge 28187823ed
Update handling of single-element arrays.
Also, add a test. This fixes #1113.
2024-04-15 13:14:53 -07:00
Martin Whitaker ef7f0a8f38 Add regression tests for early signal elaboration. 2024-04-06 10:19:00 +01:00
Martin Whitaker ca307053f2 Allow nets & variables to be elaborated early on demand.
If a net or variable is referenced in another net or variable declaration
or in a value parameter definition (e.g. when using the $bits function)
and hasn't already been elaborated, we need to elaborate it early. So
during the scope elaboration phase, add placeholders in each NetScope
object to record the PWire objects that are yet to be elaborated. This
allows the symbol_search() function to find the unelaborated objects
and to trigger early elaboration.

Add a flag in the PWire object to indicate when we are elaborating it.
This allows us to detect circular references and avoid an infinite loop.

This fixes issue #483, issue #575, and issue #1097.
2024-04-06 10:10:54 +01:00
Martin Whitaker ff4cd2c5da Merge branch 'declare-before-use' 2024-04-06 09:13:07 +01:00
Martin Whitaker 52d049b513 Add additional regression tests for issue #1099. 2024-02-25 21:55:37 +00:00
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 f08ff895af Add informational messages that point to declaration after use. 2024-02-25 16:12:31 +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
Martin Whitaker d043c1fa44 Add regression tests for declare before use. 2024-02-20 08:46:28 +00:00
Martin Whitaker f1bf6a7a55 Mark the vhdl_fa4_test4 as NI.
The VHDL pre-processor is generating illegal code for this test case
(using localparam values before they are declared).
2024-02-19 18:41:33 +00:00
Martin Whitaker 76a9d38d87 Add check for parameters used before they are declared. 2024-02-19 18:20:39 +00:00
Martin Whitaker 1c28948484 Pass lexical position information to PTrigger and PNBTrigger objects. 2024-02-19 18:20:14 +00:00
Martin Whitaker cd76bd2371 Fix tests that used variables/nets before declaring them.
The sdf_interconnect tests just need the code reordering. The
pr1909940 tests were written to test use before declaration, so
now need to be CE tests.
2024-02-19 18:20:04 +00:00
Martin Whitaker 649fbb9a59 Modify symbol_search() to only return declared nets and named events.
This only applies to simple identifiers. Only return a match if the
lexical position of the identifier being searched is later in the
source text than the lexical position of a matching symbol.
2024-02-19 18:19:55 +00:00
Martin Whitaker e22831553d Improve identifier lexical position accuracy in declarations.
Enhance the lists of identifiers and declaration assignments generated
by the parser to associate each identifier with its lexical_pos. Also do
this for single items in complex parser rules where the location passed
to the pform is not the location of the identifier.
2024-02-19 18:16:35 +00:00
Martin Whitaker 4159a6a6b1 Pass on lexical position information to NetNet and NetEvent objects. 2024-02-19 18:15:56 +00:00
Martin Whitaker bb80ee6905 Add lexical position information to PWire and PEvent objects. 2024-02-19 18:14:49 +00:00
Martin Whitaker 079108f32b Add lexical position information to PEIdent objects. 2024-02-19 18:13:29 +00:00
Martin Whitaker 8b3f0d63b4 Record the lexical order of identifiers whilst scanning the source files.
This is needed for detecting use before declaration. The lexical scanner
is the only place where we process the source text in strict lexical
order, so do it there.

As Verilog allows modules to span multiple source files, don't reset
the counter when we reset the lexor.
2024-02-19 18:13:05 +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