2020年4月12日 星期日

1 bit Full adder 全加器 (Gate level)

1 bit Full adder 全加器 (Gate level)




//=========================================
//定義一位元全加器
//(A ⊕ B) ⊕ Carry_in.  == Sum
// (A.B) or ( Carry_in A) or (A.C) === Carry_out
//=========================================
module Full_Adder(a,b,cin,sum,cout);
//宣告輸出入埠
input a,b,cin;

output sum,cout;

//宣告內部接線
wire net1,net2,net3;

xor u0(sum, a, b, cin);
and u1(net1, a, b);
and u2(net2, b, cin);
and u3(net3, cin, a);
or u4 (cout, net1, net2, net3);
endmodule


/* 
Full Adder Module for bit Addition 
*/
`timescale 100ns / 100ps 
 
module TB; 
/*
module Full_Adder (a,b,cin,sum,cout);
input a,b,cin;
output sum,cout;
*/
 
reg a;
reg b;
reg cin;

wire sum,cout;

Full_Adder UUT (a,b,cin,sum,cout);
 
initial
begin
a=1'b0; b=1'b0; cin=1'b0;
#5
a=1'b0; b=1'b0; cin=1'b1;
#5
a=1'b0; b=1'b1; cin=1'b0;
#5
a=1'b0; b=1'b1; cin=1'b1;
#5
a=1'b1; b=1'b0; cin=1'b0;
#5
a=1'b1; b=1'b0; cin=1'b1;
#5
a=1'b1; b=1'b1; cin=1'b0;
#5
a=1'b1; b=1'b1; cin=1'b1;
   
#5
$stop;
        
end
 
endmodule

沒有留言:

張貼留言

  清除項目編譯快取 執行 flutter clean 重新取得套件依賴 執行 flutter pub get 完整重新編譯並執行 flutter run 1. 新增專案套件 (pubspec.yaml) 在 Flutter 專案根目錄下的 pubspec.yaml 中,新增 ...