library ieee;
use ieee.std_logic_1164. all;

entity MAIN_TB is
end entity;
architecture BEH of MAIN_TB is
component MAIN is
port(
    reset	           :	IN  STD_LOGIC;
    clock	           :	IN  STD_LOGIC;
    reconfig	        :	IN  STD_LOGIC ;
    read_param	      :	IN  STD_LOGIC ;
    write_param	     :	IN  STD_LOGIC ;
    ---pll_scandataout	 :	IN  STD_LOGIC ;
    counter_param	   :	IN  STD_LOGIC_VECTOR (2 DOWNTO 0) ;
		counter_type	    :	IN  STD_LOGIC_VECTOR (3 DOWNTO 0) ;hhhh
    data_in	         :	IN  STD_LOGIC_VECTOR (8 DOWNTO 0) ; 
    ---------------------------------------------------------------
    busy             : OUT STD_LOGIC ;
    data_out	        :	OUT  STD_LOGIC_VECTOR (8 DOWNTO 0);
  		c0		             : OUT STD_LOGIC ;
		locked		         : OUT STD_LOGIC 

    
  );
end component;
-------------------------------------------------------------------------
signal reset	           :	 STD_LOGIC;
signal clock	           :	 STD_LOGIC:='0';
signal reconfig	        :	  STD_LOGIC ;
signal read_param	      :	 STD_LOGIC ;
signal write_param	     :	  STD_LOGIC ;
---signal pll_scandataout	 :	  STD_LOGIC ;
signal counter_param	   :	 STD_LOGIC_VECTOR (2 DOWNTO 0) ;
signal counter_type	    :	  STD_LOGIC_VECTOR (3 DOWNTO 0) ;
signal data_in	         :	  STD_LOGIC_VECTOR (8 DOWNTO 0) ; 
    ---------------------------------------------------------------
signal busy             :  STD_LOGIC ;
signal data_out	        :	  STD_LOGIC_VECTOR (8 DOWNTO 0);
signal c0		             :  STD_LOGIC ;
signal locked		         : STD_LOGIC ;
-----------------------------------------------------------------------
begin
  
 u1: MAIN 
port map(
    reset	           =>reset, 
    clock	           => clock	,
    reconfig	        => reconfig	,
    read_param	      => read_param,
    write_param	     => write_param,
   --- pll_scandataout	 => pll_scandataout,
    counter_param	   => counter_param,
		counter_type	    => counter_type,
    data_in	         => data_in	 , 
    ---------------------------------------------------------------
    busy             => busy ,
    data_out	        => data_out	, 
  		c0		             => c0		,
		locked		         => locked	 
  );
  
  
  
  
 reset <='1','0' after 500 ns;-----, '0' after 100 ns,'1' after 200 ns, '0' after 300 ns
 CLOCK<= not (clock) after 10 ns;-----after 3.125 ns;----Tper=10 ns<=>Freq.=100MHz
 counter_type<="0100";
 ----"0000",-----N counter
              ---- "0001" after 3.29 us,----M counter
               ----"0100" after 3.37 us,---C0 counter
             -----  "0101" after 3.57 us;---C1 counter
 ----"0100" after 12 us;-----C0 counter
 

 counter_param<=-----"100",            ----Bypass
                "000",
                "001" after 3 us,   ---Low Count
                "000" after 3.47 us,---High Count
                "001" after 10.1 us,---Low Count
                "000" after 10.6 us;---High Count
  data_in<="000000001", 
           "000001101" after 2.05 us,
           "000001010" after 10 us;
                    ------"000000010" after 3.45 us,
                  ----"000000010" after 3.51 us,
                     ----- "000000010" after 3.9 us;----,"000000111" after 10.91 us;               
 
-----------------------------------------------------------------------------------------------------------
 write_param <= '0',
                     '1' after 2.05 us, '0' after 2.07 us,
                     '1' after 3.09 us,  '0' after 3.11 us,
                     '1' after 3.53 us, '0' after 3.55 us,
                     '1' after 10.53 us, '0' after 10.55 us,
                     '1' after 10.73 us, '0' after 10.75 us;
                    
-- '0', '1' after 3.09 us,  '0' after 3.11 us,---------Write to N-counter:bypass
--                    '1' after 3.29 us, '0' after 3.31 us,---------Write to M-counter:bypass 
--                    '1' after 3.51 us, '0' after 3.53 us,---------Write to C0-counter:LOW 
--                    '1' after 3.7 us,  '0' after 3.72 us;---------Write to C0-counter:HIGH
--                   --- '1' after 5.35 us,'0' after 5.37 us;
---------------------------------------------------------------------------------------------------------------
 read_param  <='0';-----,'1' after 5.91 us,'0' after 5.93 us;
 reconfig	   <='0',
              ---- '1' after 2.1 us, '0' after 2.12 us,
               '1' after 3.73  us, '0' after 3.75  us,
               '1' after 13.73  us, '0' after 13.75  us;
              ----- '1' after 10.71 us, '0' after 10.73 us;
 
 end architecture;
