Verilog

Friday, April 28, 2006

Add_half_structural

這禮拜老師教的,讓我受益很多,對於verilog的這門課,開始有了更濃厚的興趣,使用程式上,也有著很大的進步。寫verilog時,一定要按步驟走,先把基礎打好,這樣以後才能更靈活的運用它!
==================================================================

module top;
reg a,b;
wire sum,c_out;
Add_half_structural m1(sum,c_out,a,b);
initial
begin
a=0;
b=0;
#2000 $finish;
end
always
#100 a=~a;
always
#50 b=~b;
endmodule

module Add_half_structural(sum,c_out,a,b);
input a,b;
output sum,c_out;
wire c_out_bar;
xorf201 G1(sum,a,b);
nandf201 G2(c_out_bar, a,b);
invf101 G3(c_out,c_out_bar);
endmodule

module nandf201(O,A1,B1);
input A1,B1;
output O;
nand(O,A1,B1);
specify
specparam
Tpd_0_1=1.13:3.09:7.75,
Tpd_1_0=0.93:2.50:7.34;
(A1=>O)=(Tpd_0_1,Tpd_1_0);
(B1=>O)=(Tpd_0_1,Tpd_1_0);
endspecify
endmodule

module xorf201(O,A1,B1);
input A1,B1;
output O;
xor(O,A1,B1);
specify
specparam
Tpd_0_1=1.13:3.09:7.75,
Tpd_1_0=0.93:2.50:7.34;
(A1=>O)=(Tpd_0_1,Tpd_1_0);
(B1=>O)=(Tpd_0_1,Tpd_1_0);
endspecify
endmodule

module invf101(O,A1);
input A1;
output O;
not(O,A1);
specify
specparam
Tpd_0_1=1.53:4.09:6.75,
Tpd_1_0=0.53:4.50:6.34;
(A1=>O)=(Tpd_0_1,Tpd_1_0);
endspecify
endmodule



Friday, April 14, 2006

全加法器之模擬

這次上課,讓我對verilog有些陌生,單單兩個禮拜沒碰,就令我產生如此生疏,所以,要認真學一樣東西,一定要經驗去接觸它,幸好我這次只有兩個禮拜,還能找回感覺,於是,我覺得應該在我有空的時候,要多多模擬一下。
===================================================================


module top;
reg a,b,c_in;
wire sum,c_out;
all_full m1(sum,c_out,a,b,c_in);
initial
begin
a=0;
b=0;
c_in=0;
#2000 $finish;
end
always#10
a=~a;
always#20
b=~b;
always#40
c_in=~c_in;
endmodule

module all_full(sum,c_out,a,b,c_in);
input a,b,c_in;
output c_out,sum;
wire w1,w2,w3;
half_adder m1(w1,w2,a,b);
half_adder m2(sum,w3,c_in,w1);
or (c_out,w2,w3);
endmodule

module half_adder(sum,c_out,a,b);
input a,b;
output sum,c_out;
wire c_out_bar;
xor (sum,a,b);
nand (c_out_bar,a,b);
not (c_out,c_out_bar);
endmodule