简体   繁体   English

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

[英]Can I extend the dut_error() method?

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

The dut_error() is not really a method (it is a macro that calls multiple methods), so cannot be extended. dut_error()并不是真正的方法(它是调用多个方法的宏),因此无法扩展。

But you can extend the dut_error_struct, and then add the code that you want. 但是您可以扩展dut_error_struct,然后添加所需的代码。 Using source_struct() you can know what struct called dut_error(), and using reflection - you can tell in which package it was defined. 使用source_struct()可以知道称为dut_error()的结构,并使用反射-可以知道在哪个包中定义了它。 For example - 例如 -

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()));
    }; 
};

I recommend looking for dut_error_struct in the help, to see this struct's methods. 我建议在帮助中寻找dut_error_struct,以查看此struct的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM