Advertisement
PedroNY

Contador

Jul 31st, 2019
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.45 KB | None | 0 0
  1. library IEEE;
  2. use IEEE.STD_LOGIC_1164.ALL;
  3. use IEEE.numeric_std.all;
  4. use IEEE.std_logic_unsigned.all;
  5.  
  6. entity Contador is
  7.     Port ( UP_DW : in  STD_LOGIC;
  8.            CLK_In : in  STD_LOGIC;
  9.            Q : out std_logic_vector (3 downto 0)               
  10.              );
  11. end Contador;
  12.  
  13. architecture Behavioral of Contador is
  14.  
  15. signal j,k, Qaux : std_logic_vector (3 downto 0);
  16. signal y : std_logic;
  17.  
  18.  
  19.     COMPONENT FF_JK --DECLARACIÓN DEL COMPONENTE FLIP-FLOP J-K
  20.     PORT(
  21.         J : IN std_logic;
  22.         K : IN std_logic;
  23.         clk : IN std_logic;          
  24.         Q : OUT std_logic
  25.         );
  26.     END COMPONENT; 
  27.    
  28. BEGIN       -- BEHAVIORAL  
  29.    
  30.     Y<=UP_DW;  
  31.     Q <= Qaux;
  32.  
  33.     J(0) <= '1';
  34.     K(0) <= '1';
  35.    
  36.     J(1) <= (not Qaux(3)) or (y and Qaux(2)) or (not (y) and Qaux(0));
  37.     K(1) <=      Qaux(3)  or (y and Qaux(2)) or (not (y) and Qaux(0));
  38.    
  39.     J(2) <=      Qaux(3)  or (not (y) and not (Qaux(1))) or (y and Qaux(0));
  40.     K(2) <= (not Qaux(3)) or (not (y) and not (Qaux(1))) or (y and Qaux(0));
  41.    
  42.     J(3) <= (not (y) and not (Qaux(1))) or (y and Qaux(2));
  43.     K(3) <= (not (y) and not (Qaux(2))) or (y and Qaux(1));
  44.    
  45.     JK_0: FF_JK PORT MAP(
  46.         J => J(0),
  47.         K => K(0),
  48.         clk => CLK_in,
  49.         Q => Qaux(0)
  50.     );
  51.    
  52.     JK_1: FF_JK PORT MAP(
  53.         J =>  J(1),
  54.         K => K(1),
  55.         clk => CLK_in,
  56.         Q => Qaux(1)
  57.     );
  58.  
  59.     JK_2: FF_JK PORT MAP(
  60.         J => J(2),
  61.         K => K(2),
  62.         clk => CLK_in,
  63.         Q => Qaux(2)
  64.     );
  65.  
  66.     JK_3: FF_JK PORT MAP(
  67.         J => J(3),
  68.         K => K(3),
  69.         clk => CLK_in,
  70.         Q => Qaux(3)
  71.     );
  72.  
  73. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement