Guest User

Untitled

a guest
Nov 22nd, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.55 KB | None | 0 0
  1. USE work.class_proj.all;
  2. LIBRARY ieee;
  3.  
  4. USE ieee.std_logic_1164.all;
  5. USE ieee.numeric_std.all;
  6.  
  7. entity icache_tb is
  8. end entity;
  9.  
  10. architecture tb of icache_tb is
  11. component icache IS
  12. port(pc: in std_logic_vector(15 DOWNTO 0);
  13. inst1In,inst2In,inst3In,inst4In: IN instruction;
  14. inst1Out,inst2Out,inst3Out,inst4Out: OUT instruction;
  15. set_index: BUFFER integer;
  16. icread: IN std_logic;
  17. icwrite: IN std_logic;
  18. clk: IN std_logic;
  19. reset: IN std_logic;
  20. ichit: OUT std_logic);
  21. END component;
  22.  
  23. signal clk: std_logic:='0';
  24. signal icwrite,icread,reset,ichit: std_logic;
  25. signal pc: std_logic_vector(15 downto 0);
  26. signal inst1In,inst2In,inst3In,inst4In,inst1out,inst2out,inst3out,inst4out: instruction;
  27.  
  28. begin
  29. UUT: icache
  30. port map(clk=>clk,icwrite=>icwrite,icread=>icread,reset=>reset,ichit=>ichit,
  31. pc=>pc,inst1In=>inst1In,inst2In=>inst2In,inst3In=>inst3In,inst4In=>inst4In,inst1out=>inst1out,
  32. inst2out=>inst2out,inst3out=>inst3out,inst4out=>inst4out);
  33. process
  34. begin
  35. pc<="0000000000000001";
  36. inst1In.opcode<="0001"; inst1In.op1<="0110"; inst1In.op2<="0101"; inst1In.op3<="1001";
  37. inst2In.opcode<="0011"; inst2In.op1<="0001"; inst2In.op2<="0101"; inst2In.op3<="0011";
  38. inst3In.opcode<="0100"; inst3In.op1<="0101"; inst3In.op2<="0011"; inst3In.op3<="0111";
  39. inst4In.opcode<="0010"; inst4In.op1<="0111"; inst4In.op2<="0000"; inst4In.op3<="0100";
  40. clk<='1'; reset<='0'; icwrite<='1'; icread<='0'; wait for 10ns;
  41. clk<='0'; reset<='0'; icwrite<='0'; icread<='1'; wait for 10ns;
  42. clk<='1'; reset<='0'; icwrite<='0'; icread<='1'; wait for 10ns;
  43. wait;
  44. end process;
  45. end tb; '
  46.  
  47. ARCHITECTURE DMICache OF icache IS
  48. TYPE L1ICache IS array (0 to 1023) OF icblock;
  49. SIGNAL instcache : L1ICache;
  50.  
  51. BEGIN
  52.  
  53. PROCESS(clk)
  54.  
  55. VARIABLE i: integer;
  56. IF clk'EVENT and (clk = '1') THEN
  57.  
  58. -- icache set index
  59. set_index <= to_integer(unsigned(pc(12 DOWNTO 3)));
  60.  
  61. -- Reset all valid bits to 0
  62. IF (reset = '1') THEN
  63. FOR i IN 0 TO 1023 LOOP
  64. instcache(i).valid <= '0';
  65. END LOOP;
  66. END IF;
  67.  
  68. -- Fill block
  69. IF ( (reset = '0') and (icwrite = '1') ) THEN
  70. instcache(set_index).inst1 <= inst1In; --(The simulation stops here with an error)
  71. instcache(set_index).inst2 <= inst2In;
  72. instcache(set_index).inst3 <= inst3In;
  73. instcache(set_index).inst4 <= inst4In;
  74. instcache(set_index).tag <= pc(15 DOWNTO 13);
  75. instcache(set_index).valid <= '1';
  76. END IF;
Add Comment
Please, Sign In to add comment