Verilog

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


0 Comments:

Post a Comment

<< Home