Advertisement
madegoff

TestBench

Feb 3rd, 2023 (edited)
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.93 KB | None | 0 0
  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3. use ieee.numeric_std.all;
  4. use ieee.std_logic_textio.all;
  5.  
  6. library std;
  7. use std.textio.all;
  8.  
  9. library work;
  10. use work.mipsISA.all;
  11.  
  12.  
  13. entity aluCtrlExt_tb is
  14. end aluCtrlExt_tb;
  15.  
  16. architecture behavioral of aluCtrlExt_tb is
  17.  
  18. signal aluop : std_logic_vector(1 downto 0);
  19. signal f : std_logic_vector(5 downto 0);
  20. signal op_uut: std_logic_vector(3 downto 0);
  21. signal jr_uut: std_logic;
  22.  
  23. type type_f_array is array(natural range <>) of std_logic_vector(5 downto 0);
  24. type type_aluOp_array is array (natural range <>) of std_logic_vector(1 downto 0);
  25. type type_op_array is array(natural range <>) of std_logic_vector(3 downto 0);
  26. type type_jr_array is array(natural range <>) of std_logic;
  27.  
  28.  
  29. constant aluOp_array : type_aluOp_array := ("00", "00", "00", "01", "01","01", "10", "10", "10", "10", "10", "10", "10", "10", "10", "10", "10", "10", "10", "10", "11" );
  30. constant f_array : type_f_array := ("100011", "101011", "111000", "000100", "000000", "010101", "100001", "100000", "000000", "100011", "100010", "100100", "100101", "100111", "001000", "111001", "101011", "101010", "111100", "111111", "101010");
  31. constant op_array : type_op_array := ("0010", "0010", "0010", "0110", "0110", "0110", "0001", "0001", "0001", "0110", "0110", "0000", "0001", "1100", "0001", "0001", "0111", "0111", "0001", "1101", "1111");
  32. constant jr_array : type_jr_array := ('0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '0', '0', '0', '0', '0', '0');
  33.  
  34. begin
  35.  
  36. uut: entity work.aluCtrlExt(behavioral)
  37. port map(aluOp => aluop,
  38. f => f,
  39. operation => op_uut,
  40. jr => jr_uut);
  41.  
  42. test:process
  43.  
  44. variable numErrors : integer := 0;
  45. variable l : line;
  46. begin
  47.  
  48. for i in 0 to 15 loop
  49.  
  50. aluOp <= aluOp_array(i);
  51. f <= f_array(i);
  52.  
  53. wait for 5 ns;
  54.  
  55. if op_uut /= op_array(i) then
  56.  
  57. write(l, time'image(now));
  58. write(l, string'(": Falsches Ergebnis am AluCtrl-Modul: operation = """));
  59. write(l, op_uut);
  60. write(l, string'(""" (erwartet: """));
  61. write(l, op_array(i));
  62. write(l, string'(""")"));
  63. writeline(OUTPUT, l);
  64.  
  65. numErrors := numErrors + 1;
  66. end if;
  67.  
  68. if jr_uut /= jr_array(i) then
  69. write(l, time'image(now));
  70. write(l, string'(": Falsches Ergebnis am AluCtrl-Modul: jr = """));
  71. write(l, jr_uut);
  72. write(l, string'(""" (erwartet: """));
  73. write(l, jr_array(i));
  74. write(l, string'(""")"));
  75. writeline(OUTPUT, l);
  76. numErrors := numErrors + 1;
  77. end if;
  78. wait for 5 ns;
  79.  
  80. end loop;
  81.  
  82. if numErrors = 0 then
  83. report "Das AluCtrlEXt-Modul funktioniert einwandfrei! (Punktzahl: 2/2)" severity note;
  84. else
  85. write(l, string'("Sie haben "));
  86. write(l, numErrors);
  87. write(l, string'(" Fehler "));
  88. report "Das AluCtrlExt-Modul ist fehlerhaft! (Punktzahl: 0/2)" severity failure;
  89.  
  90. end if;
  91.  
  92. wait;
  93.  
  94. end process ;
  95.  
  96. end behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement