Calling randomize of config object

In reply to sunils:

  1. My current code in env build_phase is something like this -
    for (int i=0; i<num_tx_lanes; i++) begin
      $sformat(instance_name, "tx_lane_agents[%0d]", i);
      // instantiate tx agent
      tx_lane_agents[i] = er_j204_lane_agent::type_id::create(instance_name, this);
      $sformat(instance_name, "TX_lane_config_%0d", i);
      // instantiate tx agent's config
      tx_lane_agents[i].cfg = er_j204_lane_config::type_id::create(instance_name, this);
      tx_lane_agents[i].cfg.lane_id = i;
      tx_lane_agents[i].cfg.lane_type = TX;
    end

Is it better to have list of configs instantiated in the env and then agent is passed the pointer of the config in env’s build phase, something like

  tx_lane_agent[i] = cfg_l[i];

  1. The config contains active_passive fields and many other parameters. active_passive won’t be generated until randomization of cfg will happen. If I wait till start of simulation phase then how will I instantiate driver and monitor in the agent? active_passive information is required to instantiate driver and sequencer.

thanks
shrawan