How to know which simulator is used in cocotb testbench?

254 views Asked by At

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.

1

There are 1 answers

0
Qiu On BEST ANSWER

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.