0

I would like to extend dur_error() method in order to write the name of the package from which the error is reported.

1 Answers1

5

The dut_error() is not really a method (it is a macro that calls multiple methods), so cannot be extended.

But you can extend the dut_error_struct, and then add the code that you want. Using source_struct() you can know what struct called dut_error(), and using reflection - you can tell in which package it was defined. 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.

user3467290
  • 706
  • 3
  • 4