Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

129 řádky
3.9 KiB

  1. //=============================AXI DRIVER CLASS====================================//
  2. class axi_driver extends uvm_driver;
  3. `uvm_component_utils(axi_driver)
  4. virtual axi_if.DRV_MP mif;
  5. axi_config axi_cfg;
  6. axi_xtn xtn;
  7. function new(string name="axi_driver", uvm_component parent);
  8. super.new(name,parent);
  9. endfunction
  10. function void build_phase(uvm_phase phase);
  11. if(!uvm_config_db#(axi_config)::get(this,"","axi_config",axi_cfg))
  12. `uvm_fatal(get_type_name(),"cannot get the configuration database have you set it?")
  13. endfunction
  14. function void connect_phase(uvm_phase phase)
  15. axi_cfg.vif=vif;
  16. endfunction
  17. task run_phase(uvm_phase phase);
  18. forever
  19. begin
  20. seq_item_port.get_next_item(xtn);
  21. driver(xtn);
  22. seq_item_port.item_done();
  23. end
  24. endtask
  25. task driver();
  26. if(xtn.write==1)
  27. begin
  28. axi_write_address();
  29. axi_write_data();
  30. axi_write_resp();
  31. end
  32. else
  33. begin
  34. axi_read_address();
  35. axi_read_data();
  36. end
  37. endtask
  38. task axi_write_addr(axi_xtn xtn);
  39. $display("start of drive_awaddr");
  40. mif.mst_drv_cb.AWVALID <= 1;
  41. mif.mst_drv_cb.AWADDR <= xtn.AWADDR;
  42. mif.mst_drv_cb.AWSIZE <= xtn.AWSIZE;
  43. mif.mst_drv_cb.AWID <= xtn.AWID;
  44. mif.mst_drv_cb.AWLEN <= xtn.AWLEN;
  45. mif.mst_drv_cb.AWBURST <= xtn.AWBURST;
  46. @(mif.mst_drv_cb);
  47. wait(mif.mst_drv_cb.AWREADY)
  48. mif.mst_drv_cb.AWVALID <= 0;
  49. repeat($urandom_range(1,5))
  50. @(mif.mst_drv_cb);
  51. $display("end of drive_awaddr");
  52. endtask
  53. task axi_write_data(axi_xtn xtn);
  54. $display("start of drive_wdata");
  55. foreach(xtn.WDATA[i])
  56. begin
  57. mif.drv_cb.WVALID <= 1;
  58. mif.drv_cb.WDATA <= xtn.WDATA[i];
  59. mif.drv_cb.WSTRB <= xtn.WSTRB[i];
  60. mif.drv_cb.WID <= xtn.WID;
  61. if(i==(xtn.AWLEN))
  62. mif.drv_cb.WLAST <= 1;
  63. else
  64. mif.drv_cb.WLAST <= 0;
  65. @(mif.drv_cb);
  66. wait(mif.drv_cb.WREADY)
  67. mif.drv_cb.WVALID <= 0;
  68. mif.drv_cb.WLAST <= 0;
  69. repeat($urandom_range(1,5))
  70. @(mif.drv_cb);
  71. end
  72. $display("end of drive_wdata");
  73. endtask
  74. task axi_write_resp(axi_xtn xtn);
  75. $display("start of drive_bresp");
  76. mif.drv_cb.BREADY<=1;
  77. @(mif.drv_cb)
  78. wait(mif.drv_cb.BVALID)
  79. mif.drv_cb.BREADY<=0;
  80. repeat($urandom_range(1,5))
  81. @(mif.drv_cb);
  82. $display("end of drive_bresp");
  83. endtask
  84. task axi_read_addr(axi_xtn xtn);
  85. $display("start of drive_raddr");
  86. repeat($urandom_range(1,3))
  87. @(mif.drv_cb);
  88. mif.drv_cb.ARID<=xtn.ARID;
  89. mif.drv_cb.ARLEN<=xtn.ARLEN;
  90. mif.drv_cb.ARSIZE<=xtn.ARSIZE;
  91. mif.drv_cb.ARBURST<=xtn.ARBURST;
  92. mif.drv_cb.ARADDR<=xtn.ARADDR;
  93. mif.drv_cb.ARVALID<=1;
  94. @(mif.drv_cb);
  95. $display("inside drive_read_addr before wait ARREADY");
  96. wait(mif.drv_cb.ARREADY)
  97. mif.drv_cb.ARVALID<=0;
  98. repeat($urandom_range(1,5))
  99. @(mif.drv_cb);
  100. $display("end of drive_raddr");
  101. endtask
  102. endclass