In OVM, agents usually contain driver, monitor and sequencer.
Example
class my_agent extends ovm_agent;
`ovm_component_utils(my_agent) // register for type_id
my_sequencer my_sequencer_h;
my_driver my_driver_h;
function new(string name, ovm_component parent);
super.new(name, parent);
endfunction: new
//------------------------------------------------------------
// Using Factory methods allows them to be overridden in tests
// to change behavior without modifying the source code
// Build create the instances of the sequencer and driver
// Connect picks up the handle of ports of children and connect
// them
//------------------------------------------------------------
function void build;
super.build();
my_sequencer_h =
my_sequencer::type_id::create("my_sequencer_h", this);
// instance name, parent
my_driver_h =
my_driver::type_id::create ("my_driver_h" , this);
endfunction: build
// Lower level connection in another function is good practice
// seq_item_port is the handler of the ports
function void connect;
my_driver_h.seq_item_port.connect(
my_sequencer_h.seq_item_export );
endfunction: connect
endclass : my_agent
Standard Phases in Component Class
// OVM component is the base class for many other classes
// my_component can be my_driver, my_monitor, my_agent and so on
// use standard phases to coordinate test activities of multiple
// components and make them re-usable
class my_component extends ovm_component;
`ovm_component_utils(my_component) // standard factory registration
virtual dut_if dut_if_h; // External interfaces
// Internal component handles
my_sequencer my_sequencer_h;
my_driver my_driver_h;
// phase 0, constructor new method
function new(string name, ovm_component parent);
super.new(name, parent);
endfunction: new
// phase 1
// Build from top-down
function void build;
super.build();
endfunction : build
// Connect from bottom-up
// Connect child components
function void connect;
endfunction : connect
// phase to run simulation, callback, open simulation files
function void start_simulation;
endfunction : start_simulation
// Only task can execute event controlled statements
// with time signatures
task run;
endtask : run
function check;
endfunction : check
function report;
endfunction : report
endclass : my_component
No comments:
Post a Comment