2020年1月30日 星期四

DE2-115 基本邏輯閘實驗(3) Full Adder全加器

DE2-115 基本邏輯閘實驗(3) Full Adder全加器

Import  pin assignments  DE2_115_pin_assignments




// Ch04 full_adder1.v
// 一位元全加法器 (閘層敘述)
/*
module FullAdder(A, B, Ci, Co, S);
input  A, B, Ci;   // A, B, Ci 一位元輸入
output Co, S;      // S 和, Co 進位

and (AB, A, B);
and (ACi, A, Ci);
and (BCi, B, Ci);
or  (Co, AB, ACi, BCi);
xor (S, A, B, Ci);

endmodule*/

//=============================================
//gate level Full Adder
//=============================================
module FullAdder(SW, LEDR, LEDG , CLOCK_50 ,KEY
                     ,HEX0 ,HEX1 ,HEX2,HEX3 ,HEX4 ,HEX5 ,HEX6 ,HEX7 );

input  [17:0] SW;   // toggle switches
input  [3:0] KEY;       // Push bottom
input  CLOCK_50;   //Clock 27MHz , 50Mhz

output [17:0] LEDR;   // red  LEDS
output [8:0] LEDG;   // green LEDs
 
output [6:0] HEX0,HEX1,HEX2,HEX3,HEX4,HEX5,HEX6,HEX7 ; //7-segment display
assign HEX0=7'b111_1111; //off 7-segment Display
assign HEX1=7'b111_1111;
assign HEX2=7'b111_1111;  //off 7-segment Display
assign HEX3=7'b111_1111;
assign HEX4=7'b111_1111;
assign HEX5=7'b111_1111;
assign HEX6=7'b111_1111;
assign HEX7=7'b111_1111;

assign A=SW[0]; //被加數

assign B=SW[1]; //加數

assign C=SW[2];// 前一級進位


and  (AB , A, B);
and  (AC , A, C);
and  (BC , B, C);
or   (Cout, AB,BC,AC);
xor  (Sum,  A,B,C);

assign LEDR[2] = Cout;
assign LEDR[0] = Sum;


endmodule




沒有留言:

張貼留言

2024產專班 作業2 (純模擬)

2024產專班 作業2  (純模擬) 1) LED ON,OFF,TIMER,FLASH 模擬 (switch 控制) 2)RFID卡號模擬 (buttom  模擬RFID UID(不從ESP32) Node-Red 程式 [{"id":"d8886...