Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- entity lab9 is
- Port(clk_wejscie : in STD_LOGIC;
- kierunek : in STD_LOGIC;
- y0 : out STD_LOGIC;
- y1 : out STD_LOGIC;
- y2 : out STD_LOGIC;
- y3 : out STD_LOGIC);
- end lab9;
- architecture Behavioral of lab9 is
- type stany is(s0,s1,s2,s3);
- signal aktualny_stan, nastepny_stan: stany;
- signal wyjscie:std_logic_vector(0 to 3);
- signal licznik: integer range 0 to 4999999:=0;
- signal tym: std_logic:='0';
- signal clk_wyjscie: std_logic;
- begin
- process(aktualny_stan,kierunek)
- begin
- case aktualny_stan is
- when s0 =>
- wyjscie <= "0111";
- if(kierunek='0') then
- nastepny_stan<=s1;
- else
- nastepny_stan<=s3;
- end if;
- when s1 =>
- wyjscie <= "1011";
- if(kierunek='0') then
- nastepny_stan<=s2;
- else
- nastepny_stan<=s0;
- end if;
- when s2 =>
- wyjscie <= "1101";
- if(kierunek='0') then
- nastepny_stan<=s3;
- else
- nastepny_stan<=s1;
- end if;
- when s3 =>
- wyjscie <= "1110";
- if(kierunek='0') then
- nastepny_stan<=s0;
- else
- nastepny_stan<=s2;
- end if;
- end case;
- end process;
- process(clk_wejscie)
- begin
- if(rising_edge(clk_wejscie))then
- if(licznik=499999) then
- tym<=not tym;
- licznik<=0;
- else
- licznik<=licznik+1;
- 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;
- y0<=wyjscie(0);
- y1<=wyjscie(1);
- y2<=wyjscie(2);
- y3<=wyjscie(3);
- end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement