stankovic96

[PSDS] Counter from 0 to 999

Oct 24th, 2018
441
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.10 KB | None | 0 0
  1. library IEEE;
  2. use IEEE.STD_LOGIC_1164.ALL;
  3.  
  4.  
  5. entity counter is
  6.     Port ( en : in STD_LOGIC;
  7.            reset : in STD_LOGIC;
  8.            clk : in STD_LOGIC;
  9.            pulse : out STD_LOGIC;
  10.            ones : out STD_LOGIC_VECTOR (3 downto 0);
  11.            tens : out STD_LOGIC_VECTOR (3 downto 0);
  12.            hund : out STD_LOGIC_VECTOR (3 downto 0));
  13. end counter;
  14.  
  15. architecture Behavioral of counter is
  16.   signal pulse_s1 :std_logic;
  17.   signal pulse_s2 :std_logic;
  18.  
  19. begin
  20.   ones_cnt: entity work.dec_counter(Behavioral)
  21.             port map(
  22.               clk=>clk,
  23.               reset=>reset,
  24.               en=>en,
  25.               q=>ones,
  26.               pulse=>pulse_s1);
  27. tens_cnt: entity work.dec_counter(Behavioral)
  28.           port map(
  29.             clk=>clk,
  30.             reset=>reset,
  31.             en=>pulse_s1,
  32.             q=>tens,
  33.             pulse=>pulse_s2);
  34. hund_cnt: entity work.dec_counter(Behavioral)
  35.            port map(
  36.              clk=>clk,
  37.              reset=>reset,
  38.              en=>pulse_s2,
  39.              q=>hund,
  40.              pulse=>pulse);        
  41.  
  42.  
  43.  
  44. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment