In reply to sharvil111:
if (size())
set_if(0); // used to set default index of implementation port
Here , index 0 is used to set default implementation port (UVM_IMPLEMENTATION) to your UVM_PORT.
On observing, the 0th element of m_imp_list array depends on which component comes first in alphabetical order. In other words, the put task of that component is invoked which comes first in alphabetical order in this array. This sounds unrealistic. So, what is the aim of having max_size argument when one can call only single imp task? Am I interpreting the max_size in a wrong manner?
m_imp_list[string] is associative array and for 0 th element will give lowest ASCII value of index string (i.e. eventually it can be interpreted as alphabetical).
You have used put → put_imp which is one to one connection, Though you can connect multiple imp port to single put port based on max_size , but at time you can supply packets to only single imp port.
Suppose , you have single Initiator and multiple Target (lets say 5 Target) , but the constraint is Initiator must communicate only one Target (which can be any) at time. By default it is communicating 0th Target (i.e Target[0]) based on set_if(0) task. If in certain cases Initiator needs to communicate Target[1] , then it will first set index of Target[1] through set_if(1) before invoking Initiator.put() task.
Here is EDA Playground Link Code.
Thus, max_size puts restriction to user not to connect additional IMP/EXP port to UVM_PORT.