SystemVerilog Testbench Lab6: functional coverage, standardizing the environment

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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值