entity sram_64k_16_tb is
end sram_64k_16_tb;

library IEEE;
library memory;
library vfp;

architecture tb0 of sram_64k_16_tb is
  use IEEE.std_logic_1164.all;
  use vfp.generic_conversions.all;
  use memory.sram_64k_16_cmpt.all;

  constant address_width : integer := 16;
  constant data_width : integer := 16;
  
  signal Addr : std_ulogic_vector(address_width-1 downto 0);
  signal Data : std_logic_vector(data_width-1 downto 0);
  signal Data_out : std_logic_vector(data_width-1 downto 0);
  signal Cs, Oe, We : std_ulogic;
  signal Cs_inv, Oe_inv : std_ulogic;

begin
  
  process
    variable loop_index : integer;
    variable addr_signed : std_ulogic_vector(address_width downto 0);
  begin
    We <= '1';
    Cs <= '1';
    Oe <= '1';
    Addr <= (others => '0');
    Data <= (others => 'Z');
    wait for 10 NS;

--  Check out control lines

--  Read with chip disabled
 
    Oe <= '0';
    wait for 10 NS;
    Oe <= '1';
    wait for 10 NS;

--  Read undefined with chip enabled

    Cs <= '0';
    wait for 10 NS;
    Oe <= '0';
    wait for 10 NS;
    Oe <= '1';
    wait for 10 NS;

--  Write with chip disabled

    Data <= (others => '1');
    wait for 10 NS;
    Cs <= '1';
    wait for 10 NS;
    We <= '0';
    wait for 10 NS;
    We <= '1';
    wait for 10 NS;

-- Check nothing was written

    Data <= (others => 'Z');
    wait for 10 NS;
    Cs <= '0';
    wait for 10 NS;
    Oe <= '0';
    wait for 10 NS;
    Oe <= '1';
    wait for 10 NS;

--  Write with chip enabled

    Data <= (others => '1');
    wait for 10 NS;
    Cs <= '0';
    wait for 10 NS;
    We <= '0';
    wait for 10 NS;
    We <= '1';
    wait for 10 NS;

-- Check something was written

    Data <= (others => 'Z');
    wait for 10 NS;
    Oe <= '0';
    wait for 10 NS;
    Oe <= '1';
    wait for 10 NS;

-- Read and write together...

    Data <= (others => '0');
    wait for 10 NS;
    We <= '0';
    Oe <= '0';
    wait for 10 NS;
    We <= '1';
    Oe <= '1';
    wait for 10 NS;


--  Write into all the Ram contents by driving the data bus

    Cs <= '0';
    for i in 0 to 15 loop
      loop_index := i;
      addr_signed := to_std_ulogic_vector (loop_index, address_width+1);
      Addr <= addr_signed(address_width-1 downto 0);
      wait for 5 NS;
      Data <= to_stdlogicvector (Addr);
      wait for 5 NS;
      We <= '0';
      wait for 20 NS;
      We <= '1';
      wait for 20 NS;
    end loop;

--  Turn off driver to the data bus and read out new Ram contents

    Data <= (others => 'Z');
    wait for 50 NS;
    for i in 0 to 15 loop
      loop_index := i;
      addr_signed := to_std_ulogic_vector (loop_index, address_width+1);
      Addr <= addr_signed(address_width-1 downto 0);
      wait for 10 NS;
      Oe <= '0';
      wait for 20 NS;
      Oe <= '1';
      wait for 20 NS;
    end loop;

    wait;
  end process;

  cs_inv <= not cs;
  oe_inv <= not oe;
  
  G1: sram_64k_16 
    port map (Addr, Cs_inv, WE, Oe_inv, Data, Data_out);

end tb0; 

<div align="center"><br /><script type="text/javascript"><!--
google_ad_client = "pub-7293844627074885";
//468x60, Created at 07. 11. 25
google_ad_slot = "8619794253";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />&nbsp;</div>