Verilator open-source SystemVerilog simulator and lint system
Go to file
Geza Lore d5bdd07c01 Fix out of bounds index into VlWide under AstSel
When part selecting bits via an AstSel in a VlWide, V3Expand used to do
something akin to:

word_index = lsb / 32;
bit_index = lsb % 32;
result =
  wide[word_index + 1] << (32 - bit_index) | wide[word_index] >> bit_index;

The unconditional "+ 1" can cause an out of bounds access into the
VlWide, when the whole of the select is into the most significant word
(i.e.: when word_index is already the most significant word).  We now
emit roughly this instead:

lo_word_index = lsb / 32;
bit_index = lsb % 32;
hi_word_index = (lsb + width - 1) / 32;
result =
  wide[hi_word_index] << (32 - bit_index) | wide[lo_word_index] >> bit_index;

i.e.: we explicitly calculate which word the MSB of the select falls
into, and address that word, rather than the unconditional + 1. The
shifts ensure we still yield the right result, even if lo_word_index and
hi_word_index are the same.

Note: The actual expression created by V3Expand can be a bit more
complicated as we might need to access 3 words when the result is a
QData, all 3 word indices are calculated explicitly.
2021-06-18 14:31:01 +01:00
.github Internals: Update to clang-format-11 (#3021) 2021-06-14 14:50:40 -04:00
bin Remove deprecated --no-relative-cfuncs (#3024) 2021-06-16 23:17:43 -04:00
ci CI: Add -m32 build 2021-06-14 00:37:59 +01:00
docs Remove deprecated --no-relative-cfuncs (#3024) 2021-06-16 23:17:43 -04:00
examples Untabify cmakefiles. No functional change. 2021-06-07 07:47:15 -04:00
include Internals: Favor VlWide over WData arrays. No functional change intended. 2021-06-17 21:17:25 -04:00
nodist Build Verilator without -Og in the coverage build 2021-06-14 19:55:03 +01:00
src Fix out of bounds index into VlWide under AstSel 2021-06-18 14:31:01 +01:00
test_regress Remove deprecated --no-relative-cfuncs (#3024) 2021-06-16 23:17:43 -04:00
.clang-format Commentary 2021-03-29 19:37:47 -04:00
.clang-tidy Internals: Use C++11 = default where obvious. No functional change intended. 2020-11-16 19:56:16 -05:00
.codacy.yml Internals: Fix misc internal coverage holes. No functional change intended. 2020-06-04 21:40:40 -04:00
.gitattributes Commentary: Convert Changes to RST format 2021-03-14 14:12:58 -04:00
.gitignore Cleanup some python warnings. No functional change. 2021-03-20 17:37:24 -04:00
Artistic docs: Move license files back to top out of docs to appease github. 2019-06-15 21:41:38 -04:00
Changes Remove deprecated --no-relative-cfuncs (#3024) 2021-06-16 23:17:43 -04:00
codecov.yml Copyright year update 2021-01-01 10:29:54 -05:00
configure.ac Build Verilator without -Og in the coverage build 2021-06-14 19:55:03 +01:00
install-sh Fix whitespace issues, bug1203. 2017-09-11 19:18:58 -04: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 Internals: Update to clang-format-11 (#3021) 2021-06-14 14:50:40 -04:00
MANIFEST.SKIP Documentation has been rewritten into a book format. 2021-04-11 18:55:06 -04:00
README.rst Docs: Fix cross-references 2021-04-13 09:25:11 -04:00
verilator-config-version.cmake.in Fix cmake version number (#2881) 2021-04-13 09:10:29 -04:00
verilator-config.cmake.in Add support of --trace-structs parameter for CMake (#2986) 2021-06-06 09:27:44 -04:00
verilator.pc.in Fix default pkgconfig version to have no spaces (#2308) 2020-05-05 08:46:24 -04:00

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

.. image:: https://img.shields.io/badge/License-LGPL%20v3-blue.svg
    :target: https://www.gnu.org/licenses/lgpl-3.0]
.. image:: https://img.shields.io/badge/License-Artistic%202.0-0298c3.svg
    :target: https://opensource.org/licenses/Artistic-2.0
.. image:: https://api.codacy.com/project/badge/Grade/fa78caa433c84a4ab9049c43e9debc6f
    :target: https://www.codacy.com/gh/verilator/verilator
.. image:: https://codecov.io/gh/verilator/verilator/branch/master/graph/badge.svg
    :target: https://codecov.io/gh/verilator/verilator
.. image:: https://github.com/verilator/verilator/workflows/build/badge.svg
    :target: https://github.com/verilator/verilator/actions?query=workflow%3Abuild

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

.. list-table::

   * - **Welcome to Verilator, the fastest Verilog/SystemVerilog simulator.**
        * Accepts synthesizable 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 commercial simulators
        * Single- and multi-threaded output models
   * - **Widely Used**
        * Wide industry and academic deployment
        * Out-of-the-box support from Arm, and RISC-V vendor IP
     - |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 multi-threaded .cpp and .h
files, the "Verilated" code.

The user writes a little C++/SystemC wrapper file, which instantiates the
"Verilated" model of the user's top level module. These C++/SystemC files
are then compiled by a C++ compiler (gcc/clang/MSVC++). The resulting
executable performs the design simulation. Verilator also supports linking
its generated libraries, optionally encrypted, into other simulators.

Verilator may not be the best choice if you are expecting a full featured
replacement for NC-Verilog, VCS or another commercial Verilog simulator, or
if you are looking for a behavioral Verilog simulator e.g. for a quick
class project (we recommend `Icarus Verilog`_ for this.) However, if you
are looking for a path to migrate SystemVerilog to C++ or SystemC, or your
team is comfortable writing just a touch of C++ code, Verilator is the tool
for you.


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

Verilator does not simply convert 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 the
closed-source Verilog simulators (Carbon Design Systems Carbonator,
Modelsim, Cadence Incisive/NC-Verilog, 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 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 <http://gtkwave.sourceforge.net/>`_ - Waveform viewer for
  Verilator traces.

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


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

Verilator is Copyright 2003-2021 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: http://iverilog.icarus.com
.. _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