Verilator open-source SystemVerilog simulator and lint system
Go to file
Christian Hecken b0adf5f7af Add vpi_put/vpi_get support for forcing signals
This commit includes PR #6688.
It adds support for `vpiForceFlag` and `vpiReleaseFlag` to
`vpi_put_value`. `vpi_get_value` is updated to return the value of
either the signal itself, or the `__VforceVal` control signal, depending
on whether the forcing is active.

The functionality is tested in the tests `t_vpi_force`, which tests that
forcing and releasing works on a clocked register being forced with a
VpiIntVal, as well as `t_vpi_forceable_bad`, which tests that attempting
to force a signal without marking it forceable causes an error. The
tests were run under Verilator (based on dc00bf248 with the commit for
isForceable applied), `Icarus Verilog version 13.0 (devel)
(s20251012-20-gcc496c3cf)`, and `xrun 24.09-a071`.

The implementation is simply done using string concatenation of the
signal name with the __VforceEn and __VforceVal suffixes. The signal vop
that the vpi_put/get functions operate on is then pointed towards either
the base signal or the __VforceVal signal (for vpi_put) or the
__VforceRd signal (for vpi_get).

While it works and passes the newly implemented tests, this solution is
quite brittle and in part re-implements existing functionality by
recreating the `__VforceRd` signal, so once #6705 is completed, it
should extend `VerilatedVar` to hold information about the force control
signals, which is provided at Verilation time, rather than a runtime
lookup.

Because `valuep` should get set to the value of the signal after
forcing when `vpi_put_value` is called with `vpiReleaseFlag`, this
commit also adds information about `isContinuously` to the
`VerilatedVarFlags`.

Lastly, since unpacked arrays cannot be forced (#4735), a Verilation
time check for this was added and tested in `t_forceable_unpacked_bad`,
which simplifies the error handling in `vpi_put_value` and
`vpi_get_value`. The same was done for forceable strings, which is
tested in `t_forceable_string_bad`.

Fixes #5933
2025-12-17 14:08:13 +01:00
.devcontainer Tests: Untabify some tests. 2024-09-01 21:12:37 -04:00
.github Bump actions/cache from 4 to 5 (#6819) 2025-12-15 11:37:46 -05:00
bin Support `-libmap` (#5891 partial) (#6764) 2025-12-16 11:21:46 -05:00
ci Internals: Add format-bash make rule (not in automatic format) 2025-11-22 12:30:29 -05:00
docs Tests: Remove old benchmarksim, should use rtlmeter instead 2025-12-16 21:17:27 -05:00
examples Tests: Change default indent to 2 spaces (match edaplayground). No functional change. 2025-07-03 20:43:13 -04:00
include Add vpi_put/vpi_get support for forcing signals 2025-12-17 14:08:13 +01:00
nodist Internals: Add some missing Python files to lint 2025-11-22 12:22:39 -05:00
src Add vpi_put/vpi_get support for forcing signals 2025-12-17 14:08:13 +01:00
test_regress Add vpi_put/vpi_get support for forcing signals 2025-12-17 14:08:13 +01:00
.bake.toml Internals: Add format-make rule and standardize Makefile indents. No functional change intended. 2025-06-24 17:58:55 -04:00
.clang-format Fix header order botched by clang-format in recent commit. 2023-10-18 06:37:46 -04:00
.clang-tidy Add vpi_put/vpi_get support for forcing signals 2025-12-17 14:08:13 +01:00
.codacy.yml CI: Avoid duplicate action runs on dependabot 2025-09-03 18:54:27 -04:00
.codecov.yml Internals: Run format-yaml 2025-11-01 14:11:47 -04:00
.gitattributes Commentary: Convert Changes to RST format 2021-03-14 14:12:58 -04:00
.gitignore Add 'make venv' target (#6775) 2025-12-14 11:18:32 +00:00
.pre-commit-hooks.yaml Add Docker pre-commit hook (#5238) (#5452) 2024-09-23 07:37:24 -04:00
.style.yapf Internals: Add .style.yapf 2024-08-26 21:53:36 -04:00
Artistic docs: Move license files back to top out of docs to appease github. 2019-06-15 21:41:38 -04:00
CITATION.cff Add CITATION.cff (#5057) (#5058). 2024-04-19 20:33:11 -04:00
CMakeLists.txt devel release 2025-11-02 11:18:20 -05:00
CPPLINT.cfg Internals: Add cpplint control file and related cleanups 2022-01-09 16:49:38 -05:00
Changes Fix duplicate name error with interface initial blocks (#6804) (#6805). 2025-12-16 20:57:58 -05:00
LICENSE docs: Move license files back to top out of docs to appease github. 2019-06-15 21:41:38 -04:00
Makefile.in Add 'make venv' target (#6775) 2025-12-14 11:18:32 +00:00
README.rst Documentation: Adapt format suggested by docstrfmt 2025-11-22 10:59:38 -05:00
configure.ac Add `-Wno-vla-cxx-extension` CLang flag, and UVM DPI tests (#6782) 2025-12-09 07:15:28 -05:00
install-sh Internals: Avoid using <tab> in the middle of lines (#3913) 2023-01-29 22:39:22 -05:00
python-dev-requirements.txt Add 'make venv' target (#6775) 2025-12-14 11:18:32 +00:00
verilator-config-version.cmake.in Copyright year update. 2025-01-01 08:30:25 -05:00
verilator-config.cmake.in Apply 'make format' 2025-11-08 15:57:16 +00:00
verilator.pc.in Fix default pkgconfig version to have no spaces (#2308) 2020-05-05 08:46:24 -04:00

README.rst

.. Github doesn't render images unless absolute URL
.. Do not know of a conditional tag, "only: github" nor "github display" works

|badge1| |badge2| |badge3| |badge4| |badge5| |badge7| |badge8|

.. |badge1| image:: https://img.shields.io/badge/Website-Verilator.org-181717.svg
   :target: https://verilator.org
.. |badge2| image:: https://img.shields.io/badge/License-LGPL%20v3-blue.svg
   :target: https://www.gnu.org/licenses/lgpl-3.0
.. |badge3| image:: https://img.shields.io/badge/License-Artistic%202.0-0298c3.svg
   :target: https://opensource.org/licenses/Artistic-2.0
.. |badge4| image:: https://repology.org/badge/tiny-repos/verilator.svg?header=distro%20packages
   :target: https://repology.org/project/verilator/versions
.. |badge5| image:: https://img.shields.io/docker/pulls/verilator/verilator
   :target: https://hub.docker.com/r/verilator/verilator
.. |badge7| image:: https://github.com/verilator/verilator/workflows/build/badge.svg
   :target: https://github.com/verilator/verilator/actions?query=workflow%3Abuild
.. |badge8| image:: https://img.shields.io/github/actions/workflow/status/verilator/verilator/rtlmeter.yml?branch=master&event=schedule&label=benchmarks
   :target: https://verilator.github.io/verilator-rtlmeter-results


Welcome to Verilator
====================

.. list-table::

   * - **Welcome to Verilator, the fastest Verilog/SystemVerilog simulator.**
        * Accepts Verilog or SystemVerilog
        * Performs lint code-quality checks
        * Compiles into multithreaded C++, or SystemC
        * Creates XML to front-end your own tools
     - |Logo|
   * - |verilator multithreaded performance|
     - **Fast**
        * Outperforms many closed-source commercial simulators
        * Single- and multithreaded output models
   * - **Widely Used**
        * Wide industry and academic deployment
        * Out-of-the-box support from Arm and RISC-V vendor IP
        * Over 700 contributors
     - |verilator usage|
   * - |verilator community|
     - **Community Driven & Openly Licensed**
        * Guided by the `CHIPS Alliance`_ and `Linux Foundation`_
        * Open, and free as in both speech and beer
        * More simulation for your verification budget
   * - **Commercial Support Available**
        * Commercial support contracts
        * Design support contracts
        * Enhancement contracts
     - |verilator support|


What Verilator Does
===================

Verilator is invoked with parameters similar to GCC or Synopsys's VCS. It
"Verilates" the specified Verilog or SystemVerilog code by reading it,
performing lint checks, and optionally inserting assertion checks and
coverage-analysis points. It outputs single- or multithreaded .cpp and .h
files, the "Verilated" code.

These Verilated C++/SystemC files are then compiled by a C++ compiler
(gcc/clang/MSVC++), optionally along with a user's own C++/SystemC wrapper
file, to instantiate the Verilated model. Executing the resulting
executable performs the design simulation. Verilator also supports linking
Verilated generated libraries, optionally encrypted, into other simulators.

Verilator may not be the best choice if you are expecting a full-featured
replacement for a closed-source Verilog simulator, need SDF annotation,
mixed-signal simulation, or are doing a quick class project (we recommend
`Icarus Verilog`_ for classwork). However, if you are looking for a path to
migrate SystemVerilog to C++/SystemC, or want high-speed simulation of
designs, Verilator is the tool for you.


Performance
===========

Verilator does not directly translate Verilog HDL to C++ or SystemC.
Rather, Verilator compiles your code into a much faster optimized and
optionally thread-partitioned model, which is in turn wrapped inside a
C++/SystemC module. The results are a compiled Verilog model that executes
even on a single thread over 10x faster than standalone SystemC, and on a
single thread is about 100 times faster than interpreted Verilog simulators
such as `Icarus Verilog`_. Another 2-10x speedup might be gained from
multithreading (yielding 200-1000x total over interpreted simulators).

Verilator has typically similar or better performance versus closed-source
Verilog simulators (e.g., Aldec Riviera-Pro, Cadence Incisive/NC-Verilog,
Mentor ModelSim/Questa, Synopsys VCS, VTOC, and Pragmatic CVer/CVC). But,
Verilator is open-sourced, so you can spend on computes rather than
licenses. Thus, Verilator gives you the best simulation cycles/dollar.


Installation & Documentation
============================

For more information:

- `Verilator installation and package directory structure
  <https://verilator.org/install>`_

- `Verilator manual (HTML) <https://verilator.org/verilator_doc.html>`_, or
  `Verilator manual (PDF) <https://verilator.org/verilator_doc.pdf>`_

- `Subscribe to Verilator announcements
  <https://github.com/verilator/verilator-announce>`_

- `Verilator forum <https://verilator.org/forum>`_

- `Verilator issues <https://verilator.org/issues>`_


Support
=======

Verilator is a community project, guided by the `CHIPS Alliance`_ under the
`Linux Foundation`_.

We appreciate and welcome your contributions in whatever form; please see
`Contributing to Verilator
<https://github.com/verilator/verilator/blob/master/docs/CONTRIBUTING.rst>`_.
Thanks to our `Contributors and Sponsors
<https://verilator.org/guide/latest/contributors.html>`_.

Verilator also supports and encourages commercial support models and
organizations; please see `Verilator Commercial Support
<https://verilator.org/verilator_commercial_support>`_.


Related Projects
================

- `GTKwave <https://gtkwave.sourceforge.net/>`_ - Waveform viewer for
  Verilator traces.

- `Icarus Verilog`_ - Icarus is a highly-featured interpreted Verilog
  simulator. If Verilator does not support your needs, perhaps Icarus may.

- `Surfer <https://surfer-project.org/>`_ - Web or offline waveform viewer
  for Verilator traces.


Open License
============

Verilator is Copyright 2003-2025 by Wilson Snyder. (Report bugs to
`Verilator Issues <https://verilator.org/issues>`_.)

Verilator is free software; you can redistribute it and/or modify it under
the terms of either the GNU Lesser General Public License Version 3 or the
Perl Artistic License Version 2.0. See the documentation for more details.

.. _chips alliance: https://chipsalliance.org
.. _icarus verilog: https://steveicarus.github.io/iverilog
.. _linux foundation: https://www.linuxfoundation.org
.. |Logo| image:: https://www.veripool.org/img/verilator_256_200_min.png
.. |verilator multithreaded performance| image:: https://www.veripool.org/img/verilator_multithreaded_performance_bg-min.png
.. |verilator usage| image:: https://www.veripool.org/img/verilator_usage_400x200-min.png
.. |verilator community| image:: https://www.veripool.org/img/verilator_community_400x125-min.png
.. |verilator support| image:: https://www.veripool.org/img/verilator_support_400x125-min.png