Skip to content

Latest commit

 

History

History

tests

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Isle Verilog Tests

Isle runs Verilog tests using cocotb and two simulators:

Before you run tests, follow the installation instructions (below).

I'm still learning cocotb, so I'm sure there'll be some mistakes and approaches that strike experienced hands as strange. Please open an issue if you have corrections or suggestions for improvement.

Run Hardware Tests

Ensure you've installed simulators and cocotb and sourced the Python venv if appropriate:

cd isle/hardware/tests
source .venv/bin/activate

Run tests using make within your chosen directory. For example, to test the TMDS encoder:

cd gfx
make tmds_encoder

Use WAVES=1 (case sensitive) to generate FST waveform files.

For example, the following creates sim_build/clut/clut.fst:

cd mem
make WAVES=1 clut

Surfer (recommended) and GTKWave support FST waveforms.

Reporting Test Failures

Many Isle tests generate random data. Ensure you include the value of COCOTB_RANDOM_SEED (from cocotb output) in your test failure report, otherwise it might be impossible to reproduce your test failure.

Simulation Support

FPGAs, such as Xilinx XC7 and Lattice ECP5, reset registers (flip-flops) to zero when configured at power-on. However, simulators such as Icarus Verilog do not. This isn't usually a problem for Isle, but there are a few cases where this breaks simulation. To handle these cases, Isle Verilog modules may include conditional initial values with BENCH, for example (from xd.v):

`ifdef BENCH  // play nicely in sim without reset
initial begin
    toggle_src = 0;
    shr_dst = 0;
end
`endif

Isle test bench makefiles enable this with:

COMPILE_ARGS += -DBENCH

I recommend defining BENCH if you're doing your own simulation of Isle Verilog modules.

Verilator Lint

There is a Verilator lint script in each hardware/book chapter directory that checks the complete design.

For example, to lint chapter 1 designs:

cd isle/hardware/book/ch01
./lint.sh

Python Lint

You can lint hardware tests from within the isle/hardware directory.

cd isle/hardware
pylint tests/gfx/tmds_encoder.py
pylint tests/book/ch03.py

Install Simulators

Install Icarus Verilog using the official instructions or run brew install icarus-verilog on macOS.

Install Verilator using the official instructions or run brew install verilator on macOS.

See boards/verilator for advice on using Verilator to run the full Isle simulation.

Install cocotb

Isle requires cocotb 2. I recommend installing cocotb inside a venv using the hardware test requirements.txt:

cd isle/hardware/tests
python3 -m venv .venv

source .venv/bin/activate
pip3 install -r requirements.txt

Troubleshooting:

  • The latest version of Python isn't necessarily supported by cocotb - check supported python versions (cocotb.org)
  • If you're having issues running cocotb on macOS, try using brew Python instead of the system one.
  • I don't recommend using the version of cocotb from OSS CAD Suite because it's not a stable release.