cocotb-test
cocotb-test copied to clipboard
Verilator errors (ex: lint errors when verilating) are suppressed when they should be displayed
This is my first time using cocotb-test and I'm using it with Verilator. I have used Verilator fairly extensively with just C++ testbenches. I'm following some alexforencich examples for cocotb-test which are basically this:
cocotb_unit_test.py:
import os
import deps
import cocotb_test.simulator
def register(top, file, parameters=None):
def _register():
cocotb_test.simulator.run(
toplevel=top,
module=os.path.splitext(os.path.basename(file))[0],
verilog_sources=deps.get_dependencies(top + '.f'),
parameters=parameters,
compile_args=['-CFLAGS', '-Wno-deprecated',],
timescale='1ns/1ps',
waves=None,
)
return _register
syncfifo_test.py:
import cocotb
import cocotb.triggers
import cocotb_unit_test
@cocotb.test()
async def syncfifo_basic(dut):
# TODO: testbench goes here
test_dut = cocotb_unit_test.register(top="syncfifo", file=__file__)
A makefile invokes the pytest file like this:
PYTHONPATH={blah} SIM=verilator WAVES=1 pytest -o log_cli=True
While this works fine for functional RTL, I found that if you have an RTL bug that the verilator linter would normally catch for you (like a misnamed variable), cocotb-test is suppressing the Verilator output that results from the "perl verilator ..." call, so all you get is the cryptic message: "SystemExit: Process .../verilator terminated with error 1". In reality the verilator command that failed prints a ton of useful debugging information before returning that value of 1, and it seems the cocotb-test should be displaying it.