Completed ngspice digital example with verilog tb

This commit is contained in:
Uros Platise 2016-03-05 08:34:05 +01:00
parent b0ac32bc03
commit b34385ec92
5 changed files with 76 additions and 9 deletions

12
examples/cmos/README Normal file
View File

@ -0,0 +1,12 @@
In this directory you will find out, how to generate a spice output
operating in two modes, analog or event-driven mode supported by ngspice
xspice sub-module.
Each test bench can be run separately by either running:
- testbench.sh, to start analog simulation or
- testbench_digital.sh for mixed-signal digital simulation.
The later case also includes pure verilog simulation using the iverilog
and gtkwave to represent the results.

View File

@ -0,0 +1,16 @@
read_verilog counter.v
read_verilog -lib cmos_cells.v
proc;; memory;; techmap;;
dfflibmap -liberty cmos_cells.lib
abc -liberty cmos_cells.lib;;
# http://vlsiarch.ecen.okstate.edu/flows/MOSIS_SCMOS/latest/cadence/lib/tsmc025/signalstorm/osu025_stdcells.lib
# dfflibmap -liberty osu025_stdcells.lib
# abc -liberty osu025_stdcells.lib;;
write_verilog synth.v
write_spice -neg 0s -pos 1s synth.sp

View File

@ -0,0 +1,33 @@
module counter_tb;
/* Make a reset pulse and specify dump file */
reg reset = 0;
initial begin
$dumpfile("counter_tb.vcd");
$dumpvars(0,counter_tb);
# 0 reset = 1;
# 4 reset = 0;
# 36 reset = 1;
# 4 reset = 0;
# 6 $finish;
end
/* Make enable with period of 8 and 6,7 low */
reg en = 1;
always begin
en = 1;
#6;
en = 0;
#2;
end
/* Make a regular pulsing clock. */
reg clk = 0;
always #1 clk = !clk;
/* UUT */
wire [2:0] count;
counter c1 (clk, reset, en, count);
endmodule

View File

@ -0,0 +1,15 @@
#!/bin/bash
# iverlog simulation
echo "Doing Verilog simulation with iverilog"
iverilog -o dsn counter.v counter_tb.v
./dsn -lxt2
gtkwave counter_tb.vcd &
# yosys synthesis
set -ex
../../yosys counter_digital.ys
# requires ngspice with xspice support enabled:
ngspice testbench_digital.sp

View File

@ -1,13 +1,4 @@
* supply voltages
.global Vss Vdd
Vss Vss 0 DC 0
Vdd Vdd 0 DC 3
* simple transistor model
.MODEL cmosn NMOS LEVEL=1 VT0=0.7 KP=110U GAMMA=0.4 LAMBDA=0.04 PHI=0.7
.MODEL cmosp PMOS LEVEL=1 VT0=-0.7 KP=50U GAMMA=0.57 LAMBDA=0.05 PHI=0.8
* load design and library
.include cmos_cells_digital.sp
.include synth.sp