Ana Sayfa FPGA FPGA ile 7-Segment Sayıcı

FPGA ile 7-Segment Sayıcı

9 min read
0
0
4,709

Merhaba arkadaşlar,

Çizgi market sponsorluğunda tarafımıza gönderilen FPGA ile çalışmalarımız devam ediyor.FPGA kitine buradan ulaşabilirsiniz.

Bugün sizlere seven segment display üzerinde 9999 ‘a kadar aşağı ve yukarı sayan sayıcı tasarımımızı anlatmak istiyorum. Bu örneğimizde daha öncekiler gibi 50Mhz lik kristalin her yükselen kenar tetiklemesine uygun bekleme konulduktan sonra girişteki switch in uygun konumuna göre sayıcı aşağı veya yukarı saymaya başlıyor. Bu örneğimiz VHDL dilinde sıkça kullanılan  with-select  seçme yönteminin anlaşılmasında çok güzel bir örnek olduğunu düşünüyorum.

Programın entity kısmı incelendiğinde giriş olarak clock ve switch kullanılırken çıkış olarak 28 tane farklı bacak kullanıldı böyle bir proje için FPGA in 28 tane bacağını kullanmak aslında pek uygun değil bu projenin aynısı çıkış bacağı olarak 11 tane pin kullanılıp gerçekleştirilebilirdi fakat bunu yapabilmek için her bir display in ayrı ayrı enable ucu bulunması gerekiyor bu enable uçları insan gözünün algılayamayacağı bir hızda sıra ile taranarak projenin aynısı gerçekleşebilirdi. Fakat kullandığımız geliştirme kitinde display lerin böyle bir özelliği olmadığı için her bir displayi tek tek kontrol etmek zorunda kaldım.

(NOT: Kullanılan displayler ortak anotlu)

VHDL kodu:

[php]
library ieee;
use ieee.std_logic_1164.all;
library altera;
use altera.altera_syn_attributes.all;

entity seven_segment is
Port ( clk : in STD_LOGIC;
switch : in std_logic; —yukarı/aşağı
output1 : out STD_LOGIC;
output2 : out STD_LOGIC;
output3 : out STD_LOGIC;
output4 : out STD_LOGIC; — birinci display çıkışları
output5 : out STD_LOGIC;
output6 : out STD_LOGIC;
output7 : out STD_LOGIC;
output11 : out STD_LOGIC;
output12 : out STD_LOGIC;
output13 : out STD_LOGIC;
output14 : out STD_LOGIC; — ikinci display çıkışları
output15 : out STD_LOGIC;
output16 : out STD_LOGIC;
output17 : out STD_LOGIC;
output21 : out STD_LOGIC;
output22 : out STD_LOGIC;
output23 : out STD_LOGIC;
output24 : out STD_LOGIC; — üçüncü display çıkışları
output25 : out STD_LOGIC;
output26 : out STD_LOGIC;
output27 : out STD_LOGIC;
output31 : out STD_LOGIC;
output32 : out STD_LOGIC;
output33 : out STD_LOGIC;
output34 : out STD_LOGIC; — dördüncü display çıkışları
output35 : out STD_LOGIC;
output36 : out STD_LOGIC;
output37 : out STD_LOGIC);
end seven_segment;

architecture Behavioral of seven_segment is
signal temp: std_logic_vector(6 downto 0);
signal temp1: std_logic_vector(6 downto 0);
signal temp2: std_logic_vector(6 downto 0);
signal temp3: std_logic_vector(6 downto 0);
signal sayici: integer:=0;
signal sayici1: integer:=0;
signal sayici2: integer:=0;
signal sayici3: integer:=0;
signal bekle: integer:=0;
begin
process(clk)
begin
if clk’event and clk=’1′ then
if(bekle<10000000)then
bekle<=bekle+1;
else
bekle<=0;
end if;
if(bekle=0)then
if(switch=’0′)then —yukaru say
sayici<= sayici+ 1;
if sayici = 9 then
sayici<=0;
sayici1<= sayici1+ 1;
if sayici1 = 9 then
sayici1<=0;
sayici2<= sayici2+ 1;
if sayici2 = 9 then
sayici2<=0;
sayici3<=sayici3+1;
if sayici3 = 9 then
sayici3<=0;
end if;
end if;
end if;
end if;
else —aşağı say
sayici<= sayici-1;
if sayici = 0 then
sayici<=9;
sayici1<= sayici1- 1;
if sayici1 = 0 then
sayici1<=9;
sayici2<= sayici2- 1;
if sayici2 = 0 then
sayici2<=9;
sayici3<=sayici3-1;
if sayici3 = 0 then
sayici3<=9;
end if;
end if;
end if;
end if;
end if;
end if;
end if;
end process;
output1 <= temp(0); —birici display in çıkışlara atanması
output2 <= temp(1);
output3 <= temp(2);
output4 <= temp(3);
output5 <= temp(4);
output6 <= temp(5);
output7 <= temp(6);

with sayici Select
temp<= "1000000" when 0,
"1111001" when 1,
"0100100" when 2,
"0110000" when 3,
"0011001" when 4,
"0010010" when 5,
"0000010" when 6,
"1111000" when 7,
"0000000" when 8,
"0010000" when 9,
"1000000" when others;
with sayici1 Select
temp1<= "1000000" when 0,
"1111001" when 1,
"0100100" when 2,
"0110000" when 3,
"0011001" when 4,
"0010010" when 5,
"0000010" when 6,
"1111000" when 7,
"0000000" when 8,
"0010000" when 9,
"1000000" when others;
output11 <= temp1(0);
output12 <= temp1(1); —ikinci display in çıkışlara atanması
output13 <= temp1(2);
output14 <= temp1(3);
output15 <= temp1(4);
output16 <= temp1(5);
output17 <= temp1(6);
with sayici2 Select
temp2<= "1000000" when 0,
"1111001" when 1,
"0100100" when 2,
"0110000" when 3,
"0011001" when 4,
"0010010" when 5,
"0000010" when 6,
"1111000" when 7,
"0000000" when 8,
"0010000" when 9,
"1000000" when others;
output21 <= temp2(0);
output22 <= temp2(1); —üçüncü display in çıkışlara atanması
output23 <= temp2(2);
output24 <= temp2(3);
output25 <= temp2(4);
output26 <= temp2(5);
output27 <= temp2(6);
with sayici3 Select
temp3<= "1000000" when 0,
"1111001" when 1,
"0100100" when 2,
"0110000" when 3,
"0011001" when 4,
"0010010" when 5,
"0000010" when 6,
"1111000" when 7,
"0000000" when 8,
"0010000" when 9,
"1000000" when others;
output31 <= temp3(0);
output32 <= temp3(1); —dördüncü display in çıkışlara atanması
output33 <= temp3(2);
output34 <= temp3(3);
output35 <= temp3(4);
output36 <= temp3(5);
output37 <= temp3(6);
end Behavioral;

[/php]

Buna Benzer Yazılar Göster !
Daha Fazlasını Yükle - Ahmet Memeşil
Daha Fazla Göster -  FPGA

Bir cevap yazın

E-posta hesabınız yayımlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir

Bak Bakalım ?

FPGA İle PWM RC Servo Motor

19Merhabalar; Bu projemizde FPGA üzerinden servo motor sürmek için PWM sinyali oluşturacağ…