微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 微电子和IC设计 > IC验证交流 > 请教:UVM scoreboard override的问题

请教:UVM scoreboard override的问题

时间:10-02 整理:3721RD 点击:
UVM平台中,有一个建好的my_scoreboard。
现在,有一个testcase需要使用不同的scoreboard,即在scoreboard中main_phase中需要比较不同的transaction,便想到了override功能。
新建class my_new_scoreboard extends my_scoreboard;,使用set_type_override_by_type(my_scoreboard::get_type(), my_new_scoreboard::get_type())重载,但是运行结果仍然是my_scoreboard中main_phase的行为,我期望的是重载后,希望运行my_new_scoreboard 中的代码。
使用factory.print(2)和uvm_top.print()打印重载信息和拓扑结构,结果如下:

  1. #### Factory Configuration (*)
  2. #
  3. # No instance overrides are registered with this factory
  4. #
  5. # Type Overrides:
  6. #
  7. #Requested TypeOverride Type
  8. #---------------------------------------
  9. #my_scoreboardmy_new_scoreboard
  10. # (*) Types with no associated type name will be printed as <unknown>
  11. #
  12. ####

  13. #scbmy_new_scoreboard-@727
  14. #act_portuvm_blocking_get_port-@1430
  15. #exp_portuvm_blocking_get_port-@1421
  16. #exp_port_readuvm_blocking_get_port-@1439

复制代码

my_scoreboard的源代码如下,act_port与exp_port中的transaction比较:

  1. class my_scoreboard extends uvm_scoreboard;

  2. traffic_trexpect_queue[$];
  3. uvm_blocking_get_port #(traffic_tr)exp_port;

  4. Read64OP_trexpect_queue_read[$];
  5. uvm_blocking_get_port #(Read64OP_tr)exp_port_read;

  6. uvm_blocking_get_port #(Response_tr)act_port;

  7. `uvm_component_utils(my_scoreboard)
  8. extern function new(string name, uvm_component parent = null);
  9. extern virtual function void build_phase(uvm_phase phase);
  10. extern virtual task main_phase(uvm_phase phase);
  11. endclass

  12. function my_scoreboard::new(string name, uvm_component parent = null);
  13. super.new(name, parent);
  14. endfunction

  15. function void my_scoreboard::build_phase(uvm_phase phase);
  16. super.build_phase(phase);
  17. exp_port = new("exp_port", this);
  18. act_port = new("act_port", this);
  19. exp_port_read = new("exp_port_read", this);
  20. endfunction

  21. task my_scoreboard::main_phase(uvm_phase phase);
  22. traffic_trget_expect, tmp_tran;
  23. Response_tr get_actual;
  24. bit result;

  25. fork
  26. while (1) begin
  27. exp_port.get(get_expect);
  28. `uvm_info("my_scoreboard", "my_scoreboard get the expect pkt, push_back it into expect_queue, and print it: ", UVM_LOW);
  29. get_expect.print();
  30. expect_queue.push_back(get_expect);
  31. end

  32. while (1) begin
  33. act_port.get(get_actual);
  34. `uvm_info("my_scoreboard", "get one actual pkt from monitor/DUT, and print it: ", UVM_LOW);
  35. get_actual.print();

  36. if(expect_queue.size() > 0) begin
  37. tmp_tran = expect_queue.pop_front();
  38. `uvm_info("my_scoreboard", "for comparing with expect pkt, pop_front one expect pkt from expect_queue, and print it: ", UVM_LOW);
  39. tmp_tran.print();

  40. result = (tmp_tran.exp_color==get_actual.act_color);
  41. if(result) begin
  42. `uvm_info("my_scoreboard: compare success", "Compare SUCCESSFULLY", UVM_LOW);
  43. $display("the expect pkt from model is: ");
  44. tmp_tran.print();
  45. $display("the actual pkt from dut is: ");
  46. get_actual.print();
  47. end
  48. else begin
  49. `uvm_error("my_scoreboard: compare fail", "Compare FAILED");
  50. $display("the expect pkt from model is: ");
  51. tmp_tran.print();
  52. $display("the actual pkt from dut is: ");
  53. get_actual.print();
  54. end
  55. end
  56. else begin
  57. `uvm_error("my_scoreboard", "Received from DUT, while Expect Queue is empty");
  58. $display("the unexpected pkt is");
  59. get_actual.print();
  60. end
  61. end
  62. join

  63. endtask

复制代码

my_new_scoreboard的源代码如下,act_port与exp_port_read中的transaction比较:

  1. class my_new_scoreboard extends my_scoreboard;

  2. `uvm_component_utils(my_new_scoreboard)
  3. function new(string name, uvm_component parent = null);
  4. super.new(name, parent);
  5. endfunction

  6. virtual function void build_phase(uvm_phase phase);
  7. super.build_phase(phase);
  8. exp_port = new("exp_port", this);
  9. act_port = new("act_port", this);
  10. exp_port_read = new("exp_port_read", this);
  11. endfunction

  12. virtual task main_phase(uvm_phase phase);
  13. Read64OP_trget_expect, tmp_tran;
  14. Response_tr get_actual;
  15. bit result;

  16. fork
  17. while (1) begin
  18. exp_port_read.get(get_expect);
  19. `uvm_info("my_new_scoreboard", "my_new_scoreboard get the expect pkt, push_back it into expect_queue_read, and print it: ", UVM_LOW);
  20. get_expect.print();
  21. expect_queue_read.push_back(get_expect);
  22. end

  23. while (1) begin
  24. act_port.get(get_actual);
  25. `uvm_info("my_new_scoreboard", "get one actual pkt from monitor/DUT, and print it: ", UVM_LOW);
  26. get_actual.print();

  27. if(expect_queue_read.size() > 0) begin
  28. tmp_tran = expect_queue_read.pop_front();
  29. `uvm_info("my_new_scoreboard", "for comparing with expect pkt, pop_front one expect pkt from expect_queue_read, and print it: ", UVM_LOW);
  30. tmp_tran.print();

  31. result = (tmp_tran.data0==get_actual.resp_data0) & (tmp_tran.data1==get_actual.resp_data1) &(tmp_tran.data2==get_actual.resp_data2) & (tmp_tran.data3==get_actual.resp_data3);
  32. if(result) begin
  33. `uvm_info("my_new_scoreboard: Read64OP compare success", "Compare SUCCESSFULLY", UVM_LOW);
  34. $display("the expect pkt from model is: ");
  35. tmp_tran.print();
  36. $display("the actual pkt from dut is: ");
  37. get_actual.print();
  38. end
  39. else begin
  40. `uvm_error("my_new_scoreboard: Read64OP compare fail", "Compare FAILED");
  41. $display("the expect pkt from model is: ");
  42. tmp_tran.print();
  43. $display("the actual pkt from dut is: ");
  44. get_actual.print();
  45. end
  46. end
  47. else begin
  48. `uvm_error("my_new_scoreboard", "Received from DUT, while Expect Queue is empty");
  49. $display("the unexpected pkt is");
  50. get_actual.print();
  51. end
  52. end
  53. join

  54. endtask

  55. endclass

复制代码

在testcase中,使用set_type_override_by_type重载:

  1. function void case0::build_phase(uvm_phase phase);
  2. super.build_phase(phase);

  3. set_type_override_by_type(my_scoreboard::get_type(), my_new_scoreboard::get_type());

  4. uvm_config_db#(uvm_object_wrapper)::set(this,
  5. "env.agt.sqr.main_phase",
  6. "default_sequence",
  7. case0_seq::type_id::get());
  8. endfunction

复制代码

运行结果却仍然是my_scoreboard中的内容:

  1. UVM_ERROR my_scoreboard.sv(80) @ 10106600: uvm_test_top.env.mt_agt.scb [my_scoreboard] Received from DUT, while Expect Queue is empty
  2. UVM_ERROR my_scoreboard.sv(80) @ 10106600: uvm_test_top.env.mt_agt.scb [my_scoreboard] Received from DUT, while Expect Queue is empty
  3. UVM_ERROR my_scoreboard.sv(80) @ 10106600: uvm_test_top.env.mt_agt.scb [my_scoreboard] Received from DUT, while Expect Queue is empty
  4. UVM_ERROR my_scoreboard.sv(80) @ 10106600: uvm_test_top.env.mt_agt.scb [my_scoreboard] Received from DUT, while Expect Queue is empty

复制代码

重载不成功,请教大家这个怎么解决?

my_new_scoreboard build_phase中的3个NEW去掉,好像跟重载关系不大

谢谢。这个我试了,有没有new结果都是一样的

scb你用的是new创建还是create创建的?

scb = my_scoreboard::type_id::create("scb", this);
create建的

scb = meteor3_scoreboard::type_id::create("scb", this);

小编解决了吗?
重载在new之前调用呢?

小编,既然是不同的scoreboard,那transaction是不同类型的吗?那你的driver和sequencer的参数也要override吧?

你的my_scoreboard中除了new之外的希望被重载的function和task应该加上virtual,my_new_scoreboard中的function和task前加不加vritual都可以

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top