In this phase we will develop the driver. Driver is defined by extending ovm_driver. Driver takes the transaction from the sequencer using seq_item_port. This transaction will be driven to DUT as per the interface specification. After driving the transaction to DUT, it sends the transaction to scoreboard using ovm_analysis_port.
In driver class, we will also define task for resetting DUT and configuring the DUT. After completing the driver class implementation, we will instantiate it in environment class and connect the sequencer to it. We will also update the test case and run the simulation to check the implementation which we did till now.
1) Define the driver class by extending ovm_driver;
`ifndef GUARD_DRIVER
`define GUARD_DRIVER
class Driver extends ovm_driver #(Packet);
endclass : Driver
2) Create a handle to configuration object. Using this object we can get DUT interfaces and DUT port addresses.
ovm_report_info(get_full_name(),"End of cfg_dut() method ",OVM_LOW);
endtask : cfg_dut
11) Define drive() method which will be used to drive the packet to DUT. In this method pack the packet fields using the pack_bytes() method of the transaction and drive the packed data to DUT interface.
12) Now we will use the above 3 defined methods and update the run() method of ovm_driver.
First call the reset_dut() method and then cfg_dut(). After completing the configuration, in a forever loop get the transaction from seq_item_port and send it DUT using drive() method and also to scoreboard using Drvr2SB_port .
ovm_report_info(get_full_name(),"END of build ",OVM_LOW); endfunction function void connect(); super.connect(); ovm_report_info(get_full_name(),"START of connect ",OVM_LOW);
2) In the build() method itself, using set_config_object , configure the configuration object with the one which is in top module.
with this, the configuration object in Sequencer and Driver will be pointing to the one which in top module.
set_config_object("t_env.*","Configuration",cfg);
3) In the build method, using set_config_string, configure the default_sequence of the sequencer to use the sequence which we defined.