Jump to content

pass configuration object to sequence item

Recommended Posts

Hi ,

We (I believe many others ) have a case where sequence item's constraints depend on values in configuration object so wanted to use get_config_object or uvm_config_db in uvm_sequence_item,

but there is no way to do get_config_object or uvm_config_db...::get in sequence_item so how do we pass config object to sequence item in a clean fashion.

I know one rather not-clean (In my opinion) way is to always use `uvm_do_with in sequence body

myseq::body() {
`uvm_do_with(req,  { cfg == p_sequence.cfg; });

but this is not-so-clean due to two reasons

  • One always have to use `uvm_do_with , instead of `uvm_do, in my sequences.

  • If One is using `uvm_create and playing with req before sending, I need to assign config object on every create, before I play with the object.
Any thoughts ??
Link to comment
Share on other sites


btw: the code shown does NOT do what you think. in SV randomization and object allocation are separate (in contrast to specman/e). that means if you randomize an object such as when using uvm_do* sub objects are not automatically allocated by randomize. it is upto the user to allocate objects (as part of the constructor). now because allocation is user defined constraints on references/object handles itself are meaningless in SV. they can either be satisfied because the USER made the the references to be the same OR they make the randomization fail when the user doesnt handle the refs properly.

you may use some other methods to pass in handles:

1. implement pre_randomize() or post_randomize() in the sequence to assign cfg

2. implement pre_body(), pre_do() or similar to retrieve references

3. use the config_db to pass references around

4. use explicit code in the body sequencer=get_sequencer(); sequencer.cfg ....;

5. split uvm_do into uvm_create, assign variables, then use uvm_rsend|uvm_send (make cfg a non-rand!)




Link to comment
Share on other sites

3. use the config_db to pass references around

This is what I want to do, but not able to do in uvm_sequence_item because config_db or get_config_object() do not work in uvm_object.

my question is - is it difficult to allow config_db/get_config_object() calls in uvm_object? If so, why ?

Link to comment
Share on other sites

config_db works in objects:

my_type foo;
uvm_config_db#(my_type)::get([B][COLOR="Red"]null[/COLOR][/B], get_full_name(), "foo", foo);
Just make sure the object's get_full_name() return the correct path (for sequence items, it is already implemented for you, so you can use it strait away)
Link to comment
Share on other sites

  • 11 years later...

Hi dudi,

When I have implemented the below code in seq_item class, I am facing an error "Unrecognized declaration 'my_sequencer' could be an unsupported keyword, a spelling mistake or missing instance port list '()' [SystemVerilog].".

The code to get the integer value in sequence_item is as follows:

function void pre_randomize();
    my_sequencer seqr;
    seqr = get_sequencer();
    uvm_config_db#(int)::get(seqr, "", "k",a);
    $display("In seq item a=%d",a);


I have set the parameter "k" in top file and trying to get the value in seq_item.

The code that I have written in top file to set the integer k is as follows:

 uvm_config_db #(int)::set(uvm_root::get(),"*","k",k);

can you please help me with this error.



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.

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...