`ifndef CALC_ENV_SV
 `define CALC_ENV_SV

class calc_env extends uvm_env;

   calc_agent agent;
   calc_config cfg;
   calc_scoreboard scbd;
   virtual interface calc_if vif;
   `uvm_component_utils (calc_env)

   function new(string name = "calc_env", uvm_component parent = null);
      super.new(name,parent);
   endfunction

   function void build_phase(uvm_phase phase);
      super.build_phase(phase);
      /************Geting from configuration database*******************/
      if (!uvm_config_db#(virtual calc_if)::get(this, "", "calc_if", vif))
        `uvm_fatal("NOVIF",{"virtual interface must be set:",get_full_name(),".vif"})
      
      if(!uvm_config_db#(calc_config)::get(this, "", "calc_config", cfg))
        `uvm_fatal("NOCONFIG",{"Config object must be set for: ",get_full_name(),".cfg"})
      /*****************************************************************/


      /************Setting to configuration database********************/
      uvm_config_db#(calc_config)::set(this, "agent", "calc_config", cfg);
      uvm_config_db#(virtual calc_if)::set(this, "agent", "calc_if", vif);

      // propagate the checks/coverage knobs to the analysis components
      uvm_config_db#(int)::set(this, "agent.mon", "checks_enable",   cfg.checks_enable);
      uvm_config_db#(int)::set(this, "agent.mon", "coverage_enable", cfg.coverage_enable);
      uvm_config_db#(int)::set(this, "scbd",      "checks_enable",   cfg.checks_enable);
      uvm_config_db#(int)::set(this, "scbd",      "coverage_enable", cfg.coverage_enable);
      /*****************************************************************/
      agent = calc_agent::type_id::create("agent", this);
      scbd = calc_scoreboard::type_id::create("scbd", this);
   endfunction : build_phase

   function void connect_phase(uvm_phase phase);
      super.connect_phase(phase);
      agent.mon.item_collected_port.connect(scbd.item_collected_imp);
   endfunction
endclass : calc_env

`endif
