Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.52 KB | None | 0 0
  1. USE std.textio.all;
  2.  
  3. ENTITY RegReadWrite_tb IS
  4. END ENTITY RegReadWrite_tb -- no generic/port clause
  5.  
  6. -- Architecture Body
  7.  
  8. FILE test_vectors : text OPEN read_mode IS
  9.     "RegReadWrite_vec.txt" -- set of test vectors,
  10.    
  11.     SIGNAL D : std_ulogic_vector(7 DOWNTO 0); -- these signals are the interface to the DUV
  12.     SIGNAL C, LE, OE : std_ulogic;
  13.    
  14.     signal vecno : NATURAL := 0; -- which vector I want, (vector number)
  15.    
  16.     BEGIN
  17.     DUV : ENTITY work.RegReadWrite(Mixed)
  18.     GENERIC MAP(size => 8)
  19.     PORT MAP(D=>D, Q=>Q, C=>C, LE=>LE, OE=>OE);
  20.    
  21.     -- stimulus process
  22.     Stim : PROCESS
  23.     VARIABLE L : LINE;
  24.     VARIABLE Dval : std_ulogic_vector(7 DOWNTO 0);
  25.     VARIABLE Qval : std_ulogic_vector(7 DOWNTO 0);
  26.     VARIABLE LEval, OEval : std_ulogic;
  27.     BEGIN
  28.     C <= '0'; -- clock
  29.     wait for 40 ns; -- to suspend process, must have sensitivity list or a wait statement
  30.     readline(test_vectors, L); -- read one line of the test_vectors "file", store in LE
  31.    
  32.    
  33.     WHILE NOT endfile(test_vectors) LOOP
  34.     readline(test_vectors, L);
  35.     read(L, LEval);
  36.     LE <= Leval;
  37.     read(L, OEval);
  38.     OE <= OEval;
  39.     read(L, Dval);
  40.     D <= Dval;
  41.     read(L, Qval);
  42.     Qv <= Qval;
  43.     wait for 10 ns;
  44.     C <= '1';
  45.     wait for 50 ns;
  46.     C <= '0';
  47.     wait for 40 ns;
  48.     END LOOP;
  49.    
  50.     report "End of Testbench.";
  51.     std.env.finish;
  52.    
  53.     END PROCESS;
  54.    
  55.     Check : PROCESS(C)
  56.     BEGIN
  57.     IF(falling_edge(c)) THEN
  58.     ASSERT Q = Qval
  59.         REPORT "ERROR: Incorrect output for vector " & to_string(vecno)
  60.         SEVERITY WARNING;
  61.     vecno <= vecno + 1;
  62.     END IF
  63.     END PROCESS;
  64.    
  65. END ARCHITECTURE Testbench;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement