cocus

TP3_A

Jun 1st, 2014
337
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 0.67 KB | None | 0 0
  1. library IEEE;
  2. use IEEE.STD_LOGIC_1164.ALL;
  3.  
  4. entity tp3_a is
  5.     Port ( S : in  STD_LOGIC;
  6.            R : in  STD_LOGIC;
  7.            lamp : out  STD_LOGIC;
  8.            rst : in  STD_LOGIC;
  9.            clk : in  STD_LOGIC);
  10. end tp3_a;
  11.  
  12. architecture Behavioral of tp3_a is
  13. signal Tr1, Tr2 : STD_LOGIC;
  14. signal Q1, Q2 : STD_LOGIC;
  15. begin
  16.     Tr1 <= Q1 and S and (not R);
  17.     Tr2 <= Q2 and R and (not S);
  18.    
  19.     process (rst, clk)
  20.     begin
  21.         if rst = '1' then Q1 <= '1'; Q2 <= '0';
  22.         elsif clk'event and clk = '1' then
  23.             if Tr1 = '1' then Q1 <= '0'; Q2 <= '1'; end if;
  24.             if Tr2 = '1' then Q2 <= '0'; Q1 <= '1'; end if;    
  25.         end if;    
  26.     end process;
  27.  
  28.     lamp <= Q2;
  29.  
  30. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment