Kara Şimşek Uygulamasının Nexys 4 Kartı Üzerinde Gerçeklenmesi
Aşağıda verilen VHDL kodunda hızı artırılabilen veya azaltabilen kayan led uygulaması verilmiştir. 8. satırda tanımlı parametre ile kaç adet led kullanılacağı tanımlanmaktadır. 9. satırda tanımlı parametre ile sistem saat darbesi frekans değeri tanımlanmaktadır. Nexys 4 kartı üzerinde 100 MHz’lik bir saat üreteci mevcuttur. 22-24 satırlarında limit değerleri ve hız artımı/azaltımında kullanılacak parametre değeri sabit olarak tanımlanmıştır. 38-51 satırları arasında tanımlı process içerisinde led’in sola veya sağa kayma işlemleri yapılmaktadır. 53-64 satırları arasında tanımlı process içerisinde led’in sağa mı yoksa sola mı kaydırılacağı belirlenmektedir. 62-82 satırları arasında tanımlı process içerisinde ise ledin sola veya sola kayması için gerekli geçerlilik sinyali üretilmektedir. 85-102 satırları arasında tanımlı process içerisinde kayma işleminin hızlanması veya yavaşlaması için butona basılıp basılmadığının kontrol edilmektedir. Butona basılmış ise r_TIMER kontrol sinyaline ekleme veya çıkarma işlemleri yapılmaktadır. 101-110 satırları arasında tanımlı process içerisinde hızlanma veya yavaşlama için butona basılıp basılmadığını kontrol eden kontrol sinyalleri üretilmektedir.
- library IEEE;
- use IEEE.STD_LOGIC_1164.ALL;
- use IEEE.STD_LOGIC_UNSIGNED.ALL;
- use IEEE.STD_LOGIC_ARITH.ALL;
- entity kara_simsek is
- Generic(
- DATA_WIDTH : integer := 16;
- SYS_FREQ : integer := 100_000_000
- );
- Port(
- in_clk : in std_logic;
- in_rst : in std_logic;
- in_inc : in std_logic;
- in_dec : in std_logic;
- out_leds : out std_logic_vector(DATA_WIDTH - 1 downto 0)
- );
- end kara_simsek;
- architecture Behavioral of kara_simsek is
- constant c_CHNG_PARAM : integer := SYS_FREQ / 5;
- constant c_UPPER_LIMIT : integer := 3 * SYS_FREQ;
- constant c_LOWER_LIMIT : integer := c_CHNG_PARAM;
- signal r_TIMER : integer := SYS_FREQ;
- signal r_cnt : integer := 0;
- signal r_cnt_flg : std_logic := '0';
- signal r_inc : std_logic_vector(2 downto 0) := (others => '0');
- signal r_dec : std_logic_vector(2 downto 0) := (others => '0');
- signal r_leds : std_logic_vector(DATA_WIDTH - 1 downto 0) := conv_std_logic_vector(1, DATA_WIDTH);
- signal r_led_flg : std_logic := '0';
- begin
- out_leds <= r_leds;
- process(in_clk, in_rst)
- begin
- if in_rst = '1' then
- r_leds <= conv_std_logic_vector(1, DATA_WIDTH);
- elsif rising_edge(in_clk) then
- if r_cnt_flg = '1' then
- if r_led_flg = '0' then
- r_leds <= r_leds(r_leds'high - 1 downto 0) & '0';
- elsif r_led_flg = '1' then
- r_leds <= '0' & r_leds(r_leds'high downto 1);
- end if;
- end if;
- end if;
- end process;
- process(in_clk, in_rst)
- begin
- if in_rst = '1' then
- r_led_flg <= '0';
- elsif rising_edge(in_clk) then
- if r_leds(0) = '1' then
- r_led_flg <= '0';
- elsif r_leds(r_leds'high) = '1' then
- r_led_flg <= '1';
- end if;
- end if;
- end process;
- process(in_clk, in_rst)
- begin
- if in_rst = '1' then
- r_cnt <= 0;
- r_cnt_flg <= '0';
- elsif rising_edge (in_clk) then
- r_cnt_flg <= '0';
- if r_cnt < r_TIMER - 1 then
- r_cnt <= r_cnt + 1;
- else
- r_cnt <= 0;
- r_cnt_flg <= '1';
- end if;
- end if;
- end process;
- process(in_clk, in_rst)
- begin
- if in_rst = '1' then
- r_TIMER <= SYS_FREQ;
- elsif rising_edge(in_clk) then
- if r_inc(r_inc'high downto r_inc'high -1) = "01" and
- r_TIMER > c_LOWER_LIMIT then
- r_TIMER <= r_TIMER - c_CHNG_PARAM;
- elsif r_dec(r_dec'high downto r_dec'high -1) = "01" and
- r_TIMER < c_UPPER_LIMIT then
- r_TIMER <= r_TIMER + c_CHNG_PARAM;
- end if;
- end if;
- end process;
- process(in_clk, in_rst)
- begin
- if in_rst = '1' then
- r_inc <= (others => '0');
- r_dec <= (others => '0');
- elsif rising_edge(in_clk) then
- r_inc <= r_inc(r_inc'high -1 downto 0) & in_inc;
- r_dec <= r_dec(r_dec'high -1 downto 0) & in_dec;
- end if;
- end process;
- end Behavioral;
- set_property PACKAGE_PIN E3 [get_ports in_clk]
- set_property IOSTANDARD LVCMOS33 [get_ports in_clk]
- set_property PACKAGE_PIN T16 [get_ports in_dec]
- set_property IOSTANDARD LVCMOS33 [get_ports in_dec]
- set_property PACKAGE_PIN R10 [get_ports in_inc]
- set_property IOSTANDARD LVCMOS33 [get_ports in_inc]
- set_property PACKAGE_PIN F15 [get_ports in_rst]
- set_property IOSTANDARD LVCMOS33 [get_ports in_rst]
- set_property PACKAGE_PIN P2 [get_ports {out_leds[15]}]
- set_property IOSTANDARD LVCMOS33 [get_ports {out_leds[15]}]
- set_property PACKAGE_PIN R2 [get_ports {out_leds[14]}]
- set_property IOSTANDARD LVCMOS33 [get_ports {out_leds[14]}]
- set_property PACKAGE_PIN U1 [get_ports {out_leds[13]}]
- set_property IOSTANDARD LVCMOS33 [get_ports {out_leds[13]}]
- set_property PACKAGE_PIN P5 [get_ports {out_leds[12]}]
- set_property IOSTANDARD LVCMOS33 [get_ports {out_leds[12]}]
- set_property PACKAGE_PIN R1 [get_ports {out_leds[11]}]
- set_property IOSTANDARD LVCMOS33 [get_ports {out_leds[11]}]
- set_property PACKAGE_PIN V1 [get_ports {out_leds[10]}]
- set_property IOSTANDARD LVCMOS33 [get_ports {out_leds[10]}]
- set_property PACKAGE_PIN U3 [get_ports {out_leds[9]}]
- set_property IOSTANDARD LVCMOS33 [get_ports {out_leds[9]}]
- set_property PACKAGE_PIN V4 [get_ports {out_leds[8]}]
- set_property IOSTANDARD LVCMOS33 [get_ports {out_leds[8]}]
- set_property PACKAGE_PIN U6 [get_ports {out_leds[7]}]
- set_property IOSTANDARD LVCMOS33 [get_ports {out_leds[7]}]
- set_property PACKAGE_PIN U7 [get_ports {out_leds[6]}]
- set_property IOSTANDARD LVCMOS33 [get_ports {out_leds[6]}]
- set_property PACKAGE_PIN T4 [get_ports {out_leds[5]}]
- set_property IOSTANDARD LVCMOS33 [get_ports {out_leds[5]}]
- set_property PACKAGE_PIN T5 [get_ports {out_leds[4]}]
- set_property IOSTANDARD LVCMOS33 [get_ports {out_leds[4]}]
- set_property PACKAGE_PIN T6 [get_ports {out_leds[3]}]
- set_property IOSTANDARD LVCMOS33 [get_ports {out_leds[3]}]
- set_property PACKAGE_PIN R8 [get_ports {out_leds[2]}]
- set_property IOSTANDARD LVCMOS33 [get_ports {out_leds[2]}]
- set_property PACKAGE_PIN V9 [get_ports {out_leds[1]}]
- set_property IOSTANDARD LVCMOS33 [get_ports {out_leds[1]}]
- set_property PACKAGE_PIN T8 [get_ports {out_leds[0]}]
- set_property IOSTANDARD LVCMOS33 [get_ports {out_leds[0]}]