Jump to content

Configuring a uvm_reg_sequence sequence


Recommended Posts

Hello,

I am trying pass configuration info to to a uvm_reg_sequence inititalization sequence through the config_db, but cannot make it work.

My uvm_reg_sequence is as follows:

class reg_init_seq extends uvm_reg_sequence;

    reg_blk_cfg    reg_blk_cfg_h;
    string         scope_name;
     reg_mmap_t    regmodel;

    `uvm_object_utils(reg_init_seq)   

    function new(string name = "reg_init_seq");
       super.new(name);
    endfunction: new

    virtual task body();   

    if (scope_name == "") begin
        scope_name = get_full_name(); // this is {sequencer.get_full_name(), get_name()}
    end  

    if ( uvm_config_db#(reg_blk_cfg)::get(null, scope_name, "reg_blk_cfg", reg_blk_cfg_h) )
      $display("Found Config object");
    else  
      $display("Did not find  Config object");
   endtask
endclass : reg_init_seq

and my uvm_test code is

class cfg_test  extends uvm_test;

   `uvm_component_utils(cfg_test )

    top_env  env;

    reg_blk_cfg        reg_blk_cfg_h;
	
    function new(string name = "cfg_test", uvm_component parent=null);
       super.new(name,parent);
       reg_blk_cfg_h = new();
    endfunction // new
	
   function void build_phase(uvm_phase phase);

      reg_blk_cfg_h.sync_mode         = EXT;
       
      if (env == null) $cast(env, uvm_top.find("env"));

      uvm_config_db#(reg_blk_cfg)::set(this, "*reg_init_seq*", "reg_blk_cfg", reg_blk_cfg_h); 

   endfunction : build_phase // automatic

   task run_phase(uvm_phase phase);
       reg_init_seq        reg_seq; 

       phase.raise_objection(this);

       reg_seq =  reg_init_seq::type_id::create("reg_init_seq",this);
       reg_seq.regmodel = env.regmodel;
       reg_seq.start(null);

       phase.drop_objection(this);
    endtask : run_phase 
endclass : tim_cfg_test

When I run the sim, it results in the "Did not find Config object" message.

I am still struggling with the UVM configuration mechanism's and would love some help.

Thanks,

Wavy

Link to comment
Share on other sites

A little more info... I turned on the Config DB tracing. Here is the results of the set and get

UVM_INFO @ 0: reporter [CFGDB/SET] Configuration 'uvm_test_top.*reg_init_seq*.reg_blk_cfg' (type reg_blk_cfg) set by uvm_test_top = (reg_blk_cfg)

UVM_INFO @ 230000000: reporter [CFGDB/GET] Configuration 'reg_init_seq.reg_blk_cfg' (type reg_blk_cfg) read by = null (failed lookup)

I am guessing it fails due to the uvm_test_top hierarchy, but don't see how to get around this problem.

Thanks again for the help.

Edited by wavy
Link to comment
Share on other sites

After a good nights sleep, the solution to my problem became obvious. I just changed the cntxt argument of the set call from this to null:

uvm_config_db#(reg_blk_cfg)::set(null, "*reg_init_seq*", "reg_blk_cfg", reg_blk_cfg_h);

which removed uvm_test_top from the path and allowed to set call to find reg_blk_cfg

Link to comment
Share on other sites

Hi There,

You use the "null" in the first argument because your code is a top layer module not a component.

Regarding the uvm_config_db, the cntxt and inst_name together from a scope which is used to locate the resource within the database.

If the cntxt is null then inst_name(the "*reg_init_seq*" in your codes)will provide the complete scope information of the setting.

In the last issue code, you use the "this" as the first argument, then you could be sure that you have only configured this env's agent and not any other agents in the component hierarchy.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...