微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 微电子和IC设计 > 微电子学习交流 > 求助:rvm的问题

求助:rvm的问题

时间:12-12 整理:3721RD 点击:
class cell extends rvm_data {
  static rvm_log log = new("cell","class");
  integer a ;
  
  task new(){
    super.new(this.log)
  }
  virtual function rvm_data copy(rvm_data to = null) {
    cell cpy;
    if ( to == null )
      cpy = new ();
    else {
      if (!cast_assign(cpy, to ,CHECK)) {
        rvm_fatal(log,"not a cell instance");    
      }
    this.copy_data(cpy);
    cpy.a = this.a;
    copy = cpy;
  }
}
program test {
  cell a = new();
  cell b = new();
  cell c;
  a.a =1;
  b.a =2;
  cast_assign(c,a.copy());
  rvm_note(log,psprintf("%d",b.a));
}
报错:rvm_note这句null访问
如果改成
cast_assign(c,a.copy(b));
就没有问题,为什么?

if/else匹配的问题...
仔细检查一下copy函数里面,当to为null时,你没有
返回任何东西,所以...

哦,这个是凭印象写出来的,我现在没有环境
不确定当时是否写成下面这样了,我本意是写成这样的
copy没有返回任何东西,那就是null吧
cast_assign(c,null)也不报错?
class cell extends rvm_data {
  static rvm_log log = new("cell","class");
  integer a ;
  
  task new(){
    super.new(this.log)
  }
  virtual function rvm_data copy(rvm_data to = null) {
    cell cpy;
    if ( to == null )
      cpy = new ();
    else {
      if (!cast_assign(cpy, to ,CHECK)) {
        rvm_fatal(log,"not a cell instance");    
      }
    }
    this.copy_data(cpy);
    cpy.a = this.a;
    copy = cpy;
}
program test {
  cell a = new();
  cell b = new();
  cell c;
  a.a =1;
  b.a =2;
  cast_assign(c,a.copy());
  rvm_note(log,psprintf("%d",b.a));
}

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top