在线咨询
eetop公众号 创芯大讲堂 创芯人才网
切换到宽版

EETOP 创芯网论坛 (原名:电子顶级开发网)

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
查看: 4093|回复: 8

[求助] 请教:UVM scoreboard override的问题

[复制链接]
发表于 2016-4-25 14:31:21 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

x
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 Type      Override Type        
  8. #   ------------------  ---------------------
  9. #   my_scoreboard       my_new_scoreboard
  10. # (*) Types with no associated type name will be printed as <unknown>
  11. #
  12. ####

  13. #         scb                    my_new_scoreboard       -     @727
  14. #           act_port             uvm_blocking_get_port       -     @1430
  15. #           exp_port             uvm_blocking_get_port       -     @1421
  16. #           exp_port_read        uvm_blocking_get_port       -     @1439


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




  1. class my_scoreboard extends uvm_scoreboard;
  2.    
  3.    traffic_tr  expect_queue[$];
  4.    uvm_blocking_get_port #(traffic_tr)  exp_port;
  5.    
  6.    Read64OP_tr  expect_queue_read[$];
  7.    uvm_blocking_get_port #(Read64OP_tr)  exp_port_read;
  8.    
  9.    uvm_blocking_get_port #(Response_tr)  act_port;
  10.    
  11.    `uvm_component_utils(my_scoreboard)
  12.    extern function new(string name, uvm_component parent = null);
  13.    extern virtual function void build_phase(uvm_phase phase);
  14.    extern virtual task main_phase(uvm_phase phase);
  15. endclass

  16. function my_scoreboard::new(string name, uvm_component parent = null);
  17.    super.new(name, parent);
  18. endfunction

  19. function void my_scoreboard::build_phase(uvm_phase phase);
  20.    super.build_phase(phase);
  21.    exp_port = new("exp_port", this);
  22.    act_port = new("act_port", this);
  23.    exp_port_read = new("exp_port_read", this);
  24. endfunction

  25. task my_scoreboard::main_phase(uvm_phase phase);
  26.    traffic_tr  get_expect, tmp_tran;
  27.    Response_tr get_actual;
  28.    bit result;

  29.          fork
  30.              while (1) begin
  31.                 exp_port.get(get_expect);
  32.                 `uvm_info("my_scoreboard", "my_scoreboard get the expect pkt, push_back it into expect_queue, and print it: ", UVM_LOW);
  33.                 get_expect.print();
  34.                 expect_queue.push_back(get_expect);
  35.              end
  36.              
  37.              while (1) begin
  38.                 act_port.get(get_actual);
  39.                 `uvm_info("my_scoreboard", "get one actual pkt from monitor/DUT, and print it: ", UVM_LOW);
  40.                 get_actual.print();
  41.                 
  42.                 if(expect_queue.size() > 0) begin
  43.                                 tmp_tran = expect_queue.pop_front();
  44.                                 `uvm_info("my_scoreboard", "for comparing with expect pkt, pop_front one expect pkt from expect_queue, and print it: ", UVM_LOW);
  45.                                 tmp_tran.print();
  46.                                 
  47.                                 result = (tmp_tran.exp_color==get_actual.act_color);
  48.                                 if(result) begin
  49.                                    `uvm_info("my_scoreboard: compare success", "Compare SUCCESSFULLY", UVM_LOW);
  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.                                 else begin
  56.                                    `uvm_error("my_scoreboard: compare fail", "Compare FAILED");
  57.                                    $display("the expect pkt from model is: ");
  58.                        tmp_tran.print();
  59.                        $display("the actual pkt from dut is: ");
  60.                        get_actual.print();
  61.                                 end
  62.                             end
  63.                 else begin
  64.                                 `uvm_error("my_scoreboard", "Received from DUT, while Expect Queue is empty");
  65.                                 $display("the unexpected pkt is");
  66.                                 get_actual.print();
  67.                 end
  68.              end  
  69.          join
  70.      
  71. endtask


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




  1. class my_new_scoreboard extends my_scoreboard;
  2.    
  3.    `uvm_component_utils(my_new_scoreboard)
  4.          function new(string name, uvm_component parent = null);
  5.       super.new(name, parent);
  6.    endfunction
  7.    
  8.    virtual function void build_phase(uvm_phase phase);
  9.                    super.build_phase(phase);
  10.                    exp_port = new("exp_port", this);
  11.                    act_port = new("act_port", this);
  12.                    exp_port_read = new("exp_port_read", this);
  13.          endfunction

  14.    virtual task main_phase(uvm_phase phase);
  15.               Read64OP_tr  get_expect, tmp_tran;
  16.                    Response_tr get_actual;
  17.                    bit result;
  18.                   
  19.                   fork
  20.                      while (1) begin
  21.                         exp_port_read.get(get_expect);
  22.                         `uvm_info("my_new_scoreboard", "my_new_scoreboard get the expect pkt, push_back it into expect_queue_read, and print it: ", UVM_LOW);
  23.                         get_expect.print();
  24.                         expect_queue_read.push_back(get_expect);
  25.                      end
  26.                      
  27.                      while (1) begin
  28.                         act_port.get(get_actual);
  29.                         `uvm_info("my_new_scoreboard", "get one actual pkt from monitor/DUT, and print it: ", UVM_LOW);
  30.                         get_actual.print();
  31.                         
  32.                         if(expect_queue_read.size() > 0) begin
  33.                                         tmp_tran = expect_queue_read.pop_front();
  34.                                         `uvm_info("my_new_scoreboard", "for comparing with expect pkt, pop_front one expect pkt from expect_queue_read, and print it: ", UVM_LOW);
  35.                                         tmp_tran.print();
  36.                                         
  37.                                         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);
  38.                                         if(result) begin
  39.                                            `uvm_info("my_new_scoreboard: Read64OP compare success", "Compare SUCCESSFULLY", UVM_LOW);
  40.                                            $display("the expect pkt from model is: ");
  41.                                tmp_tran.print();
  42.                                $display("the actual pkt from dut is: ");
  43.                                get_actual.print();
  44.                                         end
  45.                                         else begin
  46.                                            `uvm_error("my_new_scoreboard: Read64OP compare fail", "Compare FAILED");
  47.                                            $display("the expect pkt from model is: ");
  48.                                tmp_tran.print();
  49.                                $display("the actual pkt from dut is: ");
  50.                                get_actual.print();
  51.                                         end
  52.                                     end
  53.                         else begin
  54.                                         `uvm_error("my_new_scoreboard", "Received from DUT, while Expect Queue is empty");
  55.                                         $display("the unexpected pkt is");
  56.                                         get_actual.print();
  57.                         end
  58.                      end  
  59.                   join
  60.                      
  61.                 endtask
  62.                
  63. endclass


复制代码
在testcase中,使用set_type_override_by_type重载:



  1. function void case0::build_phase(uvm_phase phase);
  2.    super.build_phase(phase);
  3.    
  4.    set_type_override_by_type(my_scoreboard::get_type(), my_new_scoreboard::get_type());
  5.    
  6.    uvm_config_db#(uvm_object_wrapper)::set(this,
  7.                                            "env.agt.sqr.main_phase",
  8.                                            "default_sequence",
  9.                                            case0_seq::type_id::get());
  10. 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


复制代码
重载不成功,请教大家这个怎么解决?
发表于 2016-4-25 18:58:53 | 显示全部楼层
本帖最后由 AnswerLJ 于 2016-4-25 19:02 编辑

my_new_scoreboard build_phase中的3个NEW去掉,好像跟重载关系不大
 楼主| 发表于 2016-4-26 08:12:44 | 显示全部楼层
回复 2# AnswerLJ


    谢谢。这个我试了,有没有new结果都是一样的
发表于 2016-4-26 08:57:08 | 显示全部楼层
scb你用的是new创建还是create创建的?
 楼主| 发表于 2016-4-26 09:31:37 | 显示全部楼层
回复 4# hover99


    scb = my_scoreboard::type_id::create("scb", this);
create建的
 楼主| 发表于 2016-4-26 09:32:29 | 显示全部楼层
回复 4# hover99

scb = meteor3_scoreboard::type_id::create("scb", this);
发表于 2016-11-2 13:52:58 | 显示全部楼层
楼主解决了吗????
重载在new之前调用呢?
发表于 2016-11-2 14:48:05 | 显示全部楼层
楼主,既然是不同的scoreboard,那transaction是不同类型的吗?那你的driver和sequencer的参数也要override吧?
发表于 2017-1-22 16:53:53 | 显示全部楼层
你的my_scoreboard中除了new之外的希望被重载的function和task应该加上virtual,my_new_scoreboard中的function和task前加不加vritual都可以
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

站长推荐 上一条 /1 下一条

小黑屋| 手机版| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-9-27 12:17 , Processed in 0.024202 second(s), 7 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表