BCD Upcounter with Seven Segment display
Hi everyone, today we will learn how to use seven segment display and usage of case-when. At my one of the earlier post i did counter but now i improved the program. Now it counts from "0000" to "1001" then it goes back. I have a reset input as you see and at the end of the program there are two when-case situation. These are fır the seven segment displays at Cyclone V SoC 5CSEMA5F31 board.
library ieee; use ieee.std_logic_1164.all; use IEEE.STD_LOGIC_ARITH.ALL; use ieee.std_logic_unsigned.all; entity BCD_counter is generic (N : integer:= 3 ); port( clk : in std_logic; rst : in std_logic; y : out std_logic_vector(3 downto 0) ); end entity; architecture behavioral of BCD_counter is signal ara : std_logic_vector(3 downto 0); begin process(clk,rst) begin if rst = '1' then ara <= "0000"; -- elsif ara = "1010" then -- ara <= "0000"; elsif rising_edge(clk) then ara <= ara + "0001" ; else ara <= ara; end if; end process; y <= ara; process(y) begin case y(3 downto 0) is when "0000" => segment1 <= "1000000"; when "0001" => segment1 <= "1001111"; when "0010" => segment1 <= "0100100"; when "0011" => segment1 <= "0110000"; when "0100" => segment1 <= "0011001"; when "0101" => segment1 <= "0100100"; when "0110" => segment1 <= "0000010"; when "0111" => segment1 <= "0111000"; when "1000" => segment1 <= "0000000"; when "1001" => segment1 <= "0011000"; when "1010" => segment1 <= "0100000"; when "1011" => segment1 <= "0000011"; when "1100" => segment1 <= "1000110"; when "1101" => segment1 <= "0100001"; when "1110" => segment1 <= "0000110"; when others => segment1 <= "0001110"; end case; case y(7 downto 4) is when "0000" => segment2 <= "1000000"; when "0001" => segment2 <= "1001111"; when "0010" => segment2 <= "0100100"; when "0011" => segment2 <= "0110000"; when "0100" => segment2 <= "0011001"; when "0101" => segment2 <= "0100100"; when "0110" => segment2 <= "0000010"; when "0111" => segment2 <= "0111000"; when "1000" => segment2 <= "0000000"; when "1001" => segment2 <= "0011000"; when "1010" => segment2 <= "0100000"; when "1011" => segment2 <= "0000011"; when "1100" => segment2 <= "1000110"; when "1101" => segment2 <= "0100001"; when "1110" => segment2 <= "0000110"; when others => segment2 <= "0001110"; end case; end process; end behavioral; --ozturkgokhan.com

Modelsim Output
best wishes,
gökhan öztürk
Mart 23, 2016 tarihinde Vhdl içinde yayınlandı ve Altera, CODING, DIY, Fpga, Modelsim, programming, Quartus, Vhdl olarak etiketlendi. Kalıcı bağlantıyı yer imlerinize ekleyin. Yorum yapın.
Yorum yapın
Comments 0