vmm_data

1. 成员解释:

stream_id: 指示何种设备发出或传送的transaction。一般和transactor相关

data_id: transaction的序号

scenario_id:某设备传送的一组transaction,构成了一个scenario.

vmm_notify

 

我们只需要指定一个静态的log就可以构造出一个vmm_data实例。即, new(vmm_log log).

 

2. constraint的命名规则:

must obey constraint:"class_name_valid"

should obey constraint:  "class_name_rule   or class_name_var_local"

 

3. 必须补全的函数

 

virtual function string psdisplay(string prefix);
     psdisplay=super.psdisplay(prefix);   //输出 prefix以及stream_id,data_id, scenario_id
     $sformat(psdisplay, "%s,....", psdisplay,this.member);
endfunction

virtual function bit is_valid(bit silent=1, int kind=0);
is_valid=1;
if(!super.is_valid(silent,kind)) begin
      is_valid=0; 
      return;
end
if(kind) begin
       if(this.move==IDLE) begin
           if(!silent) `vmm_error(log,"must not be IDLE");
           is_valid=0;
           return;
       end
end
else begin
       if(!this.randomize(null))begin
             if(!silent)  `vmm_error(log,"failed randomization check");
             is_valid=0;
             return;
       end
end
endfunction     

virtual function vmm_data allocate();
        packet  tr=new();
        allocate=tr;
endfunction
 
virtual function vmm_data copy(vmm_data to=null);
         packet cpy;
         if(to ==null) cpy=new;
         else if(!$cast(cpy, to)) begin
            `vmm_fatal(log, "Attemping to copy mismatched packet instance");
         end
         this.copy_data(cpy);
         cpy.prop= this.prop;    //扩展成员拷贝
          .......
          copy=cpy;
endfunction

function void post_randomize()
        ....
endfunction

virtual function bit compare(vmm_data to, output string diff, input int kind = -1);
    packet pkt;
    compare=0;
    if(to==null) begin diff="No target Compare Object!"; return;  end
    if(!$cast(pkt,to)) begin  diff="Not object of the same class!"; return; end
    if(..!=..)      diff="..."   return;   end
    if(..!=..)      diff="..."   return;   end
    diff = "successful compare!";
    compare=1;
endfunction          

 

通过copy 和 compare函数不难发现, 源或目的一般用最基本的基类,而在函数中声明一个当前的扩展类的handler,然后检查这源或目是否为空,如果为空则给声明的扩展类的handler分派内存,否则通过cast直接赋值给扩展类的handler。 如果基类handler被赋扩展类的handler后只能看到基类的数据成员和基类虚函数对应的扩展类的函数。

 

4. transaction(data item) 即 vmm_data 的派生类 的new函数不应该带任何参数。--- generator 的需要。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值