我可以扩展dut_error()方法吗?

时间:2017-12-31 12:52:25

标签: specman e

我想扩展dur_error()方法,以便编写报告错误的包的名称。

1 个答案:

答案 0 :(得分:5)

dut_error()实际上不是一个方法(它是一个调用多个方法的宏),因此无法扩展。

但是你可以扩展dut_error_struct,然后添加你想要的代码。使用source_struct(),您可以知道什么结构称为dut_error(),并使用反射 - 您可以告诉它在哪个包中定义。 例如 -

extend dut_error_struct {
    write() is first {
    out(source_struct() is a any_unit ? "UNIT " : "STRUCT ",
        source_struct_name(), " reporting of error: ");


    // Special output for errors coming from the ahb package:

    // Using reflection, can get lots of info about the reporting struct.
    // For example - in which package it was defined

    // If using annotation - can use them as well.
    // For example - different messages for annotated features

    var reporter_rf : rf_struct = 
      rf_manager.get_struct_of_instance(source_struct());
    if reporter_rf.get_package().get_name() == "ahb" {
        out(append("xxxxxx another bug in AHB package, ",
                       "\nreported ", source_location()));
    }; 
};

我建议在帮助中查找dut_error_struct,以查看此struct的方法。