Install RyuSim, compile your first design, and run tests with cocotb.
Install the required build tools for your distribution. The installer will warn if these are missing, but installing them first avoids interruption.
sudo apt install clang cmake python3 python3-pip
sudo dnf install clang cmake python3 python3-pip
sudo dnf install epel-release && sudo /usr/bin/crb enable && sudo dnf install clang cmake python3 python3-pip
curl -fsSL https://ryusim.seiraiyu.com/install.sh | bash
The installer auto-detects your architecture and glibc version. See Downloads for the full list of supported distributions.
Create a simple counter design:
module counter (
input logic clk,
input logic rst,
output logic [7:0] count
);
always_ff @(posedge clk) begin
if (rst)
count <= 8'h0;
else
count <= count + 1;
end
endmodule
Compile it:
ryusim compile counter.sv --top counter
RyuSim v1 is a VPI-only simulator. Write testbenches in Python using cocotb.
Note: RyuSim support is not yet in upstream cocotb. Install cocotb from the Seiraiyu fork first — see Downloads for details.
Create a testbench file test_counter.py:
import cocotb
from cocotb.triggers import RisingEdge, FallingEdge
from cocotb.clock import Clock
@cocotb.test()
async def test_counter_counts(dut):
"""Check that the counter increments on each clock edge."""
cocotb.start_soon(Clock(dut.clk, 10, unit="ns").start())
dut.rst.value = 1
await RisingEdge(dut.clk)
await FallingEdge(dut.clk)
dut.rst.value = 0
for _ in range(10):
await RisingEdge(dut.clk)
await FallingEdge(dut.clk) # let NBA updates settle
assert dut.count.value.to_unsigned() == 10, f"Expected 10, got {dut.count.value.to_unsigned()}"
Create a Makefile in the same directory:
SIM ?= ryusim
TOPLEVEL_LANG := verilog
VERILOG_SOURCES = $(PWD)/counter.sv
TOPLEVEL = counter
COCOTB_TEST_MODULES = test_counter
include $(shell cocotb-config --makefiles)/Makefile.sim
Run the test:
make
cocotb will compile the design with RyuSim, load the VPI testbench, and report results. See the cocotb documentation for triggers, coroutines, bus drivers, and more.