Post processing the ngspice simulation outputs using Hspice Toolbox and matlab

Before proceeding with the postprocessing we need to note a few issues:

  • the raw files generated so far are in ascii format.

    • according to ngspice documentation, by default, the raw file should be saved in binary format,
      however, this does not seem to be the case with Windows OS

  • the Hspice Toolbox requires the raw files to be in binary format.

  • unfortunately, electric's Plot Simulation Output is not able to read the latest ngspice raw binary format

  • there are three options:

1. give up visualizing the simulation outputs through electric and use ngspice CLI instead

  • in this case the most effective solution is to add the following line to the file .spiceinit.

set filetype=binary

2. start ngspice, load the simulation data, and re-save it in binary format

 

3. edit the control session (.control … .endc) of the schematic (or netlist) and write the raw file both in ascii and binary format

  • example:

.control
                                  ...

set filetype=ascii
write ./spiceout/C5_inverter_VTC_ngsp.raw v(in) v(out) dvout VSW VIL VIH VOH VOL
set filetype=binary
write ./spiceout/C5_inverter_VTC_ngsp_bin.raw v(in) v(out) dvout VSW VIL VIH VOL

                                   ...
.endc

For the moment we will “stick” with option 2.

matlab script