Advertisement
1WaKa_WaKa1

lru_tb

Apr 5th, 2023 (edited)
1,345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. `timescale 1ns / 1ps
  2.  
  3. module lru_tb;
  4.  
  5. reg clock, rst, en;
  6. reg[31:0] data_in;
  7. wire[31:0] out1, out2, out3, out4, out5, out6, out7, out8;
  8.  
  9. lru buffer(
  10.     .clk(clock),
  11.     .reset(rst),
  12.     .enable(en),
  13.     .data(data_in),
  14.     .out1(out1),
  15.     .out2(out2),
  16.     .out3(out3),
  17.     .out4(out4),
  18.     .out5(out5),
  19.     .out6(out6),
  20.     .out7(out7),
  21.     .out8(out8)
  22. );
  23.  
  24. integer i;
  25. integer test[0:20];
  26.  
  27. initial begin
  28.  
  29.     test[0] = 20;
  30.     test[1] = 7627;
  31.     test[2] = 777;
  32.     test[3] = 888;
  33.     test[4] = 9999;
  34.     test[5] = 222;
  35.     test[6] = 999;
  36.     test[7] = 4444;
  37.     test[8] = 555;
  38.     test[9] = 7627;
  39.     test[10] = 7627;
  40.     test[11] = 222;
  41.     test[12] = 222;
  42.     test[13] = 222;
  43.     test[14] = 111;
  44.     test[15] = 333;
  45.    
  46.     clock = 0;
  47.     rst = 0;
  48.     en = 0;
  49.     #5 clock = ~clock;
  50.     #5 clock = ~clock;
  51.    
  52.     for(i = 0; i < 16; i = i + 1) begin
  53.         data_in = test[i];
  54.         #5 en = 1;
  55.         #5 clock = ~clock;
  56.         #5 en = 0;
  57.         #5 clock = ~clock;
  58.         if (data_in == 555) begin
  59.             $display ("Current state: %d", buffer.state);
  60.         end
  61.         #5 clock = ~clock;
  62.         #5 clock = ~clock;
  63.         if (data_in == 555) begin
  64.             $display ("Current state: %d", buffer.state);
  65.         end
  66.         #5 clock = ~clock;
  67.         #5 clock = ~clock;
  68.         if (data_in == 555) begin
  69.             $display ("Current state: %d", buffer.state);
  70.         end
  71.        
  72.         $display("inserted %d, out = [%d, %d, %d, %d, %d, %d, %d, %d]", test[i], out1, out2, out3, out4, out5, out6, out7, out8);
  73.     end
  74.     $stop;
  75.  
  76. end
  77.  
  78. endmodule
  79.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement