请教: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()打印重载信息和拓扑结构,结果如下:
现在,有一个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()打印重载信息和拓扑结构,结果如下:
- #### Factory Configuration (*)
- #
- # No instance overrides are registered with this factory
- #
- # Type Overrides:
- #
- #Requested TypeOverride Type
- #---------------------------------------
- #my_scoreboardmy_new_scoreboard
- # (*) Types with no associated type name will be printed as <unknown>
- #
- ####
- #scbmy_new_scoreboard-@727
- #act_portuvm_blocking_get_port-@1430
- #exp_portuvm_blocking_get_port-@1421
- #exp_port_readuvm_blocking_get_port-@1439
- class my_scoreboard extends uvm_scoreboard;
- traffic_trexpect_queue[$];
- uvm_blocking_get_port #(traffic_tr)exp_port;
- Read64OP_trexpect_queue_read[$];
- uvm_blocking_get_port #(Read64OP_tr)exp_port_read;
- uvm_blocking_get_port #(Response_tr)act_port;
- `uvm_component_utils(my_scoreboard)
- extern function new(string name, uvm_component parent = null);
- extern virtual function void build_phase(uvm_phase phase);
- extern virtual task main_phase(uvm_phase phase);
- endclass
- function my_scoreboard::new(string name, uvm_component parent = null);
- super.new(name, parent);
- endfunction
- function void my_scoreboard::build_phase(uvm_phase phase);
- super.build_phase(phase);
- exp_port = new("exp_port", this);
- act_port = new("act_port", this);
- exp_port_read = new("exp_port_read", this);
- endfunction
- task my_scoreboard::main_phase(uvm_phase phase);
- traffic_trget_expect, tmp_tran;
- Response_tr get_actual;
- bit result;
- fork
- while (1) begin
- exp_port.get(get_expect);
- `uvm_info("my_scoreboard", "my_scoreboard get the expect pkt, push_back it into expect_queue, and print it: ", UVM_LOW);
- get_expect.print();
- expect_queue.push_back(get_expect);
- end
- while (1) begin
- act_port.get(get_actual);
- `uvm_info("my_scoreboard", "get one actual pkt from monitor/DUT, and print it: ", UVM_LOW);
- get_actual.print();
- if(expect_queue.size() > 0) begin
- tmp_tran = expect_queue.pop_front();
- `uvm_info("my_scoreboard", "for comparing with expect pkt, pop_front one expect pkt from expect_queue, and print it: ", UVM_LOW);
- tmp_tran.print();
- result = (tmp_tran.exp_color==get_actual.act_color);
- if(result) begin
- `uvm_info("my_scoreboard: compare success", "Compare SUCCESSFULLY", UVM_LOW);
- $display("the expect pkt from model is: ");
- tmp_tran.print();
- $display("the actual pkt from dut is: ");
- get_actual.print();
- end
- else begin
- `uvm_error("my_scoreboard: compare fail", "Compare FAILED");
- $display("the expect pkt from model is: ");
- tmp_tran.print();
- $display("the actual pkt from dut is: ");
- get_actual.print();
- end
- end
- else begin
- `uvm_error("my_scoreboard", "Received from DUT, while Expect Queue is empty");
- $display("the unexpected pkt is");
- get_actual.print();
- end
- end
- join
- endtask
- class my_new_scoreboard extends my_scoreboard;
- `uvm_component_utils(my_new_scoreboard)
- function new(string name, uvm_component parent = null);
- super.new(name, parent);
- endfunction
- virtual function void build_phase(uvm_phase phase);
- super.build_phase(phase);
- exp_port = new("exp_port", this);
- act_port = new("act_port", this);
- exp_port_read = new("exp_port_read", this);
- endfunction
- virtual task main_phase(uvm_phase phase);
- Read64OP_trget_expect, tmp_tran;
- Response_tr get_actual;
- bit result;
- fork
- while (1) begin
- exp_port_read.get(get_expect);
- `uvm_info("my_new_scoreboard", "my_new_scoreboard get the expect pkt, push_back it into expect_queue_read, and print it: ", UVM_LOW);
- get_expect.print();
- expect_queue_read.push_back(get_expect);
- end
- while (1) begin
- act_port.get(get_actual);
- `uvm_info("my_new_scoreboard", "get one actual pkt from monitor/DUT, and print it: ", UVM_LOW);
- get_actual.print();
- if(expect_queue_read.size() > 0) begin
- tmp_tran = expect_queue_read.pop_front();
- `uvm_info("my_new_scoreboard", "for comparing with expect pkt, pop_front one expect pkt from expect_queue_read, and print it: ", UVM_LOW);
- tmp_tran.print();
- 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);
- if(result) begin
- `uvm_info("my_new_scoreboard: Read64OP compare success", "Compare SUCCESSFULLY", UVM_LOW);
- $display("the expect pkt from model is: ");
- tmp_tran.print();
- $display("the actual pkt from dut is: ");
- get_actual.print();
- end
- else begin
- `uvm_error("my_new_scoreboard: Read64OP compare fail", "Compare FAILED");
- $display("the expect pkt from model is: ");
- tmp_tran.print();
- $display("the actual pkt from dut is: ");
- get_actual.print();
- end
- end
- else begin
- `uvm_error("my_new_scoreboard", "Received from DUT, while Expect Queue is empty");
- $display("the unexpected pkt is");
- get_actual.print();
- end
- end
- join
- endtask
- endclass
- function void case0::build_phase(uvm_phase phase);
- super.build_phase(phase);
- set_type_override_by_type(my_scoreboard::get_type(), my_new_scoreboard::get_type());
- uvm_config_db#(uvm_object_wrapper)::set(this,
- "env.agt.sqr.main_phase",
- "default_sequence",
- case0_seq::type_id::get());
- endfunction
- UVM_ERROR my_scoreboard.sv(80) @ 10106600: uvm_test_top.env.mt_agt.scb [my_scoreboard] Received from DUT, while Expect Queue is empty
- UVM_ERROR my_scoreboard.sv(80) @ 10106600: uvm_test_top.env.mt_agt.scb [my_scoreboard] Received from DUT, while Expect Queue is empty
- UVM_ERROR my_scoreboard.sv(80) @ 10106600: uvm_test_top.env.mt_agt.scb [my_scoreboard] Received from DUT, while Expect Queue is empty
- 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都可以