Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

vor 7 Monaten
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. class axi_drv extends uvm_driver#(axi_seq_item)
  2. `uvm_components_utils(axi_drv)
  3. virtual intf vif;
  4. axi_seq_item txn;
  5. int [31:0] temp[];
  6. function new(string name="axi_drv",uvm_component parent);
  7. super.new(name.parent);
  8. endfunction
  9. function void build_phase(uvm_phase phase);
  10. uvm_config_db#(virtual intf)::get(this,"",vif,vif);
  11. txn=axi_seq_item::type_id::create(txn);
  12. endfunction
  13. task run_phase(uvm_phase phase);
  14. begin
  15. get_next_item(txn);
  16. drive(txn);
  17. item_done();
  18. endtask
  19. task drive(txn);
  20. fork
  21. // reset();
  22. write_add(txn);
  23. write_data(txn);
  24. read_add(txn);
  25. join
  26. endtask
  27. ///////////////write addr///////////
  28. task write_add(txn);
  29. int lower_wrap_boundary;
  30. int upper_wrap_boundary;
  31. int burst_len,burst_size;
  32. int total_trans;
  33. if(txn.write==1)
  34. begin
  35. @(vif.clk);
  36. vif.awid<=txn.awid;
  37. vif.awlen<=txn.awlen;
  38. vif.awsize<=txn.awsize;
  39. vif.awburst<=txn.awburst;
  40. /////////fixed burst/////////////
  41. if(txn.awburst==2'b00)
  42. begin
  43. vif.awaddr<=txn.awaddr;
  44. end
  45. /////////////incr burst//////////////
  46. else if(txn.awaddr==2'b01)
  47. begin
  48. vif.awaddr<=txn.awaddr;
  49. for(int i=0;i<awlen;i++)
  50. begin
  51. vif.awaddr<=txn.awaddr+(2**awsize);
  52. end
  53. end
  54. //////////////////////wrap burst//////////
  55. else if(txn.awaddr==2'b10)
  56. begin
  57. if(awaddr%(2**awsize==0))
  58. begin
  59. burst_len=awlen+1;
  60. burst_size=2**awsize;
  61. total_trans=burst_len*burst_size;
  62. lower_wrap_boundary=int'(awaddr/total_trans)*total_trans;
  63. upper_wrap_boundary=lower_wrap_boundary+total_trans;
  64. end
  65. end
  66. vif.awvalid<=1;
  67. wait(vif.awready);
  68. @(vif.clk);
  69. vif.awvalid<=0;
  70. end
  71. endtask
  72. //////////////write data///////////////
  73. task write_data(txn);
  74. begin
  75. temp=new[txn.awlen+1];
  76. forech(txn.wdata[i][j])
  77. begin
  78. temp[i][8*j+:8]=data[i][j];
  79. end
  80. for(i=0;i<awlen+1;i++)
  81. begin
  82. @(vif.clk);
  83. vif.wid<=txn.wid;
  84. vif.wdata<=temp[i];
  85. vif.wlast<=(awlen==i)?1:0;
  86. end
  87. vif.wvalid<=1;
  88. wait(vif.wready)
  89. @(vif.clk);
  90. vif.wvalid<=0;
  91. end
  92. endtask
  93. ///////////read addr///////////
  94. task read_add(txn);
  95. begin
  96. if(!txn.write)
  97. begin
  98. @(vif.clk);
  99. vif.arid<=txn.arid;
  100. vif.araddr<=txn.araddr;
  101. vif.arlen<=txn.arlen;
  102. vif.arsize<=txn.arsize;
  103. vif.arburst<=txn.arburst;
  104. vif.arvalid<=1;
  105. wait(vif.arready);
  106. @(vif.clk);
  107. vif.arvalid<=0;
  108. end
  109. end
  110. endtask
  111. endclass