Lab5实现了多通道同时验证,遗留的问题是:发多少个包才能将所有输入输出端口的组合都测试一遍?这需要用功能覆盖率来回答。
Functional coverage
在Scoreboard类里增加coverage
部分,执行功能覆盖率来跟踪testbench的进程,当输入输出的组合全部验到之后结束仿真。
`ifndef INC_SCOREBOARD_SV
`ifndef INC_SCOREBOARD_SV
class Scoreboard;
string name;
event DONE;
Packet refPkt[$];
Packet pkt2send, pkt2cmp;
pkt_mbox driver_mbox, receiver_mbox;
// functional coverage properties
bit [3:0] sa, da;
covergroup router_cv;
coverpoint sa;
coverpoint da;
cross sa, da;
endgroup
extern function new(string name = "Scoreboard", pkt_mbox driver_mbox = null, recevier_mbox = null);
extern virtual task start();
extern virtual task check(); // compare
endclass
function Scoreboard::new(string name, pkt_mbox driver_mbox, recevier_mbox);
this.name = name;
if(driver_mbox == null) driver_mbox = new(); // 为入口参数driver_mbox分配空间
this.driver_mbox = diver_mbox;
if(receiver_mbox == null) receiver_mbox = new(); // 为入口参数recevier_mbox分配空间
this.receiver_mbox = receiver_mbox;
router_cv = new(); // functional coverage
endfunction
task Scoreboard::start();
fork
forever begin
this.receiver_mbox.get(this.pkt2cmp);
while( this.driver_mbox.num() ) begin
Packet pkt;
this.driver_mbox.get(pkt);
this.refPkt.push_back(pkt);
end
this.check();
end
join_none
endtask:start
task Scoreboard::check();
real coverage_result; // functional coverage
int index[$];
string message;
static int pkt_checked = 0;
index = this.refPkt.find_first_index() with (item.da == this.pkt2c