求助:uvm的回调怎么使用`uvm_do_callbacks
时间:10-02
整理:3721RD
点击:
各位:
正在看《A practical Guide to Adopting the Universal Verification
》,正看到第四章最后的回调,将书上的例子跑一下,结果有错,我是新手,不知道遇到这种类型的错误该怎么弄,特来请教大家。
systemverilog代码:
program test;
import uvm_pkg::*;
`include "uvm_macros.svh"
class street extends uvm_component;
`uvm_component_utils(street)
function new(string name, uvm_component parent);
super.new(name, parent);
endfunction : new
task run();
`uvm_info("INFOl", "I vacationed here in 2010", UVM_LOW)
endtask : run
endclass : street
class city extends uvm_component;
streetMain_St;
`uvm_component_utils(city)
`uvm_register_cb(city,city_cbs)
function new(string name, uvm_component parent);
super.new(name, parent);
endfunction : new
function void build();// note that we allocate in the build()
super.build();
Main_St = street::type_id::create("Main_St", this);
endfunction : build
task run () ;
uvm_component child, parent;
string pr, ch;
child = get_child("Main_St");
parent= get_parent();
//pr= parent.get_full_name();
pr = parent.get_name();
ch = child.get_name();
`uvm_do_callbacks(city,city_cbs,pre_info(this))
`uvm_info(get_type_name(),$psprintf("Parent:%s Child:%s",pr,ch),UVM_LOW);
endtask :run
endclass:city
virtual class city_cbs extends uvm_callback;
function new(string name="city_cb");
super.new(name);
endfunction
pure virtual function void pre_info(city c);
endclass : city_cbs
class state extends uvm_component;
city Capital_city;
`uvm_component_utils(state)
function new(string name, uvm_component parent);
super.new(name, parent);
endfunction : new
function void build();
super.build();
Capital_city=city::type_id::create("Capital_city", this);
endfunction : build
function void end_of_elaboration();
this.print();
endfunction : end_of_elaboration
endclass:state
class my_city_cb extends city_cbs;
function new(string name ="my_city_cb");
super.new(name);
endfunction
virtual function void pre_info(city c);
`uvm_info("my_city_cb",$psprintf("pre_info called for city %s",c.get_full_name()),UVM_LOW)
endfunction
endclass:my_city_cb
state Florida=state::type_id::create("Florida", null);
state New_York=state::type_id::create("New_York", null);
typedef uvm_callbacks#(city,city_cbs) city_cb;
my_city_cb cb = new;
// Start UVM Phases
initial begin
city_cb::add(null,cb);
run_test();
end
initial #100 global_stop_request();
endprogram: test
用irun -uvm test.sv运行得到的错误提示:
file: test.sv
`uvm_do_callbacks(city,city_cbs,pre_info(this))
|
ncvlog: *E,SVNOTY (test.sv,34|58): Syntactically this identifier appears to begin a datatype but it does not refer to a visible datatype in the current scope.
(`define macro: uvm_do_obj_callbacks [/opt1/eda_tools/cadence2011/tools/uvm/uvm_lib/uvm_sv/sv/macros/uvm_callback_defines.svh line 162], `define macro: uvm_do_callbacks [/opt1/eda_tools/cadence2011/tools/uvm/uvm_lib/uvm_sv/sv/macros/uvm_callback_defines.svh line 139], file: test.sv line 34)
正在看《A practical Guide to Adopting the Universal Verification
》,正看到第四章最后的回调,将书上的例子跑一下,结果有错,我是新手,不知道遇到这种类型的错误该怎么弄,特来请教大家。
systemverilog代码:
program test;
import uvm_pkg::*;
`include "uvm_macros.svh"
class street extends uvm_component;
`uvm_component_utils(street)
function new(string name, uvm_component parent);
super.new(name, parent);
endfunction : new
task run();
`uvm_info("INFOl", "I vacationed here in 2010", UVM_LOW)
endtask : run
endclass : street
class city extends uvm_component;
streetMain_St;
`uvm_component_utils(city)
`uvm_register_cb(city,city_cbs)
function new(string name, uvm_component parent);
super.new(name, parent);
endfunction : new
function void build();// note that we allocate in the build()
super.build();
Main_St = street::type_id::create("Main_St", this);
endfunction : build
task run () ;
uvm_component child, parent;
string pr, ch;
child = get_child("Main_St");
parent= get_parent();
//pr= parent.get_full_name();
pr = parent.get_name();
ch = child.get_name();
`uvm_do_callbacks(city,city_cbs,pre_info(this))
`uvm_info(get_type_name(),$psprintf("Parent:%s Child:%s",pr,ch),UVM_LOW);
endtask :run
endclass:city
virtual class city_cbs extends uvm_callback;
function new(string name="city_cb");
super.new(name);
endfunction
pure virtual function void pre_info(city c);
endclass : city_cbs
class state extends uvm_component;
city Capital_city;
`uvm_component_utils(state)
function new(string name, uvm_component parent);
super.new(name, parent);
endfunction : new
function void build();
super.build();
Capital_city=city::type_id::create("Capital_city", this);
endfunction : build
function void end_of_elaboration();
this.print();
endfunction : end_of_elaboration
endclass:state
class my_city_cb extends city_cbs;
function new(string name ="my_city_cb");
super.new(name);
endfunction
virtual function void pre_info(city c);
`uvm_info("my_city_cb",$psprintf("pre_info called for city %s",c.get_full_name()),UVM_LOW)
endfunction
endclass:my_city_cb
state Florida=state::type_id::create("Florida", null);
state New_York=state::type_id::create("New_York", null);
typedef uvm_callbacks#(city,city_cbs) city_cb;
my_city_cb cb = new;
// Start UVM Phases
initial begin
city_cb::add(null,cb);
run_test();
end
initial #100 global_stop_request();
endprogram: test
用irun -uvm test.sv运行得到的错误提示:
file: test.sv
`uvm_do_callbacks(city,city_cbs,pre_info(this))
|
ncvlog: *E,SVNOTY (test.sv,34|58): Syntactically this identifier appears to begin a datatype but it does not refer to a visible datatype in the current scope.
(`define macro: uvm_do_obj_callbacks [/opt1/eda_tools/cadence2011/tools/uvm/uvm_lib/uvm_sv/sv/macros/uvm_callback_defines.svh line 162], `define macro: uvm_do_callbacks [/opt1/eda_tools/cadence2011/tools/uvm/uvm_lib/uvm_sv/sv/macros/uvm_callback_defines.svh line 139], file: test.sv line 34)
UVM for analog ?