【发布时间】:2020-02-27 08:14:01
【问题描述】:
下面SystemVerilog代码中的“virtual tinyalu_bfm”是什么意思?示例:
uvm_config_db #(virtual tinyalu_bfm)::set(null, "*", "bfm", bfm);
如果我省略了 virtual 关键字,会有什么不同吗?只是好奇,因为 virtual 的通常 oop 含义仅适用于类或类成员,这是一个示例,它应用于一个接口,该接口被传递到作为 UVM 包的一部分的静态函数中......只是想知道为什么我需要在这种情况下称它为虚拟的,它的目的是使它成为虚拟的。
module top;
// UVM Framework
import uvm_pkg::*;
`include "uvm_macros.svh"
import tinyalu_pkg::*; //import all tb classes and types
tinyalu_bfm bfm();
// invoke APIs from uvm_pkg to start test...
initial begin
uvm_config_db #(virtual tinyalu_bfm)::set(null, "*", "bfm", bfm);
run_test();
end
endmodule : top
interface tinyalu_bfm;
byte unsigned A;
byte unsigned B;
bit clk;
bit reset_n;
initial begin
clk = 0;
forever begin
#10;
clk = ~clk;
end
end
task reset_alu();
reset_n = 1'b0;
@(negedge clk);
@(negedge clk);
reset_n = 1'b1;
start = 1'b0;
endtask : reset_alu
task send_op(input byte iA, input byte iB, input operation_t iop, output shortint alu_result);
// ...
endtask : send_op
endinterface : tinyalu_bfm
再看这里...接口对象也被声明为虚拟...为什么?
// FILE: random_test.svh
class random_test extends uvm_test;
// ...
virtual tinyalu_bfm bfm;
function new (string name, uvm_component parent);
super.new(name,parent);
if(!uvm_config_db #(virtual tinyalu_bfm)::get(null, "*","bfm", bfm))
$fatal("Failed to get BFM");
endfunction : new
task run_phase(uvm_phase phase);
//...
endtask : run_phase
endclass
【问题讨论】:
-
请参阅第 10 章:高级接口,“用于验证的系统 Verilog”,2012 年第 3 版,作者:Chris Spear 和 Greg Tumbush……“虚拟接口的更好名称应该是”参考接口。”
标签: system-verilog uvm