我要喝牛奶
2003-12-25 05:28:46 UTC
題目是要做一個3-bit的full adder (有要求先做1-bit的full adder)
CI是carry in ;CO 是carry out
Input (A,B,CI) 要從0跑到127 (是BINARY表示法0~127需三位數 AB(CI) )
A:3-bit B:3-bit SUM:3-bit CI, CO :1-bit
我的問題好像是出在SUM被設定為1-bit 無法表示題目要的
可以幫我找找哪裡錯了媽 謝謝....
`timescale 100ns/100ns
module Adder1(CO,SUM,A,B,CI);
output CO,SUM;
input A,B,CI;
and a1(a1_o,A,B);
and a2(a2_o,A,CI);
and a3(a3_o,B,CI);
or o1(CO,a1_o,a2_o,a3_o);
xor xo1(SUM,A,B,CI);
specify
(A, B, CI *> CO)=1;
(A, B, CI *> SUM)=1;
endspecify
endmodule
module Adder3(CO,SUM,A,B,CI);
output CO;
output [2:0]SUM;
input [2:0]A, B;
input CI;
Adder1 add1(CO_1,SUM[0],A[0],B[0],CI);
Adder1 add2(CO_2,SUM[1],A[1],B[1],CO_1);
Adder1 add3(CO,SUM[2],A[2],B[2],CO_2);
endmodule
module test;
reg[2:0]A,B;
reg CI;
Adder3 add(CO,SUM,A,B,CI);
initial begin
A=0;
B=0;
CI=0;
SUM=3'b000;
end
always #640 A[2]=~A[2];
always #320 A[1]=~A[1];
always #160 A[0]=~A[0];
always #80 B[2]=~B[2];
always #40 B[1]=~B[1];
always #20 B[0]=~B[0];
always #10 CI=~CI;
initial begin
#1300 $finish;
end
endmodule
--
[1;37m□ 本文章由 [33mjeanie[37m 從 [32mJaiHui.f2.ntu.edu.tw[37m 發表[m
[1;37m□ 本文章由 [33mjeanie[37m 在 [32m2003/12/25 Thu 13:28:46[37m 修改[m
CI是carry in ;CO 是carry out
Input (A,B,CI) 要從0跑到127 (是BINARY表示法0~127需三位數 AB(CI) )
A:3-bit B:3-bit SUM:3-bit CI, CO :1-bit
我的問題好像是出在SUM被設定為1-bit 無法表示題目要的
可以幫我找找哪裡錯了媽 謝謝....
`timescale 100ns/100ns
module Adder1(CO,SUM,A,B,CI);
output CO,SUM;
input A,B,CI;
and a1(a1_o,A,B);
and a2(a2_o,A,CI);
and a3(a3_o,B,CI);
or o1(CO,a1_o,a2_o,a3_o);
xor xo1(SUM,A,B,CI);
specify
(A, B, CI *> CO)=1;
(A, B, CI *> SUM)=1;
endspecify
endmodule
module Adder3(CO,SUM,A,B,CI);
output CO;
output [2:0]SUM;
input [2:0]A, B;
input CI;
Adder1 add1(CO_1,SUM[0],A[0],B[0],CI);
Adder1 add2(CO_2,SUM[1],A[1],B[1],CO_1);
Adder1 add3(CO,SUM[2],A[2],B[2],CO_2);
endmodule
module test;
reg[2:0]A,B;
reg CI;
Adder3 add(CO,SUM,A,B,CI);
initial begin
A=0;
B=0;
CI=0;
SUM=3'b000;
end
always #640 A[2]=~A[2];
always #320 A[1]=~A[1];
always #160 A[0]=~A[0];
always #80 B[2]=~B[2];
always #40 B[1]=~B[1];
always #20 B[0]=~B[0];
always #10 CI=~CI;
initial begin
#1300 $finish;
end
endmodule
--
[1;37m□ 本文章由 [33mjeanie[37m 從 [32mJaiHui.f2.ntu.edu.tw[37m 發表[m
[1;37m□ 本文章由 [33mjeanie[37m 在 [32m2003/12/25 Thu 13:28:46[37m 修改[m