Advertisement
Simone_Monaco

count

May 18th, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 2.23 KB | None | 0 0
  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3. use ieee.numeric_std.all;
  4.  
  5. entity counters is
  6.     port (clk, rst, enWr_A, enRd_A_1, enRd_A_3, enRd_A : in std_logic;
  7.             mux_cnt : in std_logic_vector (1 downto 0);
  8.             iseven_l, cnta_is1023_h, cntn_is0_h, cnt_Nis2, cnt_Nis1 : out std_logic;
  9.             Address : out std_logic_vector (9 downto 0));
  10. end counters;
  11.  
  12. architecture behavior of counters is
  13.  
  14. component CounterN is
  15.     generic (N : integer := 10);
  16.     port (Enable, Clk, Clear, up : in std_logic;
  17.             Start : in unsigned (N-1 downto 0);
  18.             Num                  : out std_logic_vector (N-1 downto 0));
  19. end component;
  20.  
  21. component mux4to1 IS
  22.     GENERIC ( N : POSITIVE := 10) ;
  23.     PORT ( w0, w1, w2, w3  :      IN STD_LOGIC_VECTOR( ( N - 1 ) DOWNTO 0 ) ;
  24.                   s           :       IN STD_LOGIC_VECTOR (1  DOWNTO 0) ;
  25.                   f           :     OUT STD_LOGIC_VECTOR( ( N - 1 ) DOWNTO 0 ) ) ;
  26. END component;
  27.  
  28. signal w0, w1, w2, w3, addr : std_logic_vector (9 downto 0);
  29.  
  30. begin
  31.     cntW_A  : CounterN port map (Clk => clk, Enable => enWr_A,   Clear => rst, up => '1', Start => (others => '0'), Num => w0);
  32.     cntRd_A_1: CounterN port map (Clk => clk, Enable => enRd_A_1, Clear => rst, up => '0', Start => "1111111110"   , Num => w1);
  33.     cntRd_A : CounterN port map (Clk => clk, Enable => enRd_A,   Clear => rst, up => '0', Start => "1111111111" , Num => w2);
  34.     cntRd_A_3: CounterN port map (Clk => clk, Enable => enRd_A_1, Clear => rst, up => '0', Start => "1111111100"    , Num => w3);
  35.    
  36.     mux_count   : mux4to1  port map (w0 => w0, w1 => w1, w2 => w2, w3 => w3, s => mux_cnt, f => Address);
  37.     --Address <= unsigned(addr);
  38.    
  39.     iseven_l      <= w2(0);
  40.     cnta_is1023_h <= (w0(9) and w0(8) and w0(7) and w0(6) and w0(5) and w0(4) and w0(3) and w0(2) and w0(1) and w0(0)); --'1' if first counter has finished
  41.     cntn_is0_h <= (not w2(9) and not w2(8) and not w2(7) and not w2(6) and not w2(5) and not w2(4) and not w2(3) and not w2(2) and not w2(1) and not w2(0));    --'1' if counter (N count) has finished
  42.     cnt_Nis2 <= (not w2(9) and not w2(8) and not w2(7) and not w2(6) and not w2(5) and not w2(4) and not w2(3) and not w2(2) and w2(1) and not w2(0));
  43.     cnt_Nis1 <= (not w1(9) and not w1(8) and not w1(7) and not w1(6) and not w1(5) and not w1(4) and not w1(3) and not w1(2) and not w1(1) and not w1(0));
  44. end behavior;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement