What's All This Mixed-Signal Simulation Stuff Anyway ?: Rich Klinger 2006
What's All This Mixed-Signal Simulation Stuff Anyway ?: Rich Klinger 2006
1
Rich Klinger
AdvanceMS Example
1.0 Scope
We have been using AdvanceMS for mixed-signal simulations using ModelSim and Eldo.
The documentation from Mentor was enough to get us started but did not address issues
specific to our usage. This document is meant to fill in the gaps.
The circuit used in this example is a simplified version of circuits similar to what we
designed for SoC’s. It is trivial enough that it could be simulated quickly in Eldo as a
pure spice circuit without the gain of separating the digital function into verilog. The
intent is to demonstrate the mechanics of running a mixed-signal simulation using
AdvanceMS.
If you are interested in just copying a working example then copy the files listed in Table
1 and run the sim as described in section 2.2.
2
Rich Klinger
AdvanceMS Example
File Description
tb_nander.run Shell script that controls the sim
tb_nander.cmd Eldo command file. Contains sim OPTIONS, LIB, PROBE,
PARAM, MODEL, a2d and d2a, DEFWAVE statements.
tb_nander.v Verilog testbench
nander_top.v1 Top-level verilog file
nander_logic.v Verilog logic module
tb_nander_analog. Eldo spice subcircuit declarations
v
sp_nander.cir Top-level Eldo testbench netlist
nander.cir Eldo subcircuit.
pad.cir Eldo subcircuit
add_waves.do Optional file that adds waves to the waveform viewer
window
Table 1: File Summary - The files used in this example should be in the directory
example_files in the same directory where this file resides.
1
There are two versions of this file. One is in analog_src directory and is used for mixed-signal sims. There
is another copy that is the src directory, it is used for pure verilog sims. The difference is in the instantiation
of the analog circuit. The mixed-signal version instantiates a spice subcircuit, whereas the pure verilog
version instantiates a verilog behavioral model. See lines 43 -51 of nander_top.v.
3
Rich Klinger
AdvanceMS Example
tb_nander .run
tb_nander .v
nander _top.v
tb_logic.v
10 MHz D SET
Q
CL R Q
2.5 MHz
$monitor
pad
pad.cir
#################################################################
## File Name : tb_nander.run
## Author : Rich Klinger
## Date Created : 05/09/06
#################################################################
4
Rich Klinger
AdvanceMS Example
The next 2 lines delete any previous instances of the design library, SPICE, and then
creates a fresh one using the valib command. The valib command is very similar to the
ModelSim command vlib.
\rm -rf SPICE *.ini
valib SPICE
The design library is where the compiled files are put for use during the simulation. The
name of the library can be any directory name that UNIX supports, however, AdvanceMS
uses a special library called WORK during compilation, so don’t use the name
WORK/work or any name that ends in WORK/work.
The next section compiles the verilog source files with the valog command. The –ms
switch is used to specify ModelSim mode for the compilation. This is stated as a
mandatory switch in the AdvanceMS User’s Manual.2
#################################################################
## Compile the Verilog files
#################################################################
valog ../src/nander_logic.v -ms
valog ../analog_src/nander_top.v -ms
valog ../test_src/tb_nander_analog.v -ms
valog ../test_src/tb_nander.v -ms
Note the four directories; ../src/, ../analog_src/, ../test_src/, ./ The first directory, ../src/, is
where the source verilog that will be synthesized and APR’ed is stored. The second,
../analog_src/, is where analog behavioral models and other analog-only files are kept.
The third, ../test_src/, is where files used in either pure verilog or mixed-signal sims are
kept. The last, ./, is the current simulation directory.
The next section compiles the spice file with the vacom command. The –f switch forces
overwriting of existing compiled files. The –ams switch compiles the files in AdvanceMS
and then imported into ModelSim. The –spice switch indicates that the file to be
compiled is a spice file. The next item in the command, sp_nander, is the ADMS entity
name to be used for the sim. In this example the entity name is the same as the spice
subcircuit name, sp_nander. The last item is the subcircuit and file path,
sp_nander@sp_nander.cir.
#################################################################
## Compile the SPICE files
#################################################################
vacom -f -ams -spice sp_nander sp_nander@sp_nander.cir
2
AdvanceMS User’s Manual, v2.0_1, page 9-21
5
Rich Klinger
AdvanceMS Example
The last section of the run file runs the simulation using the vasim command. The –cmd
switch indicates the next item is the name of the Eldo command file to be used for the
simulation. The item after the command file is the name of the top-level entity, in our
case it is the verilog module, tb_nander, in the top-level testbench file, tb_nander.v. The
–do switch calls the do-file add_waves.do. As stated previously the do-file can contain
other commands for vasim but in this example only add wave commands are called. Also,
the last line of the do-file in this example has the command that actually starts the sim
after all files have been locked and loaded. The command is run –all, this can also be
typed into the GUI command window that will start with the vasim command.
#################################################################
## Run the sim
#################################################################
vasim -cmd tb_nander.cmd tb_nander -do add_waves.do
*****************************************************************
** File Name : tb_nander.cmd
** Author : Rich Klinger
** Date Created : 05/09/06
*****************************************************************
** Description : Eldo commands for the nander testbench.
*****************************************************************
The next section contains global declarations. Use’em if ya need’em. But most likely you
won’t.
************************************************
* Globals
************************************************
.GLOBAL 0
The next section contains simulation options using the .OPTION command. The settings
shown are for accuracy. Other OPTIONS are available. See your handy-dandy Eldo
User’s Manual for more information.
************************************************
* Options
************************************************
.OPTION
+gear
6
Rich Klinger
AdvanceMS Example
+eps= 1.0e-6
+abstol= 1.0e-15
+reltol= 1.0e-6
+vntol= 1.0e-9
The next section contains the path to the model library and the skew corner to be used.
************************************************
* Libraries
************************************************
.LIB "/usr/eda/models/eldo/prod/90nm.lib" typ
The next section contains the simulation type, TRAN, and the most efficient
convergence algorithm, RAMP, to be used during DC convergence. This was found
through trial-and-error on the TSI ADC circuit. Your mileage may vary.
************************************************
* Simulation Types
************************************************
.TRAN 1p 1u
.RAMP tran 1u
The next section contains PROBE statements to save signals in the spice circuit to the
waveform file. Unless you have changed where the signals are saved, the default is a
WDB file with the same name as the CMD file. That is, the results from this sim will be
saved to tb_nander.wdb.
************************************************
* Probes
************************************************
.PROBE tran v
.PROBE tran w
The next section contains PARAM statements that declare values for the supplies in the
spice testbench, sp_nander.cir.
************************************************
* Supplies
************************************************
.PARAM vcc3p3 = 3.3V
.PARAM vcc1p8 = 1.8V
.PARAM vcc1p0 = 1.0V
The next section contains MODELS, DEFHOOK and HOOK statements necessary for
inserting A-to-D and D-to-A converters at the spice/verilog boundary. The MODEL
7
Rich Klinger
AdvanceMS Example
statements define the A-to-D and D-to-A converters. In our example we have several
different power domains and so we need several different A-to-D and D-to-A converters.
A complete description of MODEL commands can be found in the Eldo User’s Manual.
The HOOK and DEFHOOK commands are defined in the AdvanceMS User’s Manual.
The DEFHOOK command is used to define the default converters to be inserted in nodes
that are not explicitly connected in the following HOOK statements. In this example any
ports not explicitly connected in the HOOK statements are assumed to be in the 1V
domain and are connected with the d2a_std and a2d_std converters. The HOOK
statements connect the ports that are not on the 1V domain.
************************************************
* Converters
************************************************
.MODEL a2d_std a2d mode=std_logic vth1=0.2 vth2=0.5
.MODEL d2a_std d2a mode=std_logic vhi=1.0 vlo=0 trise=1n tfall=1n
.MODEL d2a_3p3 d2a mode=std_logic vhi=3.3 vlo=0 trise=1n tfall=1n
.MODEL a2d_3p3 a2d mode=std_logic vth1=0.2 vth2=2.5
.MODEL d2a_1p8 d2a mode=std_logic vhi=1.8 vlo=0 trise=1n tfall=1n
.DEFHOOK d2a_std a2d_std
.HOOK adc1.vcc_tsi_3p3v_hv nt1.tnd1.vcc_tsi_3p3v_hv bidir
mod=a2d_3p3 mod=d2a_3p3
.HOOK adc1.vcc_tsi_1p8v_mv nt1.tnd1.vcc_tsi_1p8v_mv mod=d2a_1p8
.HOOK adc1.vcc_tsi_3p3v_hv nt1.pad1.vcc_tsi_3p3v_hv mod=d2a_3p3
.HOOK nt1.fireb_mv nt1.tnd1.fireb_mv mod=d2a_1p8
The last section contains DEFWAVE statements. As with the PROBE statements, unless
you have changed the defaults, the waveforms defined here will be saved to
tb_nander.wdb.
************************************************
* Wave Definitions
************************************************
.DEFWAVE I_1p0v V(nt1.tnd1.vcc_1p0v_lvx) - V(nt1.tnd1.vcc_1p0v_lv)
.DEFWAVE I_1p8v V(nt1.tnd1.vcc_1p8v_mvx) - V(nt1.tnd1.vcc_1p8v_mv)
.DEFWAVE I_3p3v V(nt1.tnd1.vcc_3p3v_hvx) - V(nt1.tnd1.vcc_3p3v_hv)
.DEFWAVE I_vss V(nt1.tnd1.vssx) - V(nt1.tnd1.vss)
8
Rich Klinger
AdvanceMS Example
run -all
It is recommended that you setup a sim directory structure prior to running the sim so that
you can keep track of your data. If I were you I would do that before proceeding.
If you don’t know the version number, then just do the tsetup advancems and the
available versions will be listed.
If everything is in order, then AdvanceMS will start and the sim will run. If you do not
use a do-file or do not have the run –all command at the end of the do-file then you will
need to enter run –all in the GUI command window. If you have errors in any of the
verilog files the error will be shown in the GUI command window. If you have errors in
the spice files then the errors may or may not be listed in the GUI command file. My
suggestion is that if you have an error related to not being able to load the spice file, then
make a simple testbench that calls the spice circuit and just use Eldo to get the spice
errors debugged.
As of May 2006, the default waveform viewer is EZWave and will show the results of the
sim. The waveforms listed in add_waves.do will be automatically added to the window
and updated as the sim progresses. The signals saved in the tb_nander.cmd file will need
to be selected from the signal browser in the left-hand column of the EZWave window.
9
Rich Klinger
AdvanceMS Example
#######################################################################
## Compile the Verilog files
#######################################################################
valog ../src/nander_logic.v -ms
valog ../analog_src/nander_top.v -ms
valog ../test_src/tb_nander_analog.v -ms
valog ../test_src/tb_nander.v -ms
#######################################################################
## Compile the SPICE files
#######################################################################
vacom -f -ams -spice sp_nander sp_nander@../analog_src/sp_nander.cir
#######################################################################
## Run the sim
#######################################################################
vasim -cmd tb_nander.cmd tb_nander -do add_waves.do
10
Rich Klinger
AdvanceMS Example
tb_nander.cmd
***********************************************************************
** File Name : tb_nander.cmd
** Author : Rich Klinger
** Date Created : 05/09/06
***********************************************************************
** Description : Eldo commands for the nander testbench.
***********************************************************************
************************************************
* Globals
************************************************
.GLOBAL 0
************************************************
* Options
************************************************
.OPTION
+gear
+eps= 1.0e-6
+abstol= 1.0e-15
+reltol= 1.0e-6
+vntol= 1.0e-9
************************************************
* Libraries
************************************************
.LIB "/usr/eda/models/eldo/prod/90nm.lib" typ
************************************************
* Simulation Types
************************************************
.TRAN 1p 1u
.RAMP tran 1u
************************************************
* Probes
************************************************
.PROBE tran v
.PROBE tran w
************************************************
* Supplies
************************************************
.PARAM vcc3p3 = 3.3V
.PARAM vcc1p8 = 1.8V
.PARAM vcc1p0 = 1.0V
************************************************
* Converters
11
Rich Klinger
AdvanceMS Example
************************************************
.MODEL a2d_std a2d mode=std_logic vth1=0.2 vth2=0.5
.MODEL d2a_std d2a mode=std_logic vhi=1.0 vlo=0 trise=1n tfall=1n
.MODEL d2a_3p3 d2a mode=std_logic vhi=3.3 vlo=0 trise=1n tfall=1n
.MODEL a2d_3p3 a2d mode=std_logic vth1=0.2 vth2=2.5
.MODEL d2a_1p8 d2a mode=std_logic vhi=1.8 vlo=0 trise=1n tfall=1n
.DEFHOOK d2a_std a2d_std
.HOOK nt1.vcc_tsi_3p3v_hv nt1.tnd1.vcc_tsi_3p3v_hv bidir mod=a2d_3p3
mod=d2a_3p3
.HOOK nt1.vcc_tsi_1p8v_mv nt1.tnd1.vcc_tsi_1p8v_mv mod=d2a_1p8
.HOOK nt1.fireb_mv nt1.tnd1.fireb_mv mod=d2a_1p8
************************************************
* Wave Definitions
************************************************
.DEFWAVE I_1p0v V(nt1.tnd1.vcc_1p0v_lv_r) - V(nt1.tnd1.vcc_1p0v_lv)
.DEFWAVE I_1p8v V(nt1.tnd1.vcc_1p8v_mv_r) - V(nt1.tnd1.vcc_1p8v_mv)
.DEFWAVE I_3p3v V(nt1.tnd1.vcc_3p3v_hv_r) - V(nt1.tnd1.vcc_3p3v_hv)
.DEFWAVE I_vss V(nt1.tnd1.vss_r) - V(nt1.tnd1.vss)
12
Rich Klinger
AdvanceMS Example
tb_nander.v
***********************************************************************
** File Name : tb_nander.v
** Author : Rich Klinger
** Date Created : 05/09/06
***********************************************************************
** Description : This code is the top-level testbench for the nander.
**********************************************************************/
module tb_nander;
reg in_ext;
reg rstb;
reg clk10M;
reg din;
reg fireb_mv;
reg VCC_3P3V_HV;
reg VCC_1P8V_MV;
reg VCC_1p0V_LV;
reg VSS;
reg clk2M;
wire ndout;
initial
begin
in_ext <= 0;
rstb <= 1;
clk10M <= 0;
din <= 0;
fireb_mv <= 0;
VCC_3P3V_HV <= 0;
VCC_1P8V_MV <= 0;
VCC_1p0V_LV <= 0;
VSS <= 0;
clk2M <= 0;
end
initial
begin
#100 VCC_3P3V_HV <= 0;
#100 VCC_1P8V_MV <= 0;
#100 VCC_1p0V_LV <= 0;
#100 rstb <= 0;
#100 rstb <= 1;
#100 fireb_mv <= 1;
13
Rich Klinger
AdvanceMS Example
// verilog instance
nander_top nt1
(rstb,
clk,
din,
in_ext,
ndout,
fireb_mv,
VCC_3P3V_HV,
VCC_1P8V_MV,
VCC_1p0V_LV,
VSS
);
always @(clk2M)
$monitor($time, " clk2M = %b", clk2M, " ndout = ", ndout);
endmodule
14
Rich Klinger
AdvanceMS Example
nander_top.v
***********************************************************************
** File Name : nander.v
** Author : Rich Klinger
** Date Created : 05/09/06
***********************************************************************
** Description : This code models the behavior of the nander_top
**********************************************************************/
`timescale 1 ns/100 ps
module nander_top
(rstb,
clk,
din,
in_ext,
ndout,
fireb_mv,
VCC_3P3V_HV,
VCC_1P8V_MV,
VCC_1p0V_LV,
VSS
);
/**********************************************************************
** Logic
**********************************************************************/
nander_logic lg1
(rstb,
clk,
din,
data
);
/**********************************************************************
** Verilog Behavioral Instances
**********************************************************************/
//sp_nander tnd1(data, in_ext, ndout, fireb_mv, vcc_3p3v_hv,
vcc_1p8v_mv, vcc_1p0v_lv, vss);
/**********************************************************************
** Analog Instances
**********************************************************************/
\spice.sp_nander(sp_nander) tnd1(data, in_ext, ndout, fireb_mv,
vcc_3p3v_hv, vcc_1p8v_mv, vcc_1p0v_lv, vss);
/**********************************************************************
End of top-level nander module
**********************************************************************/
endmodule //nander
15
Rich Klinger
AdvanceMS Example
nander_logic.v
************************************************************************
** File Name : nander_logic.v
** Author : Rich Klinger
** Date Created : 05/09/06
************************************************************************
** Description : This code contains logic for AdvanceMS example.
***********************************************************************
*/
`timescale 1 ns/100 ps
reg data;
endmodule //logic
16
Rich Klinger
AdvanceMS Example
tb_nander_analog.v
***********************************************************************
** File Name : tb_nander_analog.v
** Author : Rich Klinger
** Date Created : 05/09/06
***********************************************************************
** Description : This code provides modules used during testing only.
** Log notes:
**********************************************************************/
/**********************************************************************
** Analog Instance Declaration used during AdvanceMS simulations
**********************************************************************/
module sp_nander(in1_lv, in_ext, out_lv, fireb_mv, vcc_3p3v_hv,
vcc_1p8v_mv, vcc_1p0v_lv, vss);
endmodule //tb_nander
17
Rich Klinger
AdvanceMS Example
sp_nander.cir
***********************************************************************
** File Name : sp_nander.cir
** Author : Rich Klinger
** Date Created : 05/09/06
***********************************************************************
** Description : Analog Testbench for nander.
**
***********************************************************************
***********************************************************************
** Analog Testbench - Must be declared as a .subckt in Verilog-on-top
sim
***********************************************************************
.SUBCKT sp_nander in1_lv in_ext out_lv fireb_mv VCC_3P3V_HV_v
VCC_1P8V_MV_v VCC_1p0V_LV_v VSS_v
***********************************************************************
** .Includes
***********************************************************************
.INCLUDE ../analog_src/nander.cir
.INCLUDE ../analog_src/pad.cir
***********************************************************************
** Termination resistors for unused supply inputs.
***********************************************************************
Rvcc3v vcc_3p3v_hv_v 0 1000k
Rvcc2v vcc_1p8v_mv_v 0 1000k
Rvcc1v vcc_1p0v_lv_v 0 1000k
Rvssv vss_v 0 1000k
***********************************************************************
** Power Supplies
***********************************************************************
*Vcc_3p3v_hvx vcc_3p3v_hvx 0 DC = vcc3p3
*Vcc_1p8v_mvx vcc_1p8v_mvx 0 DC = vcc1p8
*Vcc_1p0v_lvx vcc_1p0v_lvx 0 DC = vcc1p0
*Vssx vssx 0 DC = 0V
** Ramping Supplies
Vcc_3p3v_hv vcc_3p3v_hv_r 0 DC = 0V PWL(0,0, 1u,0, 1.1u,vcc3p3)
Vcc_1p8v_mv vcc_1p8v_mv_r 0 DC = 0V PWL(0,0, 2u,0, 2.1u,vcc1p8)
Vcc_1p0v_lv vcc_1p0v_lv_r 0 DC = 0V PWL(0,0, 3u,0, 3.1u,vcc1p0)
Vss vss_r 0 DC = 0V
***********************************************************************
*** Analog Core circuit - nander.cir
***********************************************************************
Xnand1 in1_lv in2_hv out_lv fireb_mv vcc_3p3v_hv vcc_1p8v_mv
vcc_1p0v_lv vss nander
18
Rich Klinger
AdvanceMS Example
***********************************************************************
*** Pad
***********************************************************************
Xpad1 in_ext in2_hv vcc_1p0v_lv vcc_1p8v_mv vcc_3p3v_hv vss vss apad
.ENDS
***********************************************************************
**sp_nander
***********************************************************************
19
Rich Klinger
AdvanceMS Example
nander.cir
***********************************************************************
** File Name : nander.cir
** Author : Rich Klinger
** Date Created : 05/09/06
***********************************************************************
20
Rich Klinger
AdvanceMS Example
21
Rich Klinger
AdvanceMS Example
pad.cir
***********************************************************************
** File Name : pad.cir
** Author : Rich Klinger
** Date Created : 05/09/06
***********************************************************************
22
Rich Klinger
AdvanceMS Example
add_waves.do
add wave :tb_nander:in_ext
add wave :tb_nander:nt1:in_ext
run –all
23
Rich Klinger