DE2-115 開發 以BCD to 7-Segment 解碼器 為例(Verilog behavioral modeling )
參考來源:http://163.28.10.78/content/vocation/control/tp_nh/control/tp_nh/logic/ch8/p3.htm
BCD對七段顯示器解碼器
七段顯示器原理
(一)排列方式
P:POINT 小數點 CM:COMMON 共同腳 |
(二)顯示十進位數字
(三)顯示原理:
七段顯示器每一節段代表一個發光二極體(LED),而每一個LED之陽極接在一起成為共同腳,而各陰極即分別為a……….g , p之接腳,共同腳接正電源,將要顯示之節段接腳輸入低電位,相對之節段LED即可發光,此乃共陽極之七段顯示器;共陰極之七段顯示器即各LED陰極接成共同腳接至地電位,而各相對顯示之LED接腳需接高電位。
七段顯示解碼 / 驅動器
7447:共陽極七段顯示解碼 / 驅動器
7448:共陰極七段顯示解碼 / 驅動器
(一)BCD對共陽極七段顯示器解碼真值表
7447接腳圖
LT:Lamp Test 顯示測器
BI:Blamking Iutput 遮沒輸入
RBO:Ripple Blamking Output預先遮沒輸出
RBI:Ripple Blamking Input預先遮沒輸入
(三)7447控制信號真值表
module BCD_to_7SEG(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;
segment7(SW[3:0],HEX0);
endmodule
//Verilog module.
module segment7(bcd,seg);
//Declare inputs,outputs and internal variables.
input [3:0] bcd;
output [6:0] seg;
reg [6:0] seg;
//always block for converting bcd digit into 7 segment format
always @(bcd)
begin
case (bcd) //case statement
0 : seg = 7'b100_0000; //segG, segF, segE, segD, segC, segB, segA,
1 : seg = 7'b111_1001;
2 : seg = 7'b010_0100;
3 : seg = 7'b011_0000;
4 : seg = 7'b001_1001;
5 : seg = 7'b001_0010;
6 : seg = 7'b000_0011;
7 : seg = 7'b111_1000;
8 : seg = 7'b000_0000;
9 : seg = 7'b001_1000;
10 : seg = 7'b010_0111;
11 : seg = 7'b011_0011;
12 : seg = 7'b001_1101;
13 : seg = 7'b011_0110;
14 : seg = 7'b000_0111;
15 : seg = 7'b111_1111;
//switch off 7 segment character when the bcd digit is not a decimal number.
default : seg = 7'b1111111;
endcase
end
endmodule
沒有留言:
張貼留言