AXI-Verification architecture, functional coverage and assertions based coverage code
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

331 linhas
9.6 KiB

  1. class scoreboard extends uvm_scoreboard;
  2. `uvm_component_utils(scoreboard)
  3. env_config m_cfg;
  4. uvm_tlm_analysis_fifo #(master_xtn) mas_fifo[][];
  5. uvm_tlm_analysis_fifo #(slave_xtn) slv_fifo[][];
  6. master_xtn write_address;
  7. slave_xtn write_address_1;
  8. master_xtn write_address_1_1;
  9. master_xtn write_data;
  10. slave_xtn write_data_1;
  11. master_xtn write_data_1_1;
  12. slave_xtn write_response;
  13. master_xtn write_response_1;
  14. master_xtn write_response_1_1;
  15. master_xtn read_address;
  16. slave_xtn read_address_1;
  17. master_xtn read_address_1_1;
  18. master_xtn read_data_response;
  19. slave_xtn read_data_response_1;
  20. master_xtn read_data_response_1_1;
  21. extern function new (string name = "scoreboard",uvm_component parent);
  22. extern function void build_phase (uvm_phase phase);
  23. extern task run_phase (uvm_phase phase);
  24. extern task compare_write_address();
  25. extern task compare_write_data();
  26. extern task compare_write_response();
  27. extern task compare_read_address();
  28. extern task compare_read_data_response ();
  29. extern function void report_phase (uvm_phase phase);
  30. int success [bit [3:0]];
  31. int channel_1;
  32. endclass
  33. ////////////////////////////////////////// NEW FUNCTION
  34. function scoreboard::new (string name = "scoreboard",uvm_component parent);
  35. super.new (name,parent);
  36. write_address_cov = new();
  37. write_data_cov = new();
  38. write_data_cov_2 = new();
  39. write_response_cov = new();
  40. read_address_cov = new();
  41. read_data_response_cov = new();
  42. read_data_response_cov_2 = new();
  43. endfunction
  44. //////////////////////////////////////////// BUILD PHASE
  45. function void scoreboard::build_phase (uvm_phase phase);
  46. super.build_phase(phase);
  47. run_test19:
  48. if(!uvm_config_db #(env_config)::get(this,"","env_config",m_cfg))
  49. `uvm_fatal ("SCOREBOADR","\n\n\t\t\t\tGETTING DATABASE FAILED\n\n")
  50. mas_fifo = new [m_cfg.no_of_mas_top_agts * m_cfg.no_of_mas_agts];
  51. foreach(mas_fifo[i])
  52. begin
  53. mas_fifo[i] = new[5];
  54. run_test19:
  55. for (int j = 0;j < 5;j++)
  56. mas_fifo[i][j] = new ($sformatf("mas_fifo[%0d][%0d]",i,j),this);
  57. end
  58. slv_fifo = new [m_cfg.no_of_slv_top_agts * m_cfg.no_of_slv_agts];
  59. foreach(slv_fifo[i])
  60. begin
  61. slv_fifo[i] = new[5];
  62. for (int j = 0;j < 5;j++)
  63. slv_fifo[i][j] = new ($sformatf("slv_fifo[%0d][%0d]",i,j),this);
  64. end
  65. endfunction
  66. ////////////////////////////////////////////// RUN PHASE
  67. task scoreboard::run_phase (uvm_phase phase);
  68. fork
  69. forever
  70. begin
  71. mas_fifo[0][0].get (write_address);
  72. slv_fifo[0][0].get (write_address_1);
  73. compare_write_address();
  74. end
  75. forever
  76. run_test19:
  77. begin
  78. mas_fifo[0][1].get (write_data);
  79. slv_fifo[0][1].get (write_data_1);
  80. compare_write_data();
  81. end
  82. forever
  83. begin
  84. mas_fifo[0][2].get (write_response_1);
  85. slv_fifo[0][2].get (write_response);
  86. compare_write_response();
  87. end
  88. run_test19:
  89. forever
  90. begin
  91. mas_fifo[0][3].get (read_address);
  92. slv_fifo[0][3].get (read_address_1);
  93. compare_read_address();
  94. end
  95. forever
  96. begin
  97. run_test19:
  98. mas_fifo[0][4].get (read_data_response);
  99. slv_fifo[0][4].get (read_data_response_1);
  100. compare_read_data_response ();
  101. end
  102. join
  103. endtask
  104. ////////////////////////////////////////////// COMPARE WRITE ADDRESS
  105. task scoreboard::compare_write_address();
  106. write_address_1_1 = master_xtn::type_id::create ("write_address_compare");
  107. write_address_1_1.awid = write_address_1.awid;
  108. write_address_1_1.awaddr = write_address_1.awaddr;
  109. write_address_1_1.awlen = write_address_1.awlen;
  110. write_address_1_1.awsize = write_address_1.awsize;
  111. write_address_1_1.awburst = write_address_1.awburst;
  112. write_address.control = 1;
  113. `uvm_info("SCOREBOARD",$sformatf("WRITE ADDRESS fROM MASTER MONITOR \n %s",write_address.sprint),UVM_HIGH)
  114. write_address_1_1.control = 1;
  115. `uvm_info("SCOREBOARD",$sformatf("WRITE ADDRESS fROM SLAVE MONITOR \n %s",write_address_1_1.sprint),UVM_HIGH)
  116. write_address_1_1.control_1 = 1;
  117. if (write_address_1_1.compare (write_address))
  118. begin
  119. write_address_cov.sample();
  120. success[write_address.awid][1:0] = 1;
  121. end
  122. else
  123. success[write_address.awid][1:0] = 2;
  124. endtask
  125. ////////////////////////////////////////////// COMPARE WRITE DATA
  126. task scoreboard::compare_write_data();
  127. write_data_1_1 = master_xtn::type_id::create ("write_data_compare");
  128. write_data_1_1.wid = write_data_1.wid;
  129. foreach (write_data_1.wdata[i])
  130. write_data_1_1.wdata[i] = write_data_1.wdata[i];
  131. foreach (write_data_1.wstrobe[i])
  132. write_data_1_1.wstrobe[i] = write_data_1.wstrobe[i];
  133. write_data.control = 2;
  134. `uvm_info("SCOREBOARD",$sformatf("WRITE DATA fROM MASTER MONITOR \n %s",write_data.sprint),UVM_HIGH)
  135. write_data_1_1.control = 2;
  136. `uvm_info("SCOREBOARD",$sformatf("WRITE DATA fROM SLAVE MONITOR \n %s",write_data_1_1.sprint),UVM_HIGH)
  137. write_data_1_1.control_1 = 2;
  138. if (write_data_1_1.compare (write_data))
  139. begin
  140. write_data_cov.sample();
  141. foreach (write_data.wstrobe[i])
  142. write_data_cov_2.sample(i);
  143. success[write_data.wid][3:2] = 1;
  144. end
  145. else
  146. success[write_data.wid][3:2] = 2;
  147. endtask
  148. ////////////////////////////////////////////// COMPARE WRITE RESPONSE
  149. task scoreboard::compare_write_response();
  150. write_response_1_1 = master_xtn::type_id::create ("write_response_compare");
  151. write_response_1_1.bid = write_response.bid;
  152. write_response_1_1.bresp = write_response.bresp;
  153. write_response_1.control = 3;
  154. `uvm_info("SCOREBOARD",$sformatf("WRITE RESPONSE fROM MASTER MONITOR \n %s",write_response_1.sprint),UVM_HIGH)
  155. write_response_1_1.control = 3;
  156. `uvm_info("SCOREBOARD",$sformatf("WRITE RESPONSE fROM SLAVE MONITOR \n %s",write_response_1_1.sprint),UVM_HIGH)
  157. write_response_1.control_1 = 3;
  158. if (write_response_1.compare (write_response_1_1))
  159. begin
  160. write_response_cov.sample();
  161. success[write_response_1.bid][5:4] = 1;
  162. end
  163. else
  164. success[write_response_1.bid][5:4] = 2;
  165. endtask
  166. ////////////////////////////////////////////// COMPARE READ ADDRESS
  167. task scoreboard::compare_read_address();
  168. read_address_1_1 = master_xtn::type_id::create ("read_address_compare");
  169. read_address_1_1.arid = read_address_1.arid;
  170. read_address_1_1.araddr = read_address_1.araddr;
  171. read_address_1_1.arlen = read_address_1.arlen;
  172. read_address_1_1.arsize = read_address_1.arsize;
  173. read_address_1_1.arburst = read_address_1.arburst;
  174. read_address.control = 4;
  175. `uvm_info("SCOREBOARD",$sformatf("READ ADDRESS fROM MASTER MONITOR \n %s",read_address.sprint),UVM_HIGH)
  176. read_address_1_1.control = 4;
  177. `uvm_info("SCOREBOARD",$sformatf("READ ADDRESS fROM SLAVE MONITOR \n %s",read_address_1_1.sprint),UVM_HIGH)
  178. read_address_1_1.control_1 = 4;
  179. if (read_address_1_1.compare (read_address))
  180. begin
  181. read_address_cov.sample();
  182. success[read_address.arid][7:6] = 1;
  183. end
  184. else
  185. success[read_address.arid][7:6] = 2;
  186. endtask
  187. ////////////////////////////////////////////// COMPARE READ DATA AND RESPONSE
  188. task scoreboard::compare_read_data_response ();
  189. read_data_response_1_1 = master_xtn::type_id::create ("read_data_response_compare");
  190. read_data_response_1_1.rid = read_data_response_1.rid;
  191. foreach (read_data_response_1.rdata[i])
  192. read_data_response_1_1.rdata[i] = read_data_response_1.rdata[i];
  193. foreach (read_data_response_1.read_resp[i])
  194. read_data_response_1_1.read_resp[i] = read_data_response_1.read_resp[i];
  195. read_data_response.control = 6;
  196. `uvm_info("SCOREBOARD",$sformatf("READ DATA AND RESPONSE fROM MASTER MONITOR \n %s",read_data_response.sprint),UVM_HIGH)
  197. read_data_response_1_1.control = 6;
  198. `uvm_info("SCOREBOARD",$sformatf("READ DATA AND RESPONSE fROM SLAVE MONITOR \n %s",read_data_response_1_1.sprint),UVM_HIGH)
  199. read_data_response_1_1.control_1 = 5;
  200. if (read_data_response_1_1.compare (read_data_response))
  201. begin
  202. read_data_response_cov.sample();
  203. foreach (read_data_response.read_resp[i])
  204. read_data_response_cov_2.sample(i);
  205. success[read_data_response.rid][9:8] = 1;
  206. end
  207. else
  208. success[read_data_response.rid][9:8] = 2;
  209. endtask
  210. //////////////////////////////////////////// REPORT PHASE
  211. function void scoreboard::report_phase (uvm_phase phase);
  212. channel_1 = $fopen("Report.txt","a");
  213. $fdisplay (channel_1,"\n\n\t================================================================================================================================================");
  214. $fdisplay (channel_1,"\t\t ID \t ADDRESS \t WRITE_DATA \t WRITE_RESPONSE \t READ_ADDRESS \t READ_DATA and RESPONSE \n");
  215. foreach (success[i])
  216. $fdisplay (channel_1,"\t\t %0d \t %0d \t\t %0d \t\t %0d \t\t\t %0d \t\t %0d \n",i,success[i][1:0],success[i][3:2],success[i][5:4],success[i][7:6],success[i][9:8]);
  217. $fdisplay (channel_1,"\n\n\t===============================================================================================================================================");
  218. $fclose(channel_1);
  219. $display ("\n\n\t\t\t\t\t\t\t\t REPORT");
  220. $display ("\n\n============================================================================================================================================");
  221. $display ("\n\n\t\t\t\t\t\t 0 ==> TRANSACTION NOT RECIEVED (`~`) \n");
  222. $display ("\t\t\t\t\t 1 ==> TRANSACTION COMPARED SUCCESSFULLY (`_`) \n");
  223. $display ("\t\t\t\t\t 2 ==> TRANSACTION COMPARED BUT NOT MATCHING (-_-) \n");
  224. $display ("\n============================================================================================================================================\n\n");
  225. $display ("\t ID \t ADDRESS \t WRITE_DATA \t WRITE_RESPONSE \t READ_ADDRESS \t READ_DATA and RESPONSE \n");
  226. foreach (success[i])
  227. $display ("\t %0d \t %0d \t\t %0d \t\t %0d \t\t\t %0d \t\t %0d \n",i,success[i][1:0],success[i][3:2],success[i][5:4],success[i][7:6],success[i][9:8]);
  228. $display ("\n\n============================================================================================================================================");
  229. endfunction