`ifndef CALC_DRIVER_SV
`define CALC_DRIVER_SV
class calc_driver extends uvm_driver#(calc_seq_item);

   `uvm_component_utils(calc_driver)
   virtual interface calc_if vif;
   function new(string name = "calc_driver", uvm_component parent = null);
      super.new(name,parent);
   endfunction // new
   
   function void build_phase(uvm_phase phase);
      if (!uvm_config_db#(virtual calc_if)::get(null, "*", "calc_if", vif))
        `uvm_fatal("NOVIF",{"virtual interface must be set:",get_full_name(),".vif"})
      
   endfunction // build_phase
   
   task main_phase(uvm_phase phase);
      forever begin
	 @(posedge vif.clk);	 
	 if (!vif.rst)
	   begin
              seq_item_port.get_next_item(req);
	      
              `uvm_info(get_type_name(),
			$sformatf("Driver sending...\n%s", req.sprint()),
			UVM_HIGH)
	      vif.req1_data_in = req.operand1;
	      vif.req1_cmd_in = req.cmd;	      
	      @(posedge vif.clk);
	      vif.req1_data_in = req.operand2;
	      vif.req1_cmd_in = 0;	      
	      
              seq_item_port.item_done();
	   end
      end
   endtask : main_phase

endclass : calc_driver

`endif

