Use conditional compilation guards to avoid compiling the same include file more than once.
Create user-defined transaction classes by extending the class uvm_sequence_item.
Do not use field macros. (This comes at a heavy cost in terms of performance)
Use the rand qualifier in front of any class member variables that might need to be randomized, now or in the future.
After any member variables, define a constructor that includes a single string name argument with a default value of the empty string, a call to super.new, and is otherwise empty.
After the constructor, always override the convert2string, do_copy, do_compare, do_print, and do_record methods.
Always instantiate transaction objects using the factory.
`ifndefGPIO_UVC_DRIVER_SV`define GPIO_UVC_DRIVER_SVclassgpio_uvc_driverextendsuvm_driver#(gpio_uvc_sequence_item);`uvm_component_utils(gpio_uvc_driver)virtualgpio_uvc_ifvif;gpio_uvc_configm_config;externfunctionnew(stringname,uvm_componentparent);externfunctionvoidbuild_phase(uvm_phasephase);externtaskrun_phase(uvm_phasephase);externtaskdrive_sync();externtaskdrive_async();externtaskdo_drive();endclass:gpio_uvc_driverfunctiongpio_uvc_driver::new(stringname,uvm_componentparent);super.new(name,parent);endfunction:newfunctionvoidgpio_uvc_driver::build_phase(uvm_phasephase);if(!uvm_config_db#(virtualgpio_uvc_if)::get(get_parent(),"","vif",vif))begin`uvm_fatal(get_name(),"Could not retrieve gpio_uvc_if from config db")endif(!uvm_config_db#(gpio_uvc_config)::get(get_parent(),"","config",m_config))begin`uvm_fatal(get_name(),"Could not retrieve gpio_uvc_config from config db")endendfunction:build_phasetaskgpio_uvc_driver::run_phase(uvm_phasephase);foreverbeginseq_item_port.get_next_item(req);do_drive();seq_item_port.item_done();endendtask:run_phasetaskgpio_uvc_driver::drive_sync();@(vif.cb_drv);vif.cb_drv.gpio_pin<=req.gpio_pin;`uvm_info(get_type_name(),{"Sending item: ",req.convert2string()},UVM_MEDIUM)endtask:drive_synctaskgpio_uvc_driver::drive_async();vif.gpio_pin=req.gpio_pin;`uvm_info(get_type_name(),{"Sending item: ",req.convert2string()},UVM_MEDIUM)if(req.delay_enable==GPIO_UVC_ITEM_DELAY_ON)begin#(req.delay_duration_ps*1ps);endelsebegin@(vif.cb_drv);endendtask:drive_asynctaskgpio_uvc_driver::do_drive();if(req.trans_type==GPIO_UVC_ITEM_ASYNC)begindrive_async();endelsebegindrive_sync();endendtask:do_drive`endif// GPIO_UVC_DRIVER_SV