Apparently, there is no Verilog standard to say «hey we are on simulation here». Each software have it’s own flag for that.
Xilinx iSim
`ifdef XILINX_ISIM
// code for simulation with isim
`else
// code for synthesis
`endif
Mentor Modelsim
`ifdef MODEL_TECH
// code for simulation with modelsim
`else
// code for synthesis
`endif
Icarus Verilog
?
Cocotb
`ifdef COCOTB_SIM
// code for simulation with cocotb (should be cumulated with other simulator I think)
`else
// code for synthesis
`endif