If TOPLEVEL is not set iverilog fails with an obscure error message because there is nothing after the -s option. I recommend that Makefile.sim check for TOPLEVEL and (and other required variables) and give a clean error message.
This issue is specific to Icarus. Other simulators allow TOPLEVEL to be empty, which in cocotb will return the root handle as the dut object, and not some entity.
This issue is specific to Icarus. Other simulators allow
TOPLEVELto be empty, which in cocotb will return the root handle as the dut object, and not some entity.
@ktbarrett I tried running it without setting TOPLEVEL for verilator as well, and it failed too because of missing toplevel module name for option --top-module in verilator command.
Thanks to @haroonshafique-10xe this was closed by #2547.