# verilog2systemc

> Convert Verilog to SystemC keeping original structure

- Catalog id: `Verilog2Systemc`; bundle: `verilog2systemc`; latest version 20261018
- Documentation page: https://edautils.com/verilog2systemc.html
- Keywords: Verilog to SystemC, RTL to SystemC, SystemC generator, HDL conversion
- Terms: as stated on edautils.com, EDAUtils tools are free for commercial and academic use, with no license server. The bundle's own metadata says: "Free to evaluate with the bundled licence; commercial licences from help@edautils.com". Licence prerequisites per tool are under "How an agent runs it".
- This file: https://edautils.com/capabilities/verilog2systemc.md

## Downloads

- EDAUtils download site: https://edautils.ai/download/Verilog2Systemc (latest file `verilog2systemc-20261018.tar.gz`)
- SourceForge: https://sourceforge.net/projects/edautils-converters/files/verilog2systemc/
- GitHub Releases: https://github.com/edautils/releases/releases/download/RELEASE_20261018/verilog2systemc-20261018.tar.gz (release `RELEASE_20261018`; all releases: https://github.com/edautils/releases/releases)

## How an agent runs it

The following is the AGENTS.md shipped at the root of the bundle.

Translates a Verilog design, starting at one top module (`-top`), into SystemC C++: one
`<module>.hxx` / `<module>.cxx` pair per module, a `main_sc.cxx` driver for the top, and a
`Makefile` in the current directory that compiles `<outdir>/*.cxx` with g++ against a
SystemC installation into `bin/test.exe` and runs it. The top is elaborated first
(`-noelab` skips that). Four-value logic by default, two-value with `-two_value_logic`.
Main class: `com.eu.miscedautils.verilog2sc.verilog2systemc` (jar `lib/verilogparser.jar`).

### Where it ships

Its own bundle, `verilog2systemc.tar.gz` (flow `verilog2systemc`; release tree
`release_scripts/verilog2systemc/1.0`), and as a point tool in the **designplayer-shell** bundle
(`bin/verilog2systemc` running the shell's jar; this guide as `tools/verilog2systemc/AGENTS.md`,
examples under `tools/verilog2systemc/examples/`).

### Prerequisites

- Java on `PATH` (the launcher runs plain `java`). Use Java 11 or newer (Java 21 recommended: the
  release is built and regression-tested with OpenJDK 21); the bundled JAXB and Eclipse libraries
  are class-file version 55, so a Java 8 runtime fails with `UnsupportedClassVersionError`.
- `EDAUTILS_ROOT` = the unpacked bundle directory (must contain `bin/` and `lib/`). The
  launcher exits 1 with "Environment variable EDAUTILS_ROOT is not set" otherwise.
  `source setup_env.sh` (or `setup_env.csh`) from the bundle root sets `EDAUTILS_ROOT`,
  `EDAUTILS_LICENSE_FILE=$EDAUTILS_ROOT/edautils.lic` and prepends `bin/` to `PATH`.
  On Windows `bin/verilog2systemc.bat` does not set `CLASSPATH`; run `setup_env.bat` first.
- Licence: a valid licence file is required at start-up (invalid: exit status 10). The
  feature `VERILOG2SYSTEMC` is checked only when the SystemC files are written; if it is
  missing, the licence-failure message is printed, no module files are written and the
  exit status stays 0. The licence file is searched in this order:
  `$EDAUTILS_LICENSE_FILE`, `./edautils.lic` (run directory), `$HOME/edautils.lic`,
  `$EDAUTILS_ROOT/edautils.lic`.
- Optional environment: `JAVA_FLAGS` (passed to the JVM, e.g. `-Xmx8g`; with no heap option in it the launcher adds `-Xmx` sized to the machine (`bin/eu_heap.sh`: the largest of 64/32/16/12/8/4 GB within 3/4 of physical or cgroup memory, else 2 GB; `EDAUTILS_MAX_HEAP_GB` caps it)),
  `EDAUTILS_LOG_FILE` / `EDAUTILS_APPEND_LOG_FILE` (log file name; the second appends),
  `EDAUTILS_DISABLE_USAGE_TRACKING=true`, `EDAUTILS_PRINT_STACK_TRACE` (stack traces on
  internal exceptions), `EDAUTILS_ENABLE_DEBUG_ENVIRONMENT=1` (debug messages),
  `EDAUTILS_LIBRARY_MAP_FILE` (library map for `-dump`/`-restore`).
- To build/run the generated code (not needed for translation): g++, GNU make and a SystemC
  installation. The generated `Makefile` uses `SYSTEMC_ROOT ?= /software/systemc`, so set
  `SYSTEMC_ROOT` in the environment; it links with `-lsystemc` from `lib-linux`,
  `lib-linux64` or `lib`.

### Invocation

```
verilog2systemc -in <file.v> | -f <filelist>  -top <module>  [-outdir <dir>]  [options]
```

Tool-specific options:

| Option | Meaning |
|---|---|
| `-top <module>` | Top module to translate (mandatory; missing -> usage printed, nothing written) |
| `-outdir <dir>` | Directory for the generated C++ files (default `outdir`) |
| `-noelab` | Do not elaborate the top module |
| `-two_value_logic` | Use two-value logic types (faster simulation) |
| `-write_driver_monitor` | Also write `driver_<top>` and `monitor_<top>` `.hxx`/`.cxx` files |
| `-help`, `-h` | Print usage and exit |

Common Verilog-reader options (shared parser, `FVPProcessCmdLineArgs`): `-in <file>`,
`-f <filelist>`, `-excludefilelist <file>`, `+incdir+<p1>+<p2>`, `+define+A+B=1`, `-v95`
(no SystemVerilog keywords), `-nowildcard`, `-nokeywords a:b`, `-blackbox` (blackbox
undefined modules), `-declare_wires_for_undefined_obects`, `-dump`, `-restore <units>`,
`-work <lib>`, `-mapfile <ini>`, `-l <log>` / `-la <log>` (log file / append),
`-quiet`, `-nobanner`, `-dbg`, `-suppress <id1:id2>`, `-user <email>`, `-encryption_key`,
`-encryption_algorithm`, `-private_key_file`, `-public_key_file`.
An unrecognised option is an error (message 7034 "Unrecognized option") followed by the usage.

### Inputs / Outputs

- Reads: the Verilog files from `-in` / `-f` and their `` `include`` files.
- Writes: `<outdir>/<module>.hxx` and `<outdir>/<module>.cxx` for the top and its
  sub-modules, `<outdir>/main_sc.cxx`, optionally the driver/monitor files, and `Makefile`
  in the **current directory** (overwritten). The parser also creates `myEdaUtilsWork/`.
- Log: `verilog2systemc.log` in the current directory (override with `-l`/`-la` or
  `EDAUTILS_LOG_FILE`). Every console line is also written to the log.

### Exit status and messages

- 0 on a normal finish, **including runs that reported errors** (missing `-top`, top module
  not found, parse errors all return 0). 10 = invalid licence. 1 = `EDAUTILS_ROOT`
  missing/invalid.
- Message format: `verilog2systemc: <Severity>: <id>: <text>`, severity one of `Error`,
  `Fatal Error`, `Warning`, `Note`, `Programming Error`; `<id>` is a 5-digit message number.
  Usage lines have no severity or id. Top not found: Error 3293 "The top module named <top>
  not found ...". Message 405 is always suppressed.
- The run ends with `verilog2systemc: Note: <id>: Found N error(s) and M warning(s) ...`.
  This summary is **not printed with `-nobanner`**.
- `-help` output golden:
  `tests.edautilscommandline/tests/verilog2systemc/help_msg/verilog2systemc.log.gld`.

### Examples

Shipped (`runme.csh` and `runme.bat` each; both run `make` after translation in the csh
version and set `SYSTEMC_ROOT=/software/systemc`, adjust it):

```
cd $EDAUTILS_ROOT/examples/simple_test_8          # infile.txt lists simple_test_8.v tb.v
verilog2systemc -f infile.txt -top testbench -outdir tmpdir
make

cd $EDAUTILS_ROOT/examples/tv80_mcode
verilog2systemc -in tv80_mcode.v -top tv80_mcode -outdir tmpdir
```

(`tv80_mcode/runme.bat` adds `-two_value_logic`; `runme.csh` does not.)

From the regression suite (reference:
`tests.edautilscommandline/tests/verilog2systemc/always_block/runme.csh` via
`../runme_common.csh`; the testbench `tb.v` is made with `gentbvlog` when absent):

```
verilog2systemc -suppress 56937:56276:56273:56268 -nowildcard -f infile.txt -top testbench -outdir tmpdir
make
./bin/test.exe > sim.out     # compared on its 'Simulation Time' lines
```

### Integration notes

- Non-interactive; does not read stdin. Run with `</dev/null`.
- Writes the log, `Makefile`, `myEdaUtilsWork/` and the default `outdir/` into the current
  directory: give each parallel run its own working directory.
- Set `EDAUTILS_DISABLE_USAGE_TRACKING=true` to stop usage registration.
- Success test: exit status 0 **and** the log contains `Found 0 error(s)` (do not use
  `-nobanner` if you rely on that line) **and** `<outdir>/<top>.cxx` exists. Proving the
  output compiles needs `make` with a SystemC installation.
- Known gaps (source `ISSUES.txt`): bit/part-select inside an LHS concatenation, undefined
  modules, and an empty actual in a port map are not supported.

### See also

vhdl2systemc, vlogtbgen (gentbvlog), verilog2vhdl, parseverilog.
