2019-02-24 20:59:00 +01:00
|
|
|
# sv2v: SystemVerilog to Verilog
|
|
|
|
|
|
2019-04-04 05:12:52 +02:00
|
|
|
sv2v converts SystemVerilog ([IEEE 1800-2017]) to Verilog ([IEEE 1364-2005]),
|
|
|
|
|
with an emphasis on supporting synthesizable language constructs.
|
2019-03-27 08:41:41 +01:00
|
|
|
|
|
|
|
|
[IEEE 1800-2017]: https://ieeexplore.ieee.org/servlet/opac?punumber=8299593
|
|
|
|
|
[IEEE 1364-2005]: https://ieeexplore.ieee.org/servlet/opac?punumber=10779
|
2019-04-04 05:12:52 +02:00
|
|
|
|
|
|
|
|
The primary goal of this project is to create a completely free and open-source
|
|
|
|
|
tool for converting SystemVerilog to Verilog. While methods for performing this
|
|
|
|
|
conversion already exist, they generally either rely on commercial tools, or are
|
2019-04-23 17:59:15 +02:00
|
|
|
limited in scope.
|
2019-04-04 05:12:52 +02:00
|
|
|
|
|
|
|
|
This project was originally developed to target [Yosys], and so allows for
|
2019-04-23 20:07:59 +02:00
|
|
|
disabling the conversion of (passing through) those [SystemVerilog features
|
|
|
|
|
which Yosys supports].
|
2019-04-04 05:12:52 +02:00
|
|
|
|
2019-02-26 21:03:49 +01:00
|
|
|
[Yosys]: http://www.clifford.at/yosys/
|
2019-03-08 17:02:40 +01:00
|
|
|
[SystemVerilog features which Yosys supports]: https://github.com/YosysHQ/yosys#supported-features-from-systemverilog
|
2019-02-24 20:59:00 +01:00
|
|
|
|
|
|
|
|
|
2019-04-04 05:12:52 +02:00
|
|
|
## Dependencies
|
|
|
|
|
|
|
|
|
|
All of sv2v's dependencies are free and open-source.
|
|
|
|
|
|
|
|
|
|
* Build Dependencies
|
|
|
|
|
* [Haskell Stack](https://www.haskellstack.org/) - Haskell build system
|
|
|
|
|
* Haskell dependencies are managed in `sv2v.cabal`
|
|
|
|
|
* Test Dependencies
|
|
|
|
|
* [Icarus Verilog](http://iverilog.icarus.com) - for Verilog simulation
|
|
|
|
|
* [shUnit2](https://github.com/kward/shunit2) - test framework
|
|
|
|
|
|
|
|
|
|
|
2019-02-24 20:59:00 +01:00
|
|
|
## Installation
|
|
|
|
|
|
|
|
|
|
### Pre-built binaries
|
|
|
|
|
|
2019-04-04 05:12:52 +02:00
|
|
|
We plan on releasing pre-built binaries in the future.
|
2019-02-24 20:59:00 +01:00
|
|
|
|
|
|
|
|
### Building from source
|
|
|
|
|
|
2019-04-23 20:07:59 +02:00
|
|
|
You must have [Stack] installed to build sv2v. Then you can:
|
2019-02-24 20:59:00 +01:00
|
|
|
|
|
|
|
|
[Stack]: https://www.haskellstack.org/
|
|
|
|
|
|
|
|
|
|
```
|
2019-04-19 01:33:16 +02:00
|
|
|
git clone https://github.com/zachjs/sv2v.git
|
2019-02-24 20:59:00 +01:00
|
|
|
cd sv2v
|
|
|
|
|
make
|
|
|
|
|
```
|
|
|
|
|
|
2019-04-19 01:33:16 +02:00
|
|
|
This creates the executable at `./bin/sv2v`. Stack takes care of installing
|
|
|
|
|
exact (compatible) versions of the compiler and sv2v's build dependencies.
|
|
|
|
|
|
|
|
|
|
You can install the binary to your local bin path (typically `~/.local/bin`) by
|
|
|
|
|
running `stack install`, or copy over the executable manually.
|
2019-02-24 20:59:00 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
2019-04-04 05:12:52 +02:00
|
|
|
sv2v takes in a list of files and prints the converted Verilog to `stdout`.
|
2019-04-23 20:07:59 +02:00
|
|
|
Users may specify `include` search paths, define macros during preprocessing,
|
|
|
|
|
and exclude some of the conversions.
|
2019-04-04 05:12:52 +02:00
|
|
|
|
|
|
|
|
Below is the current usage printout. This interface is subject to change.
|
2019-02-26 21:03:49 +01:00
|
|
|
|
|
|
|
|
```
|
2019-03-29 00:55:53 +01:00
|
|
|
sv2v [OPTIONS] [FILES]
|
2019-02-26 21:03:49 +01:00
|
|
|
|
|
|
|
|
Common flags:
|
2019-04-04 05:12:52 +02:00
|
|
|
-e --exclude=CONV exclude a particular conversion (always,
|
|
|
|
|
interface, logic)
|
2019-04-02 22:19:59 +02:00
|
|
|
-i --incdir=DIR add directory to include search path
|
2019-04-04 05:12:52 +02:00
|
|
|
-d --define=NAME[=VALUE] define a macro for preprocessing
|
2019-04-02 22:19:59 +02:00
|
|
|
-? --help Display help message
|
|
|
|
|
-V --version Print version information
|
|
|
|
|
--numeric-version Print just the version number
|
2019-02-26 21:03:49 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
2019-04-19 01:33:16 +02:00
|
|
|
## Supported Features
|
|
|
|
|
|
|
|
|
|
sv2v supports most synthesizable SystemVerilog features. Current notable
|
|
|
|
|
exceptions include `package`/`import`/`export`, interfaces _with parameter
|
|
|
|
|
bindings_, and complex (non-identifier) `modport` expressions. Assertions are
|
|
|
|
|
also supported, but are simply dropped during conversion.
|
|
|
|
|
|
|
|
|
|
If you find a bug or have a feature request, please create an issue. Preference
|
|
|
|
|
will be given to issues which include examples or test cases.
|
|
|
|
|
|
|
|
|
|
|
2019-04-23 20:07:59 +02:00
|
|
|
## SystemVerilog Front End
|
2019-02-24 20:59:00 +01:00
|
|
|
|
2019-04-04 05:12:52 +02:00
|
|
|
This project contains a preprocessor and lexer, a parser, and an abstract syntax
|
|
|
|
|
tree representation for a subset of the SystemVerilog specification. The parser
|
|
|
|
|
is not very strict. The AST allows for the representation of syntactically (and
|
2019-02-24 20:59:00 +01:00
|
|
|
semantically) invalid Verilog. The goal is to be more general in the
|
|
|
|
|
representation to enable more standardized and straightforward conversion
|
|
|
|
|
procedures. This could be extended into an independent and more fully-featured
|
2019-04-23 17:59:15 +02:00
|
|
|
front end if there is significant interest.
|
2019-04-04 05:12:52 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
## Testing
|
|
|
|
|
|
|
|
|
|
The current test suite is limited. Tests can be run with `make test`.
|
2019-02-24 20:59:00 +01:00
|
|
|
|
|
|
|
|
|
2019-04-23 20:07:59 +02:00
|
|
|
## Acknowledgements
|
|
|
|
|
|
|
|
|
|
This project was originally forked from [Tom Hawkin's Verilog parser]. While the
|
|
|
|
|
front end has changed substantially in adding SystemVerilog support, his project
|
|
|
|
|
was as a great starting point.
|
|
|
|
|
|
|
|
|
|
[Tom Hawkin's Verilog parser]: https://github.com/tomahawkins/verilog
|
|
|
|
|
|
|
|
|
|
Reid Long was invaluable in developing this tool, providing significant tests
|
|
|
|
|
and advice, and isolating many bugs. His projects can be found
|
|
|
|
|
[here](https://bitbucket.org/ReidLong/).
|
|
|
|
|
|
|
|
|
|
Edric Kusuma helped me with the ins and outs of SystemVerilog, with which I had
|
|
|
|
|
no prior experience, and has also helped with test cases.
|
|
|
|
|
|
|
|
|
|
|
2019-02-24 20:59:00 +01:00
|
|
|
## License
|
|
|
|
|
|
|
|
|
|
See the LICENSE file for copyright and licensing information.
|