AXI-Verification architecture, functional coverage and assertions based coverage code
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

98 lignes
2.9 KiB

  1. `include "uvm_macros.svh"
  2. import uvm_pkg::*;
  3. class axi_mon1 extends uvm_monitor;
  4. `uvm_component_utils axi_mon1;
  5. virtual axi_slave_if mon_avif;
  6. uvm_analysis_port #(axi_txn) a_mon_ap;
  7. axi_txn w_trans;
  8. axi_txn r_trans;
  9. function new(string name axi_mon1",uvm_component parent =null);
  10. super.new(name, parent);
  11. // w_done =1;
  12. //r_done =1;
  13. endfunction
  14. function void build_phase(uvm_phase phase);
  15. super.build_phase(phase);
  16. `uvm_info("monitor","build_phase",UVM_MEDIUM)
  17. a_mon_ap=new("a_mon_ap",this);
  18. w_trans= axi_txn :: type_id :: create("axi_mon_txn");
  19. r_trans= axi_txn :: typeid :: create(" r_trans");
  20. endfunction:build_phase
  21. task run_phase(uvm_phase phase);
  22. forever begin
  23. // run_mon(phase);
  24. //@(mon_avif.clk);
  25. fork
  26. begin
  27. write_monitor();
  28. read_monitor();
  29. end
  30. join_none
  31. end
  32. endtask: run_phase
  33. /* task run_mon(uvm_phase phase);
  34. fork
  35. if(w_done) begin
  36. phase.raise_objection(this);
  37. w_done=0;
  38. write_monitor();
  39. w_done=1;
  40. phase.drop_objection(this);
  41. end
  42. if(r_done) begin
  43. phase.raise_objection(this);
  44. r_done=0;
  45. read_monitor();
  46. r_done=1;
  47. phase.drop_objection(this);
  48. end
  49. join_none
  50. endtask: run_mon */
  51. task write_monitor();
  52. if( mon_avif.awvalid && mon_avif.awready) begin
  53. w_trans = axi_txn ::type_id::create("w_trans");
  54. w_trans.awaddr = mon_avif.awaddr;
  55. w_trans.awid = mon_avif.awid;
  56. w_trans.awsize = mon_avif.awsize;
  57. w_trans.awlen = mon_avif.awlen;
  58. w_trans.awburst = mon_avif.awburst;
  59. w_trans.wdata = new [w_trans.awlen+1];
  60. for (int i=0; i<w_trans.awlen+1; i++) begin
  61. @( mon_avif.clk);
  62. wait( mon_avif.wvalid && mon_avif.wready);
  63. w_trans.wdata[i] = new [D_WIDTH/8];
  64. for (int j=0; j<D_WIDTH/8; j++) begin
  65. w_trans.wdata[i][j] = mon_avif.wdata[8*j+:8];
  66. end
  67. end
  68. ap.write(w_trans);
  69. `uvm_info("MMON", $sformatf("WTRANS %s", w_trans.convert2string()), UVM_HIGH)
  70. end
  71. endtask: write_monitor
  72. task read_monitor();
  73. if( mon_avif.arvalid && mon_avif.arready) begin
  74. r_trans = axi_txn#(D_WIDTH, A_WIDTH)::type_id::create("r_trans");
  75. r_trans.araddr = mon_avif.araddr;
  76. r_trans.arid = mon_avif.arid;
  77. r_trans.arsize = mon_avif.arsize;
  78. r_trans.awlen = mon_avif.awlen;
  79. r_trans.arburst = mon_avif.arburst;
  80. ap.write(r_trans);
  81. `uvm_info("MMON", $sformatf("RTRANS %s", r_trans.convert2string()), UVM_HIGH)
  82. end
  83. endtask: read_monitor
  84. endclass
  85. module top_v axi_mon1 dut;
  86. initial
  87. begin
  88. repeat(5)
  89. dut=new();
  90. assert(dut.randomize);
  91. $display("done");
  92. end
  93. endmodule