Guest User

Untitled

a guest
Sep 10th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.77 KB | None | 0 0
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date:    12:51:57 07/14/2012
  6. -- Design Name:
  7. -- Module Name:    Contador - Behavioral
  8. -- Project Name:
  9. -- Target Devices:
  10. -- Tool versions:
  11. -- Description:
  12. --
  13. -- Dependencies:
  14. --
  15. -- Revision:
  16. -- Revision 0.01 - File Created
  17. -- Additional Comments:
  18. --
  19. ----------------------------------------------------------------------------------
  20. library IEEE;
  21. use IEEE.STD_LOGIC_1164.ALL;
  22.  
  23. -- Uncomment the following library declaration if using
  24. -- arithmetic functions with Signed or Unsigned values
  25. --use IEEE.NUMERIC_STD.ALL;
  26.  
  27. -- Uncomment the following library declaration if instantiating
  28. -- any Xilinx primitives in this code.
  29. --library UNISIM;
  30. --use UNISIM.VComponents.all;
  31.  
  32. entity Contador is
  33.     Port ( ClkSig : in  STD_LOGIC;
  34.            Sel : in  STD_LOGIC;
  35.            Reset : in  STD_LOGIC;
  36.            Output : out  STD_LOGIC_VECTOR (3 downto 0));
  37. end Contador;
  38.  
  39. architecture Behavioral of Contador is
  40. signal Count: Integer range 0 to 9;
  41.  
  42. begin
  43.  
  44. select_process: process
  45. begin
  46. if ClkSig'event and ClkSig = '1' then
  47.     if Reset ='1' then
  48.         if sel = '0' then
  49.                 Count<= 9;
  50.         elsif sel ='1' then
  51.                 Count<= 0;
  52.         end  if;
  53.     elsif Reset ='0' then
  54.         if sel = '0' then
  55.                 Count<= Count -1;
  56.         elsif sel ='1' then
  57.                 Count<= Count +1;
  58.         end  if;
  59.     end if;
  60. end if;
  61.  
  62. case Count is
  63.     when '0' => output<= "0000";
  64.     when '1' => output<= "0001";
  65.     when '2' => output<= "0010";
  66.     when '3' => output<= "0011";
  67.     when '4' => output<= "0100";
  68.     when '5' => output<= "0101";
  69.     when '6' => output<= "0110";
  70.     when '7' => output<= "0111";
  71.     when '8' => output<= "1000";
  72.     when '9' => output<= "1001";
  73.    
  74. end case;
  75. end process;
  76. end Behavioral;
Add Comment
Please, Sign In to add comment