电力电子转战数字IC20220704day39——路科实验3c

报错1:Fatal: C:/Users/zx/Desktop/chenlab0/ch_pkg.sv(246): Illegal virtual interface dereference.

原因:root_test中的set_interface少写了连接到mcdt_mon的语句,也就是mcdt_mon没有接口接入

加上如图

编译tb和pkg两个文件(只编译pkg也会报错,每次都需要编译tb) 

输入命令行vsim -novopt -solvefaildebug work.tb1_chen "+TESTNAME=basic_test"

错误2:输出数据只有1位

 原因:tb文件中把三个输出wire删掉了,所以默认都是只有1位,加回去即可

 问题3:仿真停不下来,id只有1

问题4:没有checker的打印


放弃,不知道哪里出了问题


 重新整理了下结构,增加了mon_mailbox的例化,把通道从1/2/3改成了0/1/2,还是不行。

放弃

代码先存在这里

package ch_pkg;

semaphore run_stop_flags=new();//创建这个运行停止的标志存放桶
//**************************************************//
class ch_trans;
//首先,对变量做随机化,加入间隔
//Packed arrays can be made of only the single bit data types (bit, logic, reg), enumerated types, and other packed arrays and packed structures. This also means you cannot have packed arrays of integer types with predefined widths (e.g. a packed array of byte).
	rand bit [31:0] data[];//数据变成动态数组(合并数组两边都有[]的只能用单比特的数据类型比如bit logic reg、枚举类型)
	rand int channel_id;
	rand int pkt_id;
	rand int data_idle;
	rand int pkt_idle;
	     bit rsp;
	local static int object_id=0;//静态变量,一开始就分配了空间且一直存在
	
	constraint cstr{
					soft data.size inside {[4:8]};
					foreach(data[i])//按一定规律给出数据(伪随机数)
						data[i]=='h00C0_0000+(this.channel_id<<24)+(this.pkt_id<<8)+i;
					soft channel_id==0;
					soft pkt_id==0;
					data_idle inside{[0:2]};
					pkt_idle inside{[1:10]};//注意没有加soft,必须实现
	};
	//定义变量和约束后,每个类都需要做的是new函数,初始化/例化?
	function new();
		object_id++;
	endfunction
	//克隆函数,所有变量复制一次
	function ch_trans clone();
		ch_trans c =new();
		//c=new();//这两可以写成一句 ch_trans c = new();
		c.data       =this.data;
		c.channel_id =this.channel_id;
		c.pkt_id     =this.pkt_id;
		c.data_idle  =this.data_idle;
		c.pkt_idle   =this.pkt_idle;
		c.rsp        =this.rsp;
		return c;
	endfunction
	
	function string sprint();
		string s;
		s={s, $sformatf("======ch_trans====")};
		s={s, $sformatf("ch_trans object content. ")};
		s={s, $sformatf("object_id=%0d.\n", this.object_id)};
		foreach(data[i])
			s={s, $sformatf("data[%0d]=%8x ", i, this.data[i])};
		s={s, $sformatf("channel_id=%0d .", this.channel_id)};
		s={s, $sformatf("pkt_id=%0d .", this.pkt_id)};
		s={s, $sformatf("data_idle=%0d .", this.data_idle)};
		s={s, $sformatf("pkt_idle=%0d.", this.pkt_idle)};
		s={s, $sformatf("rsp=%0d.", this.rsp)};
		s={s, $sformatf("==============\n")};
		return s;//这里要返回s
	endfunction
	
endclass

//**************************************************//
class initiator_chen;
virtual interface_chen intf;//virtual表示在子类中会被调用到,声明类的成员变量接口指针必须用virtual
mailbox #(ch_trans) req_mailbox;
mailbox #(ch_trans) rsp_mailbox;//不用例化,只取gen中的用,但要声明

local string name;

function new(string name="initiator_chen");
	this.name=name;
endfunction

function void set_interface(virtual interface_chen intf);
	if(intf==null)
		$error("null, need to be intantiated.");
	else this.intf=intf;
endfunction

task run();
	this.drive();//要加this表示这个class中的drive
endtask

task drive();//取出gen的mb,取完放在哪里?句柄,而且是ch_trans
	ch_trans req, rsp;
	@(posedge intf.rstn)//复位后开始一直执行
	forever begin
		this.req_mailbox.get(req);//先取
		this.chnl_write(req);//后用
		rsp=req.clone();//再复制和点亮
		rsp.rsp&#
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值