|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
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()打印重载信息和拓扑结构,结果如下:
- #### Factory Configuration (*)
- #
- # No instance overrides are registered with this factory
- #
- # Type Overrides:
- #
- # Requested Type Override Type
- # ------------------ ---------------------
- # my_scoreboard my_new_scoreboard
- # (*) Types with no associated type name will be printed as <unknown>
- #
- ####
- # scb my_new_scoreboard - @727
- # act_port uvm_blocking_get_port - @1430
- # exp_port uvm_blocking_get_port - @1421
- # exp_port_read uvm_blocking_get_port - @1439
复制代码 my_scoreboard的源代码如下,act_port与exp_port中的transaction比较:
- class my_scoreboard extends uvm_scoreboard;
-
- traffic_tr expect_queue[$];
- uvm_blocking_get_port #(traffic_tr) exp_port;
-
- Read64OP_tr expect_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_tr get_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
复制代码 my_new_scoreboard的源代码如下,act_port与exp_port_read中的transaction比较:
- 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_tr get_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
复制代码 在testcase中,使用set_type_override_by_type重载:
- 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
复制代码 运行结果却仍然是my_scoreboard中的内容:
- 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
复制代码 重载不成功,请教大家这个怎么解决? |
|