mrforever Posted May 14, 2013 Report Share Posted May 14, 2013 Hi all, How to pass the value to the variable of uvm_sequence object? 1. use uvm_config_db 2. assign directly When i use the first way, i found that maybe uvm_config_db::get() can only use in the uvm_component class. Then i use the second way, I cann't pass the value to the variable successfully. Does anybody know the reason? Thanks in advance. pieces of code of the first way: In top: uvm_config_db#(uvm_bitstream_t)::set(uvm_root::get(), "*", "my_cpu_id", HOST_NUM); In my_sub_sequence which extends from uvm_sequence: void'(uvm_config_db#(uvm_bitstream_t)::get(this, "", "my_cpu_id", my_cpu_id)); Result: VCS reports error. pieces of code of the second way: In v_sequence: for (int i = 0; i < host_num; i++) begin inst_name = $sformatf("sub_seq[%0d]", i); //sub_seq[i] = my_sub_sequence::type_id::create(inst_name,,get_full_name()); sub_seq[i] = new(inst_name); sub_seq[i].my_cpu_id = i; end In my_sub_sequence: int my_cpu_id; ... virtual task body(); ... $display("my_cpu_id = %0d", my_cpu_id); ... endtask Result: every my_cpu_id's value display 0, not 0, 1, 2, 3. Quote Link to comment Share on other sites More sharing options...
Logger Posted May 15, 2013 Report Share Posted May 15, 2013 It would be helpful if you actually post the error message. When doing a config_db::get from a sequence I use the following pattern: uvm_config_db#(TYPE)::get(null, this.get_full_name(), "field", field); Noteworthy about this. Sequences/sequence_items do not have hierarchy until they have been started on a sequencer. Once started, get_full_name() will return a hierarchy string for your sequence that includes either the parent sequence's hierarchy (if there is a parent sequence), or the hierarchy of the sequencer that the sequence was started on. chandan 1 Quote Link to comment Share on other sites More sharing options...
mrforever Posted May 16, 2013 Author Report Share Posted May 16, 2013 It would be helpful if you actually post the error message. When doing a config_db::get from a sequence I use the following pattern: uvm_config_db#(TYPE)::get(null, this.get_full_name(), "field", field); Noteworthy about this. Sequences/sequence_items do not have hierarchy until they have been started on a sequencer. Once started, get_full_name() will return a hierarchy string for your sequence that includes either the parent sequence's hierarchy (if there is a parent sequence), or the hierarchy of the sequencer that the sequence was started on. Hi logger, Thanks for your reply, I will have a try. Buy the way, usually the uvm_config_db#(TYPE)::get() should not be invoked earlier than uvm_config_db#(TYPE)::set(), where do you invoked uvm_config_db#(TYPE)::get()? In the pre_body(), body() or new(), etc. on sequence? Quote Link to comment Share on other sites More sharing options...
Logger Posted May 16, 2013 Report Share Posted May 16, 2013 My default method is to do get() calls in pre_start(). That always runs wether started as a sub-sequence or directly on a sequencer. In the unusual (for us) circumstance where that would be too early, I move the get() calls into the body(). I often have several sequences which all need to grab the same information out of the config_db, so I write a base class sequence that gets those fields in the pre_start() task. Quote Link to comment Share on other sites More sharing options...
mrforever Posted May 17, 2013 Author Report Share Posted May 17, 2013 My default method is to do get() calls in pre_start(). That always runs wether started as a sub-sequence or directly on a sequencer. In the unusual (for us) circumstance where that would be too early, I move the get() calls into the body(). I often have several sequences which all need to grab the same information out of the config_db, so I write a base class sequence that gets those fields in the pre_start() task. Hi Logger, thanks for your reply. Best regards Quote Link to comment Share on other sites More sharing options...
DavidLarson Posted May 17, 2013 Report Share Posted May 17, 2013 The uvm_config_db is used primarily to configure uvm_components. This is a snippet from the reference manual (italics are mine): The uvm_config_db class provides a convenience interface on top of the uvm_resource_db to simplify the basic interface that is used for configuring uvm_component instances. Regardless, I find that it is far better to set the variable directly. The real power of the resource DB is when the wildcard can be used in the path, but that doesn't apply to you in this case. Quote Link to comment Share on other sites More sharing options...
Logger Posted May 18, 2013 Report Share Posted May 18, 2013 The uvm_config_db is used primarily to configure uvm_components. This is a snippet from the reference manual (italics are mine): I've noticed, and it seems to be a major oversite in UVM in my opinion. I find using the config_db inside of sequence_items invaluable for getting static configuration information that affects randomization. Say you have a system like a HDD or an SSD, which can handle a variety of sector sizes, but it does not support multiple sectors sizes simultaneously. In this case, it is highly desirable that the sector_item know what the sector_size is for the current simulation. Now I suppose one solution would be to extend the sector class with a constraint that sets the sector_size, and then use a type_override to insert that into the testbench. Or, each of the components or tests that generate sector_items could push the value into the sector_items. However, if the sector_item did a config_db::get to for that value, then you just need a config_db::set. And you likely were doing that for some of the components in the environment anyway, and none of the components need to push this value in. So for my purposes the use model has worked very well. What I'm annoyed with is, that since uvm_objects don't have hierarchy, I can't apply it to those as well. However, I'm told that is changing in a future version of UVM. Quote Link to comment Share on other sites More sharing options...
DavidLarson Posted May 20, 2013 Report Share Posted May 20, 2013 Yes, I agree Logger. Since you have several items in your TB needing this setting then using the configuration DB is the way to go (vs. setting the items directly). BTW: Have you tried using uvm_resource_db instead? Quote Link to comment Share on other sites More sharing options...
Logger Posted May 21, 2013 Report Share Posted May 21, 2013 I really should try the resource_db again. I tried to use it once in the past, but I never quite figured it out. While trying to learn it, I couldn't help but think that the config_db interface seemed easier to use. I concluded that doing uvm_config_db#(Foo)::get(null, "Foo", "foo", foo) was equivalent to using the resource_db. And I don't have to remember two different use models. However, just to account for some unforeseen future use case, I use uvm_config_db#(Foo)::get(null, get_full_name(), "foo", foo) unless I know that that won't work, because it at least gives me some ability to do selective sets if necessary. Quote Link to comment Share on other sites More sharing options...
jadec Posted May 23, 2013 Report Share Posted May 23, 2013 uvm_config_db#()::get() is a rather expensive operation. You'll want to be careful about calling it frequently. For sequences, I generally recommend doing the get in the sequencer and just using "p_sequencer." to access it from your sequence. Mina Magdy 1 Quote Link to comment Share on other sites More sharing options...
DavidLarson Posted May 24, 2013 Report Share Posted May 24, 2013 Hi Jadec, I agree that the get function is expensive, but calling it from the sequencer (rather than the sequence) is just as expensive since it is called the same number of times either way. David Quote Link to comment Share on other sites More sharing options...
jadec Posted June 4, 2013 Report Share Posted June 4, 2013 I'd call it from the sequencer once and store the value to be retrieved whenever a sequence wants it. That does assume that you're setting some global parameter and not something that's applied to particular sequence instances. Quote Link to comment Share on other sites More sharing options...
DavidLarson Posted June 4, 2013 Report Share Posted June 4, 2013 Hi Jadec, Yes, that makes sense. Thanks, David 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.