Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library IEEE;
- use IEEE.STD_LOGIC_1164.ALL;
- use ieee.std_logic_arith.all;
- use ieee.std_logic_unsigned.all;
- entity sekundnik is
- Port(
- Clk : in std_logic; --:='0';
- Reset : in std_logic; --:='0';
- --Enable: out Std_logic_vector (2 downto 0);
- wyswietlacz : out STD_LOGIC_VECTOR(0 to 6));
- end sekundnik;
- architecture arch_sekundnik of sekundnik is
- component hex7seg
- PORT ( hex : IN STD_LOGIC_VECTOR(3 DOWNTO 0);
- display : OUT STD_LOGIC_VECTOR(0 TO 6));
- end component;
- signal ans: STD_LOGIC_VECTOR(3 downto 0);
- Signal Segundo : integer range 0 to 50000000 := 0;
- Signal Cont : integer range 0 to 9 := 0;
- begin
- Process(Clk, Reset, Segundo, Cont)
- begin
- if (Reset = '1') then
- Segundo <= 0;
- Cont <= 0;
- elsif (Clk'event and Clk = '1') then
- Segundo <= Segundo + 1;
- if Segundo = 50000000 then
- Cont <= Cont+1;
- case Cont is
- when 0 => ans <= "0000";
- when 1 => ans <= "0001";
- when 2 => ans <= "0010";
- when 3 => ans <= "0011";
- when 4 => ans <= "0100";
- when 5 => ans <= "0101";
- when 6 => ans <= "0110";
- when 7 => ans <= "0111";
- when 8 => ans <= "1000";
- when 9 => ans <= "1001";
- when others => ans <="1111";
- end Case;
- if (Cont = 9) then
- Cont<=0;
- Segundo<=0;
- end if;
- end if;
- end if;
- gate: hex7seg port map (ans,wyswietlacz);
- end process;
- end arch_sekundnik;
- LIBRARY ieee;
- USE ieee.std_logic_1164.all;
- ENTITY hex7seg IS
- PORT ( hex : IN STD_LOGIC_VECTOR(3 DOWNTO 0);
- display : OUT STD_LOGIC_VECTOR(0 TO 6));
- END hex7seg;
- ARCHITECTURE Behavior OF hex7seg IS
- BEGIN
- --
- -- 0
- -- ---
- -- | |
- -- 5| |1
- -- | 6 |
- -- ---
- -- | |
- -- 4| |2
- -- | |
- -- ---
- -- 3
- --
- PROCESS (hex)
- BEGIN
- CASE hex IS
- WHEN "0000" => display <= "0000001";
- WHEN "0001" => display <= "1001111";
- WHEN "0010" => display <= "0010010";
- WHEN "0011" => display <= "0000110";
- WHEN "0100" => display <= "1001100";
- WHEN "0101" => display <= "0100100";
- WHEN "0110" => display <= "1100000";
- WHEN "0111" => display <= "0001111";
- WHEN "1000" => display <= "0000000";
- WHEN "1001" => display <= "0001100";
- WHEN "1010" => display <= "0001000";
- WHEN "1011" => display <= "1100000";
- WHEN "1100" => display <= "0110001";
- WHEN "1101" => display <= "1000010";
- WHEN "1110" => display <= "0110000";
- WHEN OTHERS => display <= "0111000";
- END CASE;
- END PROCESS;
- END Behavior;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement