Languages
I have been doing lots of automatic measurements on simulated waveforms using .MEASURE
statements. The .MEASURE
statements were introduced by HSPICE and now supported by many other SPICE simulators including Spectre. I know XMODEL has a set of measurement primitives that can do almost the same things with .MEASURE
, but I find it tedious to translate all the .MEASURE
statements that I currently have. Is there a way to translate them into equivalent SystemVerilog testbenches?
Yes, there is! MODELZEN can convert .MEASURE
statements into equivalent SystemVerilog descriptions using the XMODEL measurement primitives. Here is a simple example. Assume a SPICE testbench file named meas.sp
containing some commonly used .MEASURE
statements as shown below.
* meas.sp * measuring the voltage value of 'n1' at 10ns .MEASURE TRAN level FIND V(n1) at=10n * measuring the average value of 'n1' from 10ns to 20ns .MEASURE TRAN mean AVG V(n1) from=10n to=20n * measuring when 'n2' crosses 0.5V in the rising direction after 10ns delay .MEASURE TRAN tcross WHEN V(n2)=0.5 rise=2 td=10n * measuring the voltage value of 'n3' when the 'n2' crossing event happens .MEASURE TRAN vcross FIND V(n3) WHEN V(n2)=0.5 rise=2 td=10n * measuring the transition time of 'n3' rising from 0.1V to 0.9V .MEASURE TRAN risetime TRIG V(n3) val=0.1 rise=2 + TARG V(n3) val=0.9 rise=2
To convert this file into an equivalent SystemVerilog testbench file, say, meas.sv
, you can run MODELZEN on the Linux command line with the following arguments:
$ modelzen meas.sp -o meas.sv
The content of the meas.sv
file generated by MODELZEN is listed below. You can see that MODELZEN translated each of the .MEASURE
statements into an equivalent SystemVerilog description using the trig_*
and meas_*
primitives of XMODEL. Please refer to this Q&A posting (link) for more information on these measurement primitives. Note that the variables containing the measurement results (e.g., level
, mean
, vcross
, tcross
, and risetime
in this example) are defined as real
types, making it easy to write assertion checks examining whether the results within the expected range, for example, using simple if
statements.
`include "xmodel.h" // TOP-LEVEL MODULE __TOP__ module __TOP__ (); parameter real m = 1.0; xreal n1; xreal n2; xreal n3; // .MEASURE TRAN level FIND V(n1) 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(n1), .trig(DEVO_MEAS_level_trig), .out(level)); // .MEASURE TRAN mean AVG V(n1) from=10n to=20n real mean; xbit DEVO_MEAS_mean_trig1, DEVO_MEAS_mean_trig2; trig_time #(.delay(1e-08), .period(0)) DEVO_MEAS_mean_1 (.out(DEVO_MEAS_mean_trig1)); trig_time #(.delay(2e-08), .period(0)) DEVO_MEAS_mean_2 (.out(DEVO_MEAS_mean_trig2)); meas_avg DEVO_MEAS_mean_3 (.from(DEVO_MEAS_mean_trig1), .to(DEVO_MEAS_mean_trig2), .in(n1), .out(mean)); // .MEASURE TRAN vcross FIND V(n3) WHEN V(n2)=0.5 rise=2 td=10n real vcross; xbit DEVO_MEAS_vcross_trig; trig_rise #(.threshold(0.5), .delay(1e-08), .times(2)) DEVO_MEAS_vcross_1 (.in(n2), .out(DEVO_MEAS_vcross_trig)); meas_value DEVO_MEAS_vcross_2 (.in(n3), .trig(DEVO_MEAS_vcross_trig), .out(vcross)); // .MEASURE TRAN tcross WHEN V(n2)=0.5 rise=2 td=10n real tcross; meas_rise #(.threshold(0.5), .delay(1e-08), .times(2)) DEVO_MEAS_tcross_1 (.in(n2), .out(tcross)); // .MEASURE TRAN risetime TRIG V(n3) val=0.1 rise=2 TARG V(n3) val=0.9 rise=2 real risetime; xbit DEVO_MEAS_risetime_trig1, DEVO_MEAS_risetime_trig2; trig_rise #(.threshold(0.1), .delay(0), .times(2)) DEVO_MEAS_risetime_1 (.in(n3), .out(DEVO_MEAS_risetime_trig1)); trig_rise #(.threshold(0.9), .delay(0), .times(2)) DEVO_MEAS_risetime_2 (.in(n3), .out(DEVO_MEAS_risetime_trig2)); meas_delay DEVO_MEAS_risetime_3 (.from(DEVO_MEAS_risetime_trig1), .to(DEVO_MEAS_risetime_trig2), .out(risetime)); endmodule
Please login or Register to submit your answer
저는 그동안 수많은 .MEASURE
구문을 활용해 시뮬레이션 파형들부터 원하는 특성들을 자동측정했습니다. 참고로 .MEASURE
구문은 HSPICE에 의해 처음 도입되었지만, 이제는 Spectre를 포함한 많은 SPICE 시뮬레이터들이 지원하고 있는 아주 편리한 기능입니다. XMODEL에도 이 .MEASURE
구문들과 거의 같은 측정을 수행할 수 있는 measurement primitive들이 제공되고 있는 것을 알고 있지만, 지금까지 쌓아온 .MEASURE
구문들을 다시 일일이 measurement primitive들로 다시 옮겨쓰는 것은 엄두가 안납니다. 가지고 있는 .MEASURE
구문을 동등한 기능을 하는 SystemVerilog 테스트벤치로 자동변환하는 방법이 있나요?
Yes, there is! MODELZEN can convert .MEASURE
statements into equivalent SystemVerilog descriptions using the XMODEL measurement primitives. Here is a simple example. Assume a SPICE testbench file named meas.sp
containing some commonly used .MEASURE
statements as shown below.
* meas.sp * measuring the voltage value of 'n1' at 10ns .MEASURE TRAN level FIND V(n1) at=10n * measuring the average value of 'n1' from 10ns to 20ns .MEASURE TRAN mean AVG V(n1) from=10n to=20n * measuring when 'n2' crosses 0.5V in the rising direction after 10ns delay .MEASURE TRAN tcross WHEN V(n2)=0.5 rise=2 td=10n * measuring the voltage value of 'n3' when the 'n2' crossing event happens .MEASURE TRAN vcross FIND V(n3) WHEN V(n2)=0.5 rise=2 td=10n * measuring the transition time of 'n3' rising from 0.1V to 0.9V .MEASURE TRAN risetime TRIG V(n3) val=0.1 rise=2 + TARG V(n3) val=0.9 rise=2
To convert this file into an equivalent SystemVerilog testbench file, say, meas.sv
, you can run MODELZEN on the Linux command line with the following arguments:
$ modelzen meas.sp -o meas.sv
The content of the meas.sv
file generated by MODELZEN is listed below. You can see that MODELZEN translated each of the .MEASURE
statements into an equivalent SystemVerilog description using the trig_*
and meas_*
primitives of XMODEL. Please refer to this Q&A posting (link) for more information on these measurement primitives. Note that the variables containing the measurement results (e.g., level
, mean
, vcross
, tcross
, and risetime
in this example) are defined as real
types, making it easy to write assertion checks examining whether the results within the expected range, for example, using simple if
statements.
`include "xmodel.h" // TOP-LEVEL MODULE __TOP__ module __TOP__ (); parameter real m = 1.0; xreal n1; xreal n2; xreal n3; // .MEASURE TRAN level FIND V(n1) 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(n1), .trig(DEVO_MEAS_level_trig), .out(level)); // .MEASURE TRAN mean AVG V(n1) from=10n to=20n real mean; xbit DEVO_MEAS_mean_trig1, DEVO_MEAS_mean_trig2; trig_time #(.delay(1e-08), .period(0)) DEVO_MEAS_mean_1 (.out(DEVO_MEAS_mean_trig1)); trig_time #(.delay(2e-08), .period(0)) DEVO_MEAS_mean_2 (.out(DEVO_MEAS_mean_trig2)); meas_avg DEVO_MEAS_mean_3 (.from(DEVO_MEAS_mean_trig1), .to(DEVO_MEAS_mean_trig2), .in(n1), .out(mean)); // .MEASURE TRAN vcross FIND V(n3) WHEN V(n2)=0.5 rise=2 td=10n real vcross; xbit DEVO_MEAS_vcross_trig; trig_rise #(.threshold(0.5), .delay(1e-08), .times(2)) DEVO_MEAS_vcross_1 (.in(n2), .out(DEVO_MEAS_vcross_trig)); meas_value DEVO_MEAS_vcross_2 (.in(n3), .trig(DEVO_MEAS_vcross_trig), .out(vcross)); // .MEASURE TRAN tcross WHEN V(n2)=0.5 rise=2 td=10n real tcross; meas_rise #(.threshold(0.5), .delay(1e-08), .times(2)) DEVO_MEAS_tcross_1 (.in(n2), .out(tcross)); // .MEASURE TRAN risetime TRIG V(n3) val=0.1 rise=2 TARG V(n3) val=0.9 rise=2 real risetime; xbit DEVO_MEAS_risetime_trig1, DEVO_MEAS_risetime_trig2; trig_rise #(.threshold(0.1), .delay(0), .times(2)) DEVO_MEAS_risetime_1 (.in(n3), .out(DEVO_MEAS_risetime_trig1)); trig_rise #(.threshold(0.9), .delay(0), .times(2)) DEVO_MEAS_risetime_2 (.in(n3), .out(DEVO_MEAS_risetime_trig2)); meas_delay DEVO_MEAS_risetime_3 (.from(DEVO_MEAS_risetime_trig1), .to(DEVO_MEAS_risetime_trig2), .out(risetime)); endmodule
Please login or Register to submit your answer