【问题标题】:Specman e compilation error: No such variable 'XXX'Specman e 编译错误:没有这样的变量 'XXX'
【发布时间】:2014-09-16 07:49:51
【问题描述】:

我在函数post_access()中定义了一个变量my_reg_file(这个函数是一个vr_ad实现副作用的钩子):

//file1.e
extend TIMER_LOAD_0 vr_ad_reg {
    post_access(direction : vr_ad_rw_t) is first {
        var my_reg_file : TIMER vr_ad_reg_file = 
        get_parents()[0].as_a(TIMER vr_ad_reg_file);

        ....  

    };
};

然后我在另一个e文件中扩展这个函数:

//file2.e
extend TIMER_LOAD_0 vr_ad_reg {
    post_access(direction : vr_ad_rw_t) is also {
        start my_reg_file.some_tcm();
    };
};

我得到一个编译错误:

*** Error: No such variable 'my_reg_file'

为什么post_access() 不能识别变量my_reg_file?感谢您的帮助。

注意:file1.e 在 file2.e 之前导入

【问题讨论】:

  • 谢谢,帮我分配:)

标签: specman e


【解决方案1】:

my_reg_file 是该特定方法层的局部变量,不与其他方法层共享。 我认为方法层之间进行通信的唯一方法是: 一种。使用可以从任何方法层访问的结果保存变量。 湾。使用结构成员。

【讨论】:

    【解决方案2】:

    另一个似乎更好的解决方案是为这个子类型添加一个单独的方法,例如get_my_reg_file(),会返回想要的值,然后在需要这个值的地方调用这个方法,而不是使用局部变量。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-14
      • 1970-01-01
      相关资源
      最近更新 更多