mirror of
https://github.com/YosysHQ/yosys
synced 2025-07-24 13:18:56 +00:00
Added examples/ top-level directory
This commit is contained in:
parent
f13e387321
commit
f42218682d
17 changed files with 7 additions and 4 deletions
55
examples/cmos/cmos_cells.lib
Normal file
55
examples/cmos/cmos_cells.lib
Normal file
|
@ -0,0 +1,55 @@
|
|||
// test comment
|
||||
/* test comment */
|
||||
library(demo) {
|
||||
cell(BUF) {
|
||||
area: 6;
|
||||
pin(A) { direction: input; }
|
||||
pin(Y) { direction: output;
|
||||
function: "A"; }
|
||||
}
|
||||
cell(NOT) {
|
||||
area: 3;
|
||||
pin(A) { direction: input; }
|
||||
pin(Y) { direction: output;
|
||||
function: "A'"; }
|
||||
}
|
||||
cell(NAND) {
|
||||
area: 4;
|
||||
pin(A) { direction: input; }
|
||||
pin(B) { direction: input; }
|
||||
pin(Y) { direction: output;
|
||||
function: "(A*B)'"; }
|
||||
}
|
||||
cell(NOR) {
|
||||
area: 4;
|
||||
pin(A) { direction: input; }
|
||||
pin(B) { direction: input; }
|
||||
pin(Y) { direction: output;
|
||||
function: "(A+B)'"; }
|
||||
}
|
||||
cell(DFF) {
|
||||
area: 18;
|
||||
ff(IQ, IQN) { clocked_on: C;
|
||||
next_state: D; }
|
||||
pin(C) { direction: input;
|
||||
clock: true; }
|
||||
pin(D) { direction: input; }
|
||||
pin(Q) { direction: output;
|
||||
function: "IQ"; }
|
||||
}
|
||||
cell(DFFSR) {
|
||||
area: 18;
|
||||
ff("IQ", "IQN") { clocked_on: C;
|
||||
next_state: D;
|
||||
preset: S;
|
||||
clear: R; }
|
||||
pin(C) { direction: input;
|
||||
clock: true; }
|
||||
pin(D) { direction: input; }
|
||||
pin(Q) { direction: output;
|
||||
function: "IQ"; }
|
||||
pin(S) { direction: input; }
|
||||
pin(R) { direction: input; }
|
||||
; // empty statement
|
||||
}
|
||||
}
|
39
examples/cmos/cmos_cells.sp
Normal file
39
examples/cmos/cmos_cells.sp
Normal file
|
@ -0,0 +1,39 @@
|
|||
|
||||
.SUBCKT BUF A Y
|
||||
X1 A B NOT
|
||||
X2 B Y NOT
|
||||
.ENDS NOT
|
||||
|
||||
.SUBCKT NOT A Y
|
||||
M1 Y A Vdd Vdd cmosp L=1u W=10u
|
||||
M2 Y A Vss Vss cmosn L=1u W=10u
|
||||
.ENDS NOT
|
||||
|
||||
.SUBCKT NAND A B Y
|
||||
M1 Y A Vdd Vdd cmosp L=1u W=10u
|
||||
M2 Y B Vdd Vdd cmosp L=1u W=10u
|
||||
M3 Y A M34 Vss cmosn L=1u W=10u
|
||||
M4 M34 B Vss Vss cmosn L=1u W=10u
|
||||
.ENDS NAND
|
||||
|
||||
.SUBCKT NOR A B Y
|
||||
M1 Y A M12 Vdd cmosp L=1u W=10u
|
||||
M2 M12 B Vdd Vdd cmosp L=1u W=10u
|
||||
M3 Y A Vss Vss cmosn L=1u W=10u
|
||||
M4 Y B Vss Vss cmosn L=1u W=10u
|
||||
.ENDS NOR
|
||||
|
||||
.SUBCKT DLATCH E D Q
|
||||
X1 D E S NAND
|
||||
X2 nD E R NAND
|
||||
X3 S nQ Q NAND
|
||||
X4 Q R nQ NAND
|
||||
X5 D nD NOT
|
||||
.ENDS DLATCH
|
||||
|
||||
.SUBCKT DFF C D Q
|
||||
X1 nC D t DLATCH
|
||||
X2 C t Q DLATCH
|
||||
X3 C nC NOT
|
||||
.ENDS DFF
|
||||
|
44
examples/cmos/cmos_cells.v
Normal file
44
examples/cmos/cmos_cells.v
Normal file
|
@ -0,0 +1,44 @@
|
|||
|
||||
module BUF(A, Y);
|
||||
input A;
|
||||
output Y;
|
||||
assign Y = A;
|
||||
endmodule
|
||||
|
||||
module NOT(A, Y);
|
||||
input A;
|
||||
output Y;
|
||||
assign Y = ~A;
|
||||
endmodule
|
||||
|
||||
module NAND(A, B, Y);
|
||||
input A, B;
|
||||
output Y;
|
||||
assign Y = ~(A & B);
|
||||
endmodule
|
||||
|
||||
module NOR(A, B, Y);
|
||||
input A, B;
|
||||
output Y;
|
||||
assign Y = ~(A | B);
|
||||
endmodule
|
||||
|
||||
module DFF(C, D, Q);
|
||||
input C, D;
|
||||
output reg Q;
|
||||
always @(posedge C)
|
||||
Q <= D;
|
||||
endmodule
|
||||
|
||||
module DFFSR(C, D, Q, S, R);
|
||||
input C, D, S, R;
|
||||
output reg Q;
|
||||
always @(posedge C, posedge S, posedge R)
|
||||
if (S)
|
||||
Q <= 1'b1;
|
||||
else if (R)
|
||||
Q <= 1'b0;
|
||||
else
|
||||
Q <= D;
|
||||
endmodule
|
||||
|
12
examples/cmos/counter.v
Normal file
12
examples/cmos/counter.v
Normal file
|
@ -0,0 +1,12 @@
|
|||
module counter (clk, rst, en, count);
|
||||
|
||||
input clk, rst, en;
|
||||
output reg [2:0] count;
|
||||
|
||||
always @(posedge clk)
|
||||
if (rst)
|
||||
count <= 3'd0;
|
||||
else if (en)
|
||||
count <= count + 3'd1;
|
||||
|
||||
endmodule
|
16
examples/cmos/counter.ys
Normal file
16
examples/cmos/counter.ys
Normal 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 synth.sp
|
||||
|
7
examples/cmos/testbench.sh
Normal file
7
examples/cmos/testbench.sh
Normal file
|
@ -0,0 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -ex
|
||||
|
||||
../../yosys counter.ys
|
||||
ngspice testbench.sp
|
||||
|
29
examples/cmos/testbench.sp
Normal file
29
examples/cmos/testbench.sp
Normal file
|
@ -0,0 +1,29 @@
|
|||
|
||||
* 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 synth.sp
|
||||
.include cmos_cells.sp
|
||||
|
||||
* input signals
|
||||
Vclk clk 0 PULSE(0 3 1 0.1 0.1 0.8 2)
|
||||
Vrst rst 0 PULSE(0 3 0.5 0.1 0.1 2.9 40)
|
||||
Ven en 0 PULSE(0 3 0.5 0.1 0.1 5.9 8)
|
||||
|
||||
Xuut clk rst en out0 out1 out2 COUNTER
|
||||
|
||||
.tran 0.01 50
|
||||
|
||||
.control
|
||||
run
|
||||
plot v(clk) v(rst)+5 v(en)+10 v(out0)+20 v(out1)+25 v(out2)+30
|
||||
.endc
|
||||
|
||||
.end
|
Loading…
Add table
Add a link
Reference in a new issue