Use a class to build packet generator. Make an instance of this class. Packet generator generator generates packets and sends to driver using gen2drv channel. gen2drv is used to connect the packet generator and driver. Packet generator generates the packet and randomizes the packet. Then the packet is put into gen2drv channel. Always check whether the randomization is sucessful and display a message.
CODE: gen.sv class generator extends avm_verification_component;
// define tml interface for communication
tlm_blocking_put_if#(packet) put_port;