package my_testbench_pkg;
import uvm_pkg::*;
// The UVM sequence, transaction item, and driver are in these files:
`include "my_sequence.svh"
`include "my_driver.svh"
// The agent contains sequencer, driver, and monitor (not included)
class my_agent extends uvm_agent;
`uvm_component_utils(my_agent)
my_driver driver;
uvm_sequencer#(my_transaction) sequencer;
function new(string name, uvm_component parent);
super.new(name, parent);
endfunction
virtual function void build_phase(uvm_phase phase);
super.build_phase(phase ); //<---------------------------I add this for test.
driver = my_driver ::type_id::create("driver", this);
sequencer =
uvm_sequencer#(my_transaction)::type_id::create("sequencer", this);
endfunction
I’ve got the below error messages as the below, when I add “super.build_phase(phase );”
I just follow test1 example code.
ncvlog: E,NOTCLM (my_testbench_pkg.svh,20|22): build_phase is not a class item.
(`include file: my_testbench_pkg.svh line 84, file: testbench.sv line 9)
import my_testbench_pkg::;
I can’t understand why does error happen? I can’t understand this problem.
My guess is you have confused super.build_phase with super.bui1d_phase. Also I see you have written “virtuaf” instead of “virtual” (Although that could be an issue on my end only).
I have corrected (most of) your code so you may wanna reconsider:
class example_agent extends uvm_agent;
example_sequencer #(example_transaction) m_sequencer ;
example_driver m_driver ;
example_monitor m_monitor ;
uvm_analysis_port # (example_transaction) monitor_ap ;
virtual dut_if v_dut_if;
virtual function void build_phase (uvm_phase phase) ;
super.build_phase(phase ) ;
m_monitor = example_monitor::type_id::create("m_monitor", this);
monitor_ap = new("monitor_ap", this) ;
if ( get_is_active() == UVM_ACTIVE ) begin
m_sequencer = example_sequencer::type_id::create("m_sequencer", this);
m_driver = example_driver::type_id::create("m_driver", this);
end
endfunction : build_phase
virtual function void connect_phase (uvm_phase phase);
m_monítor.monitor_ap.connect(monitor_ap ) ;
if ( get_is_active() == UVM_ACTTVE ) begin
m_drÍver.seq_item_port.connect(m_sequencer.seq_item_export) ;
end
endfunction : connect_phase
endclass
By calling super.build_phase(phase) you are actually calling the build phase of the parent class from which your class has been extended (in this case, the parent class would be uvm_agent) and hence you are calling the build_phase of uvm_agent file (that is stored somewhere in a file as a part of the uvm methodology source file package)
package my_testbench_pkg;
import uvm_pkg::*;
// The UVM sequence, transaction item, and driver are in these files:
`include "my_sequence.svh"
`include "my_driver.svh"
// The agent contains sequencer, driver, and monitor (not included)
class my_agent extends uvm_agent;
`uvm_component_utils(my_agent)
my_driver driver;
uvm_sequencer#(my_transaction) sequencer;
function new(string name, uvm_component parent);
super.new(name, parent);
endfunction
virtual function void build_phase(uvm_phase phase);
super.build_phase(phase );
driver = my_driver ::type_id::create("driver", this);
sequencer =
uvm_sequencer#(my_transaction)::type_id::create("sequencer", this);
endfunction
endclass
The super keyword basically refers to the parent class. (Read more on Class Hierarchy, if unaware). Somewhere in the UVM file directory there is a file uvm_agent, which has a function build_phase too; and so when you include this line in your code
super.build_phase(phase);
You are basically calling that function inside uvm_agent class.
Why only uvm_agent? Because in your example, the class example_agent extends from uvm_agent.
Correct the typo bui1d_phase and then check for errors.
In reply to UVM_LOVE:
The super keyword basically refers to the parent class. (Read more on Class Hierarchy, if unaware). Somewhere in the UVM file directory there is a file uvm_agent, which has a function build_phase too; and so when you include this line in your code
super.build_phase(phase);
You are basically calling that function inside uvm_agent class.
Why only uvm_agent? Because in your example, the class example_agent extends from uvm_agent.
Correct the typo bui1d_phase and then check for errors.
Also you must have an ‘endclass’ at the end
Thanks for letting me know that. I agree that the super keyword basically refers to the parent class.
So If I use “super.build_phase(phase);” means that I will use the parent class’s item(in this case, it will be “uvm_agent” class, and we assume that build_phase method will be there in uvm_agent class, am I right? )
ncvlog: *E,NOTCLM (my_testbench_pkg.svh,20|22): build_phase is not a class item.
But I didn’t get it exactly what build_phase is not a class item. doesn’t it make sense?
ans also what if the build_phase is not a class item, then what is it?
build_phase is a class method of the class uvm_agent in your case, but it is not a data member of uvm_agent. In general it is the build_phase of one of the bas classes contained in the UVM library.
In your code example there might be something wrong, like a missing semicolon, because your error message is pointing to the wrong place.
You have a typo somewhere and unless you can post the exact code you are running, we can’t help you. The task build_phase is in your uvm_component base class if everything was enter correctly.
There no need to call super.build_phase() unless you are using the UVM field macros, which we recommend strongly against because of the performance penalties.
In reply to UVM_LOVE:
You have a typo somewhere and unless you can post the exact code you are running, we can’t help you. The task build_phase is in your uvm_component base class if everything was enter correctly.
There no need to call super.build_phase() unless you are using the UVM field macros, which we recommend strongly against because of the performance penalties.
Also, please see this comment about parent/child terminology. This is especially pertinent when talking about uvm_component.
Thanks for replying that. I found a fault point as your recommends.
Would you please let me know the list what you strongly recommends like thjs case?
In reply to UVM_LOVE:
You have a typo somewhere and unless you can post the exact code you are running, we can’t help you. The task build_phase is in your uvm_component base class if everything was enter correctly.
There no need to call super.build_phase() unless you are using the UVM field macros, which we recommend strongly against because of the performance penalties.
Also, please see this comment about parent/child terminology. This is especially pertinent when talking about uvm_component.
Hi Dave,
Could you please elaborate on why the super.build_phase() is not needed?
Hi Dave,
Could you please elaborate on why the super.build_phase() is not needed?
Thanks,
-R
Because is does nothing for you other than waste CPU time. If you used the UVM field macros, then you must call super.build() and you will waste a lot of CPU time.