Languages

CommunityCategory: MODELZENTranslating HSPICE or Spectre testbenches into XMODEL’s equivalent testbenches

MODELZEN

Translating HSPICE or Spectre testbenches into XMODEL’s equivalent testbenches

SA Support Team Staff 2019-07-12

I want to reuse the existing HSPICE or Spectre simulation testbenches for XMODEL simulations. I know I can use them as-is by running Verilog-SPICE co-simulations, but for faster speeds, I think it would be better to convert the SPICE testbench into an XMODEL equivalent testbench and run the simulation entirely in XMODEL. Is there a way to avoid manual work?

1 Answers
Best Answer
SA Support Team Staff 2019-07-12

Fortunately, there is! If your HSPICE or Spectre testbench is described in a text file format, MODELZEN can read the file and convert its significant portion into an equivalent XMODEL testbench. If the HSPICE or Spectre testbench is described in other formats, such as with Cadence ADE, you can first extract the SPICE/Spectre testbench file from it and convert the resulting file to an XMODEL testbench.

For instance, consider a HSPICE testbench file named “tb_hspice.sp” listed below:

tb_hspice.sp:

* SPICE testbench example

* parameters
.param sup=1.2
+      amp=2.0


* stimuli sources
v0 vdd gnd dc=sup
v1 vss gnd dc=0

v2 vpwl gnd PWL ( 0 0 10n 1.0 15n 1.0 20n 0 )
v3 vpls gnd DC=0 PULSE (0 1.5 10n 1n 1n 20n 40n)
v4 vsin gnd SIN (0 amp 1MEG)

* DUT instance
X1 n1 n2 n3 subckt_DUT p1=1 p2=2

* measurements
.measure tran delay trig v(n1) val=0.5 rise=1 targ v(n2) val=0.5 rise=1
.measure tran level find v(n3) at=10n

You can convert it into an equivalent XMODEL testbench by running MODELZEN in the command line with the following options:

modelzen tb_hspice.sp -o tb_hspice.sv --top TB

where the -o option specifies the output filename and the --top option specifies the name of the top-level module (default: __TOP__).

The resulting XMODEL testbench file “tb_hspice.sv” is as follows:

tb_hspice.sv:

`include "xmodel.h"

// TOP-LEVEL MODULE TB
module TB ();

parameter real m = 1.0;

xreal n1;
xreal n2;
xreal n3;
xreal vdd;
xreal vpls;
xreal vpwl;
xreal vsin;
xreal vss;

subckt_DUT #(.p1(1), .p2(2), .m(m)) X1 (n1, n2, n3);
vsource #(.mode("dc"), .dc(1.2), .m(m)) v0 (.pos(vdd), .neg(`ground), .in(`ground));
vsource #(.mode("dc"), .dc(0), .m(m)) v1 (.pos(vss), .neg(`ground), .in(`ground));
xreal XMODEL_VPWL_v2;
pwl_gen #(.data('{0,0,1e-08,1,1.5e-08,1,2e-08,0}), .repeat_pos(0), .period(-1), .delay(0)) XMODEL_VPWL_INST_v2 (XMODEL_VPWL_v2);
vsource #(.m(m)) v2 (.pos(vpwl), .neg(`ground), .in(XMODEL_VPWL_v2));
xreal XMODEL_VSIN_v4;
sin_gen #(.offset(0), .amp(2), .freq(1e+06)) XMODEL_VSIN_INST_v4 (XMODEL_VSIN_v4);
vsource #(.m(m)) v4 (.pos(vsin), .neg(`ground), .in(XMODEL_VSIN_v4));
xreal XMODEL_VPWL_v3;
pwl_gen #(.data('{0,0,1e-08,0,1.1e-08,1.5,3.1e-08,1.5,3.2e-08,0}), .repeat_pos(1e-08), .period(4e-08), .delay(0)) XMODEL_VPWL_INST_v3 (XMODEL_VPWL_v3);
vsource #(.m(m)) v3 (.pos(vpls), .neg(`ground), .in(XMODEL_VPWL_v3));

// .measure tran level find v(n3) at=10n
real        level;
xbit        DEVO_MEAS_level_trig;
trig_time   #(.delay(1e-08), .period(0))
            DEVO_MEAS_level_1 (.out(DEVO_MEAS_level_trig));
meas_value  DEVO_MEAS_level_2 (.in(n3), .trig(DEVO_MEAS_level_trig), .out(level));

// .measure tran delay trig v(n1) val=0.5 rise=1 targ v(n2) val=0.5 rise=1
real        delay;
xbit        DEVO_MEAS_delay_trig1, DEVO_MEAS_delay_trig2;
trig_rise   #(.threshold(0.5), .delay(0), .times(1))
            DEVO_MEAS_delay_1 (.in(n1), .out(DEVO_MEAS_delay_trig1));
trig_rise   #(.threshold(0.5), .delay(0), .times(1))
            DEVO_MEAS_delay_2 (.in(n2), .out(DEVO_MEAS_delay_trig2));
meas_delay  DEVO_MEAS_delay_3 (.from(DEVO_MEAS_delay_trig1), .to(DEVO_MEAS_delay_trig2), .out(delay));

endmodule

MODELZEN can also convert testbenches described in Spectre format. The only difference from the previous example is the addition of the ‘-f spectre’ option, which spectres the input file format. The command below will convert a Spectre testbench named “tb_spectre.scs” into an equivalent XMODEL testbench “tb_speectre.sv” with the top-level module named “TB”:

modelzen tb_spectre.scs -o tb_spectre.sv --top TB -f spectre
tb_spectre.scs:

// Spectre testbench example

// parameters
parameters sup=1.2
parameters amp=2.0

// stimuli sources
v0 ( vdd gnd ) vsource dc=sup
v1 ( vss gnd ) vsource dc=0

v2 ( vpwl gnd ) vsource type=pwl wave=[0 0 10n 1.0 15n 1.0 20n 0]
v3 ( vpls gnd ) vsource type=pulse val0=0 val1=1.5 delay=10n rise=1n fall=1n width=20n period=40n
v4 ( vsin gnd ) vsource type=sine dc=0 ampl=amp freq=1MEG

// DUT instance
X1 ( n1 n2 n3 ) subckt_DUT p1=1 p2=2


tb_spectre.sv:

`include "xmodel.h"

// TOP-LEVEL MODULE TB
module TB ();

parameter real m = 1.0;

xreal gnd;
xreal n1;
xreal n2;
xreal n3;
xreal vdd;
xreal vpls;
xreal vpwl;
xreal vsin;
xreal vss;

xreal XMODEL_VPWL_v3;
pwl_gen #(.data('{0,0,1e-08,0,1.1e-08,1.5,3.1e-08,1.5,3.2e-08,0}), .repeat_pos(1e-08), .period(4e-08), .delay(0)) XMODEL_VPWL_INST_v3 (XMODEL_VPWL_v3);
vsource #(.m(m)) v3 (.pos(vpls), .neg(gnd), .in(XMODEL_VPWL_v3));
subckt_DUT #(.p1(1), .p2(2), .m(m)) X1 (n1, n2, n3);
vsource #(.mode("dc"), .dc(1.2), .m(m)) v0 (.pos(vdd), .neg(gnd), .in(`ground));
vsource #(.mode("dc"), .dc(0), .m(m)) v1 (.pos(vss), .neg(gnd), .in(`ground));
xreal XMODEL_VPWL_v2;
pwl_gen #(.data('{0,0,1e-08,1,1.5e-08,1,2e-08,0}), .repeat_pos(0), .period(-1), .delay(0)) XMODEL_VPWL_INST_v2 (XMODEL_VPWL_v2);
vsource #(.m(m)) v2 (.pos(vpwl), .neg(gnd), .in(XMODEL_VPWL_v2));
xreal XMODEL_VSIN_v4;
sin_gen #(.offset(0), .amp(2), .freq(1e+06)) XMODEL_VSIN_INST_v4 (XMODEL_VSIN_v4);
vsource #(.m(m)) v4 (.pos(vsin), .neg(gnd), .in(XMODEL_VSIN_v4));

endmodule

Please note that MODELZEN may not support all syntaxes used in your SPICE/Spectre testbench files. While MODELZEN does support a variety of HSPICE and Spectre elements and command cards for generating stimuli and measuring responses, it may not support statements that are simulator-specific or technology-specific, especially when they bear no corresponding meaning in the XMODEL testbench. Please understand that you may need to do some manual refinement in case your SPICE/Spectre testbenches contain some lines that are unsupported by MODELZEN.