Verilator command line

Hi Mike,

I’m having a lot of fun with Qspice. Thanks for the great work.

I’d like to integrate the verilog build into a visual studio build. Can you provide the command line(s) that you use to run verilator and then build the dll?

Thanks
Dale

Managed to figure this out for myself, I think…

I was able to take the VerilogCounter.qsch and rebuild just using the counter.v file and ms visual studio…

First (one-time) step is to rebuild the verilated.lib file - msvs doesn’t like the dmc version. You can find the verliated.cpp file to build it from in the QSPICE/dm/verilator folder. You will need to add the text “extern” at the beginning of line 277 of verilated.h to get it to build in msvs:
extern int (*DLLprintf)(const char *fmt, …);
You probably want to keep this new verilated.lib separate from your QSPICE install so that it doesn’t interfere with DMC functionality and doesn’t get overwritten with updates.

Create a DLL project called “counter” in msvs and copy VerilogCounter.qsch and counter.v into the folder.

Open VerilogCounter.qsch
To generate the counter.cpp “DLL Main” file then right click on schematic symbol > Verilog Interface > Create C** .DLL Main Template.

The verilator command generates the other Vcounter*.cpp files:
Verilator.exe --cc -Wno-LITENDIAN counter.v
You can add this as a pre-build step in msvs with a suitable path to your QSPICE/dm/verilator folder inserted before Verilator.exe.
Project Properties>Build Events>Pre Build Event

Add your new msvs version of verilated.lib as input:
Project properties>Linker>Input>Additional dependencies

Set the project configuration to “Release” and “x86” using msvs toolbar.

Change the Output directory to the same as all the other files:
Project Properties>(check that Release and Win32 are selected)>General>Output Directory>$(SolutionDir)

Build the project and you should get counter.dll in the same folder as VerilogCounter.qsch.

You should now be able to run the sim - from the Qspice UI press the green run button in the menu.

1 Like