Guest User

Untitled

a guest
May 27th, 2015
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.89 KB | None | 0 0
  1.  
  2. LIBRARY ieee;
  3. USE ieee.std_logic_1164.ALL;
  4.  
  5. ENTITY mem8x4_tb IS
  6. END mem8x4_tb;
  7.  
  8. ARCHITECTURE behavior OF mem8x4_tb IS
  9.  
  10.     -- Component Declaration for the Unit Under Test (UUT)
  11.  
  12.     COMPONENT memorie8x4
  13.     PORT(
  14.             clk: in std_logic;
  15.          cs : IN  std_logic;
  16.          rw : IN  std_logic;
  17.          address : IN  std_logic_vector(2 downto 0);
  18.          output : INOUT  std_logic_vector(3 downto 0)
  19.         );
  20.     END COMPONENT;
  21.    
  22.  
  23.    --Inputs
  24.     signal clk : std_logic := '0';
  25.    signal cs : std_logic := '0'; -- default neselectat
  26.    signal rw : std_logic := '1'; -- default read mode
  27.    signal address : std_logic_vector(2 downto 0) := (others => '0'); -- default adresa 0
  28.  
  29.    signal output : std_logic_vector(3 downto 0) := "0000";
  30.  
  31. BEGIN
  32.  
  33.     -- Instantiate the Unit Under Test (UUT)
  34.    uut: memorie8x4 PORT MAP (
  35.              clk => clk,
  36.           cs => cs,
  37.           rw => rw,
  38.           address => address,
  39.           output => output
  40.         );
  41.  
  42.     process
  43.     begin
  44.         clk <= '0';
  45.         wait for 2 ns;
  46.         clk <= '1';
  47.         wait for 2 ns;
  48.     end process;
  49.  
  50.    -- vreau sa citesc o valoare din memorie, dupa care sa inchid chip-ul,
  51.     -- sa scriu o valoare in memorie, sa inchid chip-ul, sa trec in read
  52.     -- si sa citesc daca valoarea a fost scrisa
  53.     process
  54.     begin
  55.    
  56.         wait for 10 ns;
  57.         address <= "010"; -- selectez adresa
  58.         rw <= '1'; -- trec in modul read
  59.         cs <= '1'; -- activez memoria -> citesc output-ul
  60.         wait for 10 ns;
  61.         cs <= '0'; -- dezactivez memoria
  62.         rw <= '0'; -- trec in modul write
  63.         output <= "0110"; -- scriu ceva la output
  64.         cs <= '1'; -- activez memoria, se scrie in memorie
  65.         wait for 10 ns;
  66.         cs <= '0'; -- dezactivez memoria
  67.         rw <= '1'; -- trec in modul read
  68.         address <= "001";
  69.         cs <= '1';
  70.         wait for 10 ns;
  71.         address <= "010";
  72.         --cs <= '1'; -- activez memoria, citesc valoarea de la output
  73.         wait for 10 ns;
  74.         wait;
  75.     end process;
  76.    
  77.  
  78. END;
Advertisement
Add Comment
Please, Sign In to add comment