mea1201 Posted August 8, 2012 Report Share Posted August 8, 2012 I have an abstract agent that I wish to base other more concrete agents from, in order to use factory overriding within my configurable env. This abstract agent is defined to contain other components and objects such as the sequencer, subscriber, and configuration, and these are also all abstract classes. In addition, the abstract agent defines some boilerplate that uses the factory create to construct in the build phase, and connect in the connect phase. All pretty standard conventions that I wish to capture in the base classes. The thing I am uncertain about is that, if the env overrides the agent, would the subcomponents referenced in the abstract agent remain typed as the abstract classes? Do I need to add factory instance overrides to the concrete agent's build in order to ensure the subcomponents are concrete wherever they are referenced? What if the abstract classes are parameterized? Here is an abstract agent: virtual class abstract_agent#(T) extends uvm_agent; `uvm_component_param_utils(abstract_agent#(T)) uvm_analysis_port#(T) ap; abstract_config cfg; // assume this class defines is_active attribute abstract_subscriber#(T) sub; // assume this class also defines an analysis port ap abstract_sequencer#(T) seqr; function new(string name="abstract_agent", uvm_component parent=null); super.new(); endfunction : new function void build_phase(uvm_phase phase); super.build_phase(phase); uvm_config_db#(abstract_config)::get(this, "", "cfg", cfg); if(cfg.is_active == UVM_ACTIVE) seqr = abstract_sequencer#(T)::type_id::create("seqr", this); sub = abstract_subscriber#(T)::type_id::create("sub", this); ap = new("ap", this); endfunction : build_phase function void connect_phase(uvm_phase phase); super.connect_phase(phase); sub.ap.connect(ap); endfunction : connect_phase endclass : abstract_agent And, here is how I would like to define a typical concrete agent: class concrete_agent extends abstract_agent#(concrete_seq_item); `uvm_component_utils(concrete_agent) // use ap defined, built, and connected in abstract_agent concrete_config cfg; concrete_subscriber#(concrete_seq_item) sub; concrete_sequencer#(concrete_seq_item) seqr; function new(string name="concrete_agent", uvm_component parent=null); super.new(); endfunction : new function void build_phase(uvm_phase phase); super.build_phase(phase); // delegate build process to abstract_agent endfunction : build_phase function void connect_phase(uvm_phase phase); super.connect_phase(phase); // delegate connect process to abstract_agent endfunction : connect_phase endclass : concrete_agent Any ideas on a clean way to handle this situation? Thanks in advance! Quote Link to comment Share on other sites More sharing options...
dave_59 Posted August 10, 2012 Report Share Posted August 10, 2012 You should not be adding the component handles sub,seqr or the config handle cfg in the concrete_agent. They never get constructed. The concrete_class can provide factory overrides in its build_phase before calling super.build(). If the concrete_agent needs to provide additional components, like another subscriber, then you would add its handle and have it constructed in the concrete_agent's build_phase(). The abstract_agent should construct "base" concrete components, assuming that makes sense for your environment. Then the concrete_agent only needs to provide the necessary overrides that are different from the default, instead of requiring the concrete_agent to override everything. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.