Commit Graph

2171 Commits

Author SHA1 Message Date
Martin Whitaker da853622e9 Don't delete vvp/libvvp.h when running 'make clean'. 2025-10-25 14:16:00 +01:00
Cary R 702189a948 Add correct C++ cast for the vpi_modules 2025-10-21 00:44:23 -07:00
Cary R b7292e0179 Another fix for msys CI 2025-10-21 00:27:35 -07:00
Cary R 860761f9c6 More cppcheck fixes - part 2 2025-10-20 23:54:15 -07:00
Cary R 08c8ee081a More cppcheck updates 2025-10-20 23:54:15 -07:00
Martin Whitaker 8e2d543304 Rework makefiles to eliminate the use of dlltool in Windows builds.
The clang dlltool is not compatible with the binutils dlltool. However
both the clang and binutils linkers support reading the .def file and
creating the import library directly, so we no longer need to perform
the link in two stages.
2025-10-18 20:00:19 +01:00
Cary R 94dcd658c8 Update exe and manual pages to report @(C) 2025 2025-10-12 19:13:30 -07:00
Martin Whitaker fede5239ba Fix builds using both --enable-suffix and --enable-libvvp options.
We need to build libvvp with a suffix from the outset to ensure that
the vvp binary searches for the correct library file name once it is
installed.

Also Windows DLLs need to be stored in the same directory as the main
program, not in a separate lib directory.
2025-10-11 12:03:29 +01:00
Martin Whitaker 23b6f955d4 Fix suffixed vvp build under Windows.
Commit 95810b2f61 mistakenly added the suffix to the output file name
when linking the final vvp.exe binary. 'make check' and 'make install'
assume the suffix is only added when installing.
2025-10-11 10:39:46 +01:00
Martin Whitaker 936f92ebe6 vvp: demangle identifiers when parsing the input file (issue #1273).
The tgt-vvp code generatpr outputs identifiers as quoted strings, and
because of this, escapes any " and \ characters (which may appear in
escaped indentifiers). We need to undo this when reading them into
vvp, so that the original name is seen by the VPI routines.
2025-10-07 21:53:11 +01:00
Cary R db82380cec Minor cppcheck updates in vvp and switch vvp to use override for virtual functions 2025-07-21 23:32:34 -07:00
Martin Whitaker 7161dc0ab1 Fix return type of vpi_control() and vpi_sim_control() (issue #1208).
These were implemented as returning nothing (void), and passing an
invalid operation value would trigger an assertion failure. The IEEE
standards define them as returning 1 on success and 0 on failure.

vpi_sim_control() is the name used in Verilog-AMS. Strictly speaking
it should return a bool, but to avoid polluting the namespace by
including stdbool.h, we return a PLI_INT32. As C is a weakly typed
language, this should make no practical difference.
2025-07-08 21:14:49 +01:00
Cary R adcb9f4e0d Add support for passing a real input to logic, mos and if gates 2025-06-21 10:04:12 -07:00
Lars-Peter Clausen 4854de06ca vvp: Fix logic class property initialization
Logic type class properties use the wrong constructor resulting in a
default value of a vector with 0 width. Switch to the right constructor to
fix this.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2025-01-05 09:34:25 -08:00
Martin Whitaker 84848e8e04 vvp: fail gracefully on multi-bit modpath delays (issue #1184)
The code doesn't currently handle the case of different bits within
the vector needing different delays (e.g. when the rise and fall
delays are different and some bits are rising as other bits are
falling) and aborts with an assertion failure. For now, output a
suitable "sorry" message and exit gracefully.
2024-12-31 16:59:23 +00:00
Martin Whitaker a3903c6cd3 Document the new vvp quiet flag. 2024-12-31 15:16:09 +00:00
Martin Whitaker adb6a2f454 Add vvp "quiet" flag (issue #1193)
This adds a "-q" option on the vvp command line and a vvp_set_quiet_flag()
function in the VVP library API. Setting this flag will cause all output
to standard output via MCD bit 0 to be suppressed. It will not prevent the
output being sent to a log file if the vvp "-l" option has been used, and
it will not affect output to the STDOUT file descriptor.
2024-12-31 13:05:36 +00:00
Cary R b745119746 Update Makefile.in to install PDF correctly 2024-11-27 02:00:41 -08:00
Cary R 361e16bed2 Fix some valgrind compile warnings 2024-11-27 00:11:50 -08:00
Cary R 527b0daed6 Fix some clang warnings 2024-11-26 23:33:52 -08:00
Dag Lem ba7da9d5a5 Guard against overflow / wrap around of internal part-select bit address
Internally, the maximum address space of a vector is 31 bits + a sign bit
to signal invalid addresses (out of bounds or has one or more x or z bits).

This commit ensures that unsigned part-select bit addresses which would
otherwise overflow and wrap around within this address space are correctly
handled as out of bounds.
2024-09-16 23:50:24 +02:00
Cary R 676b36e455 Fix space issues in the source code 2024-07-21 11:19:41 -07: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
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
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
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
martinwhitaker 202d41a60c
Merge pull request #1098 from steveicarus/vpi-callback-improvements
VPI callback improvements
2024-02-12 17:42:45 +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 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 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 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 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
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
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 5c9ec105d9 Fix some compile issues 2024-01-20 12:42:55 -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