pythonverilogicaruscocotbverilator

How to know which simulator is used in cocotb testbench?


To test my Verilog design I'm using two differents simulators : Icarus and Verilator. It's work, but there are some variations between them.

For example, I can't read module parameter with verilator, but Icarus works.

Is there a way to know which simulator is in use in python testfile ?

I would like to write something like that :

        if SIM == 'icarus':
            self.PULSE_PER_NS = int(dut.PULSE_PER_NS)
            self.DEBOUNCE_PER_NS = int(dut.DEBOUNCE_PER_NS)
        else:
            self.PULSE_PER_NS = 4096 
            self.DEBOUNCE_PER_NS = 16777216

To be able to manage both simulator and compare them.


Solution

  • The running simulator name (as a string) can be determined using cocotb.SIM_NAME. If cocotb was not loaded from a simulator, it returns None.