Advertisement
sem_rez

Untitled

Apr 9th, 2021
710
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*cache finite state machine*/
  2. timeunit 1ns;
  3. timeprecision 1ps;
  4. import cache_def::*;
  5.  
  6. `define TB_CLK_PERIOD 4
  7.  
  8. module cache_simple_tb();
  9.  
  10. bit              clk;
  11. bit              rst;
  12. cpu_req_type     cpu_req; //CPU request input (CPU->cache)
  13. mem_data_type    mem_data; //memory response (memory->cache)
  14. mem_req_type     mem_req; //memory request (cache->memory)
  15. cpu_result_type  cpu_res; //cache result (cache->CPU)
  16.  
  17. dm_cache_fsm dut (.*);
  18.  
  19. /////////////////////////////
  20. // Clock and reset signals //
  21. /////////////////////////////
  22. initial begin
  23.   clk = 0;
  24.   forever clk = #(`TB_CLK_PERIOD/2) !clk;
  25. end
  26.  
  27. initial begin
  28.   rst   = 1;
  29.   repeat (10)  @(posedge clk);
  30.   rst   = 0;
  31. end
  32.  
  33. initial begin
  34.   repeat (20)  @(posedge clk);
  35.   cpu_req.addr  = 32'h1234FF66;
  36.   cpu_req.data  = 32'h77777777;
  37.   cpu_req.rw    = 1'b1;
  38.   cpu_req.valid = 1'b1;
  39.   repeat (10)  @(posedge clk);
  40.   cpu_req.addr  = 32'h000;
  41.   cpu_req.data  = 32'h1234FF66;
  42.   cpu_req.rw    = 1'b1;
  43.   cpu_req.valid = 1'b1;
  44. end
  45.  
  46. initial begin
  47.   repeat (20)  @(posedge clk);
  48.   mem_data.ready = 1;
  49.   mem_data.data  = 128'h1234FF66;
  50.   repeat (20)  @(posedge clk);
  51.   mem_data.ready = 0;
  52.   mem_data.data  = 0;
  53. end
  54.  
  55. endmodule : cache_simple_tb
  56.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement