Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library IEEE;
- use IEEE.STD_LOGIC_1164.ALL;
- entity liczeModule is
- Port ( clk_wejscie : in STD_LOGIC;
- sw0 : in STD_LOGIC;
- sw1 : in STD_LOGIC;
- a : out STD_LOGIC;
- b : out STD_LOGIC;
- c : out STD_LOGIC;
- d : out STD_LOGIC;
- e : out STD_LOGIC;
- f : out STD_LOGIC;
- g : out STD_LOGIC;
- an1 : out STD_LOGIC;
- an2 : out STD_LOGIC);
- end liczeModule;
- architecture Behavioral of liczeModule is
- type stany is (s0,s1);
- signal aktualny_stan,nastepny_stan: stany;
- signal wyjscie: std_logic_vector (0 to 6);
- signal licznik: integer range 0 to 499999:=0;
- signal licznikS: integer range 0 to 9999:=0;
- signal c1, c2: integer range 0 to 9:=0;
- signal tym: std_logic:='0';
- signal clk_wyjscie: std_logic;
- begin
- process (aktualny_stan, sw0)
- begin
- if(sw0='1') then
- wyjscie <= "0000001";
- end if;
- case aktualny_stan is
- when s0 =>
- case c1 is
- when 0 =>
- wyjscie <= "0000001";
- when 1 =>
- wyjscie <= "1001111";
- when 2 =>
- wyjscie <= "0010010";
- when 3 =>
- wyjscie <= "0000110";
- when 4 =>
- wyjscie <= "1001100";
- when 5 =>
- wyjscie <= "0100100";
- when 6 =>
- wyjscie <= "0100000";
- when 7 =>
- wyjscie <= "0001111";
- when 8 =>
- wyjscie <= "0000000";
- when 9 =>
- wyjscie <= "0000100";
- end case;
- an1 <= '0';
- an2 <= '1';
- nastepny_stan <= s1;
- when s1 =>
- case c2 is
- when 0 =>
- wyjscie <= "0000001";
- when 1 =>
- wyjscie <= "1001111";
- when 2 =>
- wyjscie <= "0010010";
- when 3 =>
- wyjscie <= "0000110";
- when 4 =>
- wyjscie <= "1001100";
- when 5 =>
- wyjscie <= "0100100";
- when 6 =>
- wyjscie <= "0100000";
- when 7 =>
- wyjscie <= "0001111";
- when 8 =>
- wyjscie <= "0000000";
- when 9 =>
- wyjscie <= "0000100";
- end case;
- an1 <= '1';
- an2 <= '0';
- nastepny_stan <= s0;
- end case;
- end process;
- process (clk_wejscie, sw0, sw1)
- begin
- if (rising_edge(clk_wejscie)) then
- if (licznik=100) then
- tym <= not tym;
- licznik <= 0;
- licznikS <= licznikS+1;
- else
- licznik <= licznik+1;
- end if;
- if (licznikS=9999) and (sw1='0') then
- licznikS <= 0;
- if (c2 + 1=10) then
- if (c1 + 1=10) then
- c1 <= 0;
- c2 <= 0;
- else
- c1 <= c1 + 1;
- c2 <= 0;
- end if;
- else
- c2 <= c2 + 1;
- end if;
- end if;
- if(sw0='1') then
- c1<=0;
- c2<=0;
- end if;
- end if;
- end process;
- clk_wyjscie <= tym;
- process (clk_wyjscie)
- begin
- if (rising_edge(clk_wyjscie)) then
- aktualny_stan <= nastepny_stan;
- end if;
- end process;
- a <= wyjscie(0);
- b <= wyjscie(1);
- c <= wyjscie(2);
- d <= wyjscie(3);
- e <= wyjscie(4);
- f <= wyjscie(5);
- g <= wyjscie(6);
- end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment