Verilog Simulator API: Testbench, Waveform, Lint & Synthesis avatar

Verilog Simulator API: Testbench, Waveform, Lint & Synthesis

Pricing

Pay per event

Go to Apify Store
Verilog Simulator API: Testbench, Waveform, Lint & Synthesis

Verilog Simulator API: Testbench, Waveform, Lint & Synthesis

Run a Verilog or SystemVerilog testbench in the cloud and get pass or fail, the output, a waveform picture and a table of signal changes. Lint with Verilator and synthesize with Yosys for gate, flip-flop and FPGA LUT counts and a schematic. For AI agents that write HDL, CI and teaching.

Pricing

Pay per event

Rating

0.0

(0)

Developer

Jumble Mog

Jumble Mog

Maintained by Community

Actor stats

0

Bookmarked

2

Total users

1

Monthly active users

3 hours ago

Last modified

Features

Limited permissions

Share

Send Verilog or SystemVerilog, get back whether it works. The testbench is really simulated, the design is linted and synthesized, and the answer comes as data a program or an AI agent can act on:

  • Pass or fail for the testbench, with the reasons: $error and $fatal calls, the first output line that reports a failure, the first compile error with its file and line, or a timeout.
  • The simulation's output, everything $display printed.
  • A waveform picture of the run, and the same waveform as a table of signal values at every change, so an agent can read it without opening a viewer. The VCD file too, if you want it.
  • A lint report from Verilator: width mismatches, unused and undriven signals, missing cases, each with its code, file, line and column.
  • A synthesis report from Yosys: gates and flip-flops, or look-up tables, carry cells, memory and DSP blocks for Lattice iCE40, Lattice ECP5, Xilinx 7 series and Gowin FPGAs; inferred latches; and the logic depth between registers.
  • A schematic of the design's top module, and the synthesized netlist.

The waveform this Actor drew for its built-in example, a UART transmitter under test: a 100 MHz clock, the reset, the serial tx line sending four bytes, the bytes 55, a3, 00 and ff on the data bus, the received byte being shifted in bit by bit with unknown bits in red, and the transmitter's state, bit index and tick counter

It runs three open-source tools that hardware engineers use every day: Icarus Verilog 12 for simulation, Verilator 5 for lint and Yosys 0.52 for synthesis. Nothing to install, no license server, one HTTP call.

It's made for:

  • AI agents that write hardware code. A model that writes Verilog needs to run it. Give it this Actor as a tool and it can write a module and a testbench, see what failed and on which line, read the waveform as a table, and fix it.
  • Continuous integration for small HDL projects: point it at a repository or a ZIP and fail the pipeline when passed is false.
  • Teaching and homework checking: run a class's submissions against one testbench in a batch, with a waveform picture for each.
  • Quick checks: "does this compile", "how many LUTs is this on an iCE40", "did I infer a latch".

How to use it

  1. Paste the design into Verilog source. The testbench can be in the same text or in Testbench. Write example to try the built-in UART transmitter.
  2. Or send several files in More files, or link to them: a .v file, a ZIP, or a GitHub folder or repository.
  3. Click Start. The result has the verdict, the output, the waveform, the lint report and the synthesis report, with links to the pictures.

Everything else is optional: the FPGA family, which signals to show, a time window, defines and parameters.

What you can send

You sendWhat happens
code with a design and its testbenchSimulated, linted and synthesized
code with only a designLinted and synthesized; nothing to simulate
code and testbenchThe same as one text with both
files: {"alu.v": "...", "alu_tb.v": "...", "defs.vh": "...", "rom.hex": "..."}A project of several files; `include and $readmemh find them by name
A link to a .v or .sv file, or to a ZIP archiveThe file, or every source file in the archive
A GitHub repository or folder link (https://github.com/user/repo/tree/main/rtl)Every source file in it
designs: a list of the aboveOne result per design, in one run
exampleThe built-in UART transmitter and its testbench

The testbench is found by itself: a module that nothing else uses, has no ports and has an initial block. The design's top module is the one the testbench instantiates. Name them with top and designTop when a project has several.

Examples

All numbers are from this Actor, on the built-in example (a UART transmitter, 60 lines, with a testbench that sends four bytes and checks each one).

InputResult
{"code": "example"}passed: 1.665 us simulated, ended by $finish. Lint: clean. Synthesis for generic gates: 130 cells, 30 flip-flops, 100 gates, logic depth 9
"target": "ice40"90 cells: 45 LUTs, 30 flip-flops, 15 carry cells
"target": "ecp5"93 cells: 39 LUTs, 30 flip-flops, 8 carry cells
"target": "xilinx"60 cells: 16 LUTs, 30 flip-flops, 5 carry cells, logic depth 5
"target": "gowin"77 cells: 25 LUTs, 30 flip-flops, 19 carry cells
The example with one bit inverted in the designfailed: "5 output line(s) report a failure; the first is: FAIL: sent 55, received aa"
The example with a semicolon missingcompile error: "uart_tx.v:42: syntax error", reported by all three tools with the line
"stopAfter": "700ns"stopped early at 700 ns, with the waveform up to there

How-to examples

How to run a Verilog testbench online

Put the design and the testbench in code (or the testbench in testbench) and start the run. No simulator to install. The testbench should end with $finish. The result's passed says whether it went well, simulation.output has what it printed, and waveformUrl is the picture.

{
"code": "module counter(input clk, input rst, output reg [3:0] q);\n always @(posedge clk) q <= rst ? 4'd0 : q + 4'd1;\nendmodule",
"testbench": "module tb;\n reg clk = 0, rst = 1; wire [3:0] q;\n counter dut(clk, rst, q);\n always #5 clk = ~clk;\n initial begin\n #12 rst = 0;\n repeat (5) @(posedge clk);\n #1 if (q !== 4'd5) $error(\"q is %0d, expected 5\", q);\n $finish;\n end\nendmodule"
}

How to tell whether a testbench passed

A testbench has no exit code, so this Actor reads the signs a person would:

  • $error or $fatal was called: failed.
  • A line of the output says FAIL, failed, mismatch or error: failed. Lines that count zero, such as 0 errors or Failed: 0, don't count.
  • It didn't compile, or was still running at the time limit: failed.
  • Otherwise: passed.

reasons lists what was found. If your testbench has its own wording, set failPattern (a regular expression for a failing line) or passPattern (one the output must match, such as ALL TESTS PASSED). An empty failPattern turns the word check off, so only $error and $fatal count.

How to let an AI agent verify the Verilog it writes

Give the agent this Actor through the Apify MCP server or the API. A loop that works: the agent writes the module and a self-checking testbench, calls the Actor, and reads passed, reasons, simulation.messages (compile errors with file and line) and simulation.output. When a test fails, waveform.trace holds the signal values at every change as rows of [time, value, value, ...], which a model reads far better than a picture. Ask for the signals that matter with waveSignals and a time window with waveFrom and waveTo to keep it short.

How to count LUTs and flip-flops for an FPGA

Set target to ice40, ecp5, xilinx or gowin. synthesis.luts, flipFlops, carries, memoryBlocks and dspBlocks are the totals, and cellsByType has every cell by its vendor name (SB_LUT4, LUT6, FDRE, CARRY4...). Turn simulation off with "actions": ["synthesize"] if you only want the count.

How to find inferred latches and other design mistakes

Run with "actions": ["lint", "synthesize"]. synthesis.latches counts latches, and synthesis.messages names each signal that became one ("Latch inferred for signal q in lat: it isn't assigned on every path"). lint.messages has Verilator's findings with their codes: WIDTHTRUNC and WIDTHEXPAND for width mismatches, UNUSEDSIGNAL, UNDRIVEN, CASEINCOMPLETE, BLKSEQ and the rest.

How to get a waveform picture or a VCD file from a testbench

The picture comes by default. You don't need $dumpfile and $dumpvars in the testbench: when it has none, every signal is recorded for you. Add "vcd" to outputs for the file, which opens in GTKWave, Surfer or the WaveTrace extension of VS Code. Choose signals with waveSignals (["clk", "state", "dut.fifo.*"]), a window with waveFrom and waveTo ("200ns", "1.5us"), and radix for hex, decimal or binary values.

How to simulate a project from GitHub

Put the repository or folder link in urls. Every .v and .sv file is compiled, headers and memory files are found by `include and $readmemh, and the testbench is picked by itself. In a repository with several testbenches, name the one to run with top.

How to check many designs in one run

Send designs, a list of objects with code, testbench, files or urls each, and a name if you like. Each one is a row in the results. Fields such as target or stopAfter can be set for all at the top, or inside one design to change it there.

FAQ

Which simulator is this?

Icarus Verilog 12, with -g2012. It runs Verilog 1995, 2001 and 2005 fully and the everyday part of SystemVerilog: logic, always_ff, always_comb, enums, typedefs, packed structs, packages with import, immediate assertions. It does not run classes, UVM, program blocks with clocking, concurrent assertions (assert property) or assignment patterns ('{...}). What it can't do, it says, and that is in simulation.messages.

Does it do VHDL?

No. Verilog and SystemVerilog only.

Does it give a maximum clock frequency?

No. That needs place and route for one exact chip. synthesis.logicDepth is the next best thing without it: the longest path between two registers, counted in cells (gates, look-up tables, carry cells). Fewer levels means a faster design.

My testbench has no $finish. What happens?

A simulation with a free-running clock never ends by itself, so it runs until the time limit (30 seconds unless you change timeoutSecs) and is reported as timed out. Set stopAfter to a simulated time such as 10us to end it there instead; the verdict is then stopped early with passed empty, unless you give a passPattern.

What does a red or amber part of the waveform mean?

Red is unknown (x): a register that hasn't been reset or a wire with no driver. Amber is high impedance (z). In the table and the picture, a hex digit x is all unknown, z all high impedance, and a capital X partly unknown.

Why is my clock not in the table?

waveform.trace leaves clocks out, because every row would be a clock edge. They are listed in waveform.clocks with period and frequency, and they are in the picture.

Is the code I send safe to run here, and is my run safe from it?

The simulation runs in a throwaway folder as an unprivileged user without the run's environment, with limits on time, output and file size. Icarus Verilog has no way to run programs from Verilog code. Each run is its own container that is deleted afterwards.

Can it synthesize SystemVerilog?

The part Yosys reads, which is smaller than what the simulator takes: logic, always_ff, always_comb, enums, typedefs and packed structs. import pkg::* is not read by this Yosys version. Where it stops, synthesis.ok is false and the message has the file and line. Simulation and lint still give their answers.

What does a run cost when the design is broken?

The same as when it works: one cent. A compile error with its line, or a failed test with its reason, is the answer you asked for. Only input that can't be read at all (no source, a dead link, a file that isn't text) is free.

Input

FieldWhat it isDefault
codeVerilog or SystemVerilog source, design and testbench together or the design alone. example runs the built-in example
testbenchThe testbench, when kept apart
filesMore files by name: sources, headers, memory files
urlsLinks to .v or .sv files, ZIP archives, GitHub files, folders or repositories
actionssimulate, lint, synthesizeall three
targetgeneric, ice40, ecp5, xilinx, gowingeneric
topThe testbench modulefound
designTopThe design's top modulefound
stopAfterEnd the simulation at this simulated time: 500ns, 20us, 1ms
timeoutSecsReal seconds the simulation may run (up to 900; each 30 seconds of tool time is one cent)30
standard2012, 2009, 2005-sv, 2005, 2001, 19952012
definesMacros: {"SIMULATION": 1}
parametersParameter values for the testbench module
designParametersParameter values for the design's top module in lint and synthesis
plusargsArguments for $test$plusargs and $value$plusargs: ["seed=42"]
failPattern, passPatternRegular expressions for a failing line, and for a line the output must havewords such as FAIL
outputswaveform, vcd, schematic, netlistwaveform, schematic
waveSignalsSignals to show, by name or pattern, in orderthe testbench's own, then one level down
waveFrom, waveToThe time window of the picture and the tablethe whole run
radixhex, dec, binhex
imageWidth, maxSignals, maxTraceRows, maxOutputCharsSizes of the picture, the table and the output text1600, 32, 200, 20000
designsA list of designs for a batch

Output

One row per design. The first row is also the run's OUTPUT record, which the run-sync API endpoint returns.

FieldWhat it is
passedtrue, false, or empty when nothing was simulated or the run was cut short
verdictpassed, failed, compile error, timed out, stopped early, no testbench, not simulated
reasonsWhy it failed
summaryThe whole result in a few sentences
top, designTop, modulesThe testbench, the design's top module, and every module found
simulationcompiled, ended ($finish, $fatal, $stop, no more events, stopAfter, time limit, output limit), errors, fatals, warnings, simTime, simTimeNs, output, and messages: compiler errors and warnings as {severity, file, line, message}
waveformsignals (name, width, changes, last), clocks (name, periodNs, frequencyMhz), and trace: columns and rows of [time, value, ...] in timeUnit
lintclean, errorCount, warningCount, and messages as {severity, code, file, line, column, message}
synthesisok, target, cells, cellsByType, rtlCells (adders, multiplexers and registers before mapping), flipFlops, latches, luts, carries, memoryBlocks, dspBlocks, gates, memoryBits, logicDepth, and messages
waveformUrl, vcdUrlThe waveform picture and file
schematicUrl, schematicPngUrlThe schematic as SVG and PNG
netlistUrl, netlistVerilogUrlThe synthesized netlist as Yosys JSON and as Verilog
logUrlThe whole output, when it was too long for the row
tools, toolSecondsThe versions of the three tools, and the seconds they ran (what the price follows)
status, errorok when the design was checked; failed with the reason when the input couldn't be used

How it works

  1. The source is read just far enough to find its modules, which one is the testbench and which the design.
  2. Icarus Verilog compiles everything and runs the testbench. If the testbench doesn't record a waveform itself, a recorder is added beside it without touching your code or its timing.
  3. The waveform file is read: the signals to show are chosen, clocks are recognised, and the picture and the table are made.
  4. The design, without the testbench, goes to Verilator with all warnings on, and to Yosys, which maps it to gates or to the FPGA family you chose. The schematic is drawn by Graphviz from the design before mapping.
  5. The verdict is worked out from the compile result, $error and $fatal, the output and the time limit.

Pricing

$0.01 per design checked, whichever of the three steps you ask for, with the waveform, schematic and files included. That covers 30 seconds of work by the tools, and almost every design needs a second or two. A long simulation or a large synthesis is $0.01 more for each further 30 seconds (toolSeconds in the result says how long they ran), so with the default time limit a design costs one cent, or two when its simulation runs into the 30-second limit. A design that doesn't compile or fails its test is a result and counts. Input that can't be read is not charged. There is no start fee.

Speed

The built-in example takes about 2 seconds for everything at the default 2 GB of memory: under 0.1 s to compile and simulate, the rest for lint, synthesis and the pictures. Synthesis for Xilinx takes a second or two longer than the other targets. A run also has a few seconds of start-up, so a call that waits for the answer takes about 10 seconds. Long simulations run at the speed of Icarus Verilog on one core; run the Actor with 4 GB of memory, its most, for a full core.

Tips and limits

  • End the testbench with $finish, and report failures with $error, $fatal or a line that says FAIL.
  • %t and $time print in your testbench's own `timescale.
  • The simulation's output is kept up to 4 MB and the recorded waveform up to 150 MB; beyond that the simulation is stopped or the waveform ends early, and the result says so. For long runs, record less: a stopAfter, or your own $dumpvars on the part you need.
  • The schematic is drawn for top modules of up to 400 cells. A larger one can't be read as a picture; use the netlist.
  • Source up to 20 MB and 2,000 files per design.
  • Encrypted IP, vendor primitives without their simulation models, and mixed VHDL projects don't work.

For AI agents and developers

This Actor works with the Apify MCP server, so AI agents can call it as a tool. Pass code and testbench, and read passed, reasons, summary, simulation.output, simulation.messages and waveform.trace. A direct API call that waits for the answer:

curl -X POST "https://api.apify.com/v2/acts/jumblemog~verilog-simulator/run-sync-get-dataset-items?token=YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"code": "module inv(input a, output y); assign y = ~a; endmodule", "testbench": "module tb; reg a; wire y; inv dut(a, y); initial begin a = 0; #1 if (y !== 1) $error(\"y should be 1\"); a = 1; #1 if (y !== 0) $error(\"y should be 0\"); $finish; end endmodule"}'

run-sync instead returns the run's OUTPUT: the first design's row as JSON.

In Python, with the apify-client package:

from apify_client import ApifyClient
client = ApifyClient("YOUR_TOKEN")
run = client.actor("jumblemog/verilog-simulator").call(run_input={
"files": {"alu.v": open("alu.v").read(), "alu_tb.v": open("alu_tb.v").read()},
"target": "ice40",
"waveSignals": ["clk", "op", "a", "b", "result", "dut.carry"],
})
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
print(item["verdict"], item["reasons"])
print(item["simulation"]["output"])
print(item["synthesis"]["luts"], item["synthesis"]["flipFlops"], item["waveformUrl"])

Credits

  • Simulation: Icarus Verilog by Stephen Williams (GPL-2.0).
  • Lint: Verilator by Wilson Snyder and contributors (LGPL-3.0 or Artistic-2.0).
  • Synthesis: Yosys by Claire Wolf and contributors (ISC), with ABC from Berkeley.
  • Schematics: Graphviz (EPL). Waveform pictures: Pillow.
  • All four tools are used unmodified, as packaged by Debian; their source code is at the links.
  • The example design is this Actor's own.