Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

124 строки
4.8 KiB

  1. class scoreboard extends uvm_scoreboard;
  2. `uvm_component_utils(scoreboard)
  3. uvm_tlm_analysis_fifo#(axi_xtn) mst_fifo_h[];
  4. uvm_tlm_analysis_fifo#(axi_xtn) slv_fifo_h[];
  5. axi_env_config env_cfg_h;
  6. axi_xtn wr_xtn,rd_xtn;
  7. axi_xtn mst_xtn,slv_xtn;
  8. static int pkt_rcvd,pkt_cmprd;
  9. covergroup write_cg;
  10. option.per_instance=1;
  11. awaddr_cp: coverpoint wr_xtn.AWADDR{bins awaddr_bin={[0:'hffff_ffff]};}
  12. awburst_cp: coverpoint wr_xtn.AWBURST{bins awburst_bin[]={[0:2]};}
  13. awsize_cp : coverpoint wr_xtn.AWSIZE{bins awsize_bin[]={[0:2]};}
  14. awlen_cp : coverpoint wr_xtn.AWLEN{bins awlen_bin={[0:11]};}
  15. bresp_cp : coverpoint wr_xtn.BRESP{bins bresp_bin={0};}
  16. WRITE_ADDR_CROSS: cross awburst_cp,awsize_cp,awlen_cp;
  17. endgroup
  18. covergroup write_cg1 with function sample(int i);
  19. option.per_instance=1;
  20. wdata_cp : coverpoint wr_xtn.WDATA[i]{bins wdata_bin={[0:'hffff_ffff]};}
  21. wstrb_cp : coverpoint wr_xtn.WSTRB[i]{bins wstrobe_bin0={4'b1111};
  22. bins wstrobe_bin1={4'b1100};
  23. bins wstrobe_bin2={4'b0011};
  24. bins wstrobe_bin3={4'b1000};
  25. bins wstrobe_bin4={4'b0100};
  26. bins wstrobe_bin5={4'b0010};
  27. bins wstrobe_bin6={4'b0001};
  28. bins wstrobe_bin7={4'b1110};
  29. }
  30. WRITE_DATA_CROSS: cross wdata_cp,wstrb_cp;
  31. endgroup
  32. covergroup read_cg;
  33. option.per_instance=1;
  34. araddr_cp: coverpoint rd_xtn.ARADDR{bins araddr_bin={[0:'hffff_ffff]};}
  35. arburst_cp: coverpoint rd_xtn.ARBURST{bins arburst_bin[]={[0:2]};}
  36. arsize_cp : coverpoint rd_xtn.ARSIZE{bins arsize_bin[]={[0:2]};}
  37. arlen_cp : coverpoint rd_xtn.ARLEN{bins arlen_bin={[0:11]};}
  38. READ_ADDR_CROSS: cross arburst_cp,arsize_cp,arlen_cp;
  39. endgroup
  40. covergroup read_cg1 with function sample(int i);
  41. option.per_instance=1;
  42. rdata_cp : coverpoint rd_xtn.RDATA[i]{bins rdata_bin={[0:'hffff_ffff]};}
  43. rresp_cp : coverpoint rd_xtn.RRESP[i]{bins rresp_bin={0};}
  44. endgroup
  45. extern function new(string name="scoreboard",uvm_component parent);
  46. extern function void build_phase(uvm_phase phase);
  47. extern task run_phase(uvm_phase);
  48. extern function void report_phase(uvm_phase phase);
  49. endclass
  50. function scoreboard::new(string name="scoreboard",uvm_component parent);
  51. super.new(name,parent);
  52. write_cg=new();
  53. write_cg1=new();
  54. read_cg=new();
  55. read_cg1=new();
  56. endfunction
  57. function void scoreboard::build_phase(uvm_phase phase);
  58. if(!uvm_config_db #(axi_env_config)::get(this,"","axi_env_config",env_cfg_h))
  59. `uvm_fatal("Scoreboard","cannot get env config, have you set it?");
  60. mst_fifo_h=new[env_cfg_h.no_of_master];
  61. slv_fifo_h=new[env_cfg_h.no_of_slave];
  62. foreach(mst_fifo_h[i])
  63. mst_fifo_h[i]=new($sformatf("mst_fifo_h[%0d]",i),this);
  64. foreach(slv_fifo_h[i])
  65. slv_fifo_h[i]=new($sformatf("slv_fifo_h[%0d]",i),this);
  66. super.build_phase(phase);
  67. endfunction
  68. task scoreboard::run_phase(uvm_phase phase);
  69. forever
  70. begin
  71. mst_fifo_h[0].get(mst_xtn);
  72. slv_fifo_h[0].get(slv_xtn);
  73. pkt_rcvd++;
  74. if(mst_xtn.compare(slv_xtn))
  75. begin
  76. wr_xtn=mst_xtn;
  77. rd_xtn=mst_xtn;
  78. pkt_cmprd++;
  79. write_cg.sample();
  80. read_cg.sample();
  81. if(mst_xtn.WVALID)
  82. begin
  83. foreach(mst_xtn.WDATA[i])
  84. begin
  85. write_cg1.sample(i);
  86. end
  87. end
  88. if(mst_xtn.RVALID)
  89. begin
  90. foreach(mst_xtn.RDATA[i])
  91. begin
  92. read_cg1.sample(i);
  93. end
  94. end
  95. end
  96. else
  97. `uvm_error("Scoreboard","Master and Slave Packet Mismatch");
  98. end
  99. endtask
  100. function void scoreboard::report_phase(uvm_phase phase);
  101. `uvm_info("SCOREBOARD",$sformatf("No. of packets received:%0d",pkt_rcvd),UVM_LOW);
  102. `uvm_info("SCOREBOARD",$sformatf("No. of packets compared:%0d",pkt_cmprd),UVM_LOW);
  103. endfunction