• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Functional Verification
  3. How to assign values to an item without randomization (without...

Stats

  • Locked Locked
  • Replies 1
  • Subscribers 66
  • Views 7535
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to assign values to an item without randomization (without constraint)?

Ketrin
Ketrin over 2 years ago

Hi all!
I wrote some code for uvm_item and uvm_sequence. It generates 5 random items using "constraint", but then I need to create the last item with defined values of item_incode variables (for example in_code = 21'b111101001100001100010 and  in_data =  16'b0000000000000101). Could you please advise how am I supposed to do that?

class item_incode extends uvm_sequence_item;
`uvm_object_utils(item_incode)
rand bit [20 : 0] in_code;
rand bit signed [15 : 0] in_data;
..... 

constraint c_incode {
0 <= in_code [20 -: 3]; 3 >= in_code [20 -: 3];
0 <= in_code [17 -: 6]; 64 > in_code [17 -: 6];
0 <= in_code [11 -: 6]; 64 > in_code [11 -: 6];
0 <= in_code [5 -: 6]; 64 > in_code [5 -:6];
}
constraint c_indata {in_data inside {[-32767:32767]};}

endclass

class seq0 extends uvm_sequence # (item_incode);

`uvm_object_utils (seq0)
.......
virtual task body();
repeat (5) begin
incode.code_or_dat = 0;
item_incode incode = item_incode::type_id::create("incode");
start_item (incode);
assert(incode.randomize());
`uvm_info("SEQ", $sformatf("Generate new item: %s", incode.convert2str()), UVM_HIGH)
finish_item(incode);
end

endtask

endclass

  • Cancel
  • tpylant
    tpylant over 2 years ago

    You can provide an inline constraint to set to a specific value.

    assert(incode.randomize() with {in_code == 21'b111101001100001100010;});

    Tim

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information