我想扩展 dur_error() 方法以编写报告错误的包的名称。
1 回答
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,以查看该结构的方法。
于 2017-12-31T14:38:42.587 回答