Jump to content

Recommended Posts

Posted

Hi All,

 

I have a scenario where i need to send n random bytes and out of n bytes i should able to corrupt few selected bytes.

I have used Queue for selecting error bytes list.

 

 

 

Transaction :

 

rand bit [7:0]  tx_data_byte[`MAX_DATA:0] ;  // data byte array

 

rand int unsigned tx_no_of_bytes_to_send  ; // number of data bytes to send

 

rand byte tx_err_bytes[$] ;           //queue contains byte positions to be corrupted

 

 

Example :

consider i am sending 5  data bytes and I have to corrupt  2,4,5 bytes (corrupting data bytes is handled in driver)

 

 

Sequence :

 

`uvm_do_with( req, {    tx_data_byte[0]=='h00;

                                     tx_data_byte[1]=='h11;
                                     tx_data_byte[2]=='h00;
                                     tx_data_byte[3]=='h99;
                                     tx_data_byte[4]=='h55;
                                     ///-----------------

                                     tx_no_of_bytes_to_send ==20;  

                                     tx_err_bytes == {4,5,7};

 

                           })

 

I am seeing below error from the cadence simulator.

Can somebody help me out in resolving this error .

 

 

Error:

Randomization constraint has error, which will cause the randomize function to return 0 and no new rand values will be set:

This feature is currently not supported for queues, dynamic arrays, strings and associative arrays.
 
 
Thank you
 

 

Posted

Hi Tudor,

 

Thanks for the reply.

Exactly, I would like to know what is the limitation of Queue usage in sequences.

With Dynamic Array I need to have additional parameter to configure the size and also assigning bytes is not straight forward

 

Following is the sample code with dyamaic array

 

rand byte tx_err_bytes[ ] ;  // Dynamic array contains byte positions to be corrupted

rand int error_byte_count ; // size of the dynamic array

 

`uvm_do_with( req, {    tx_data_byte[0]=='h00;

                                     tx_data_byte[1]=='h11;
                                     tx_data_byte[2]=='h00;
                                     tx_data_byte[3]=='h99;
                                     tx_data_byte[4]=='h55;
                                     ///-----------------

                                     tx_no_of_bytes_to_send ==20;  

                                     tx_err_bytes [0] == 4;

                                     tx_err_bytes [1] == 5;

                                     tx_err_bytes [2] == 7;

                                    error_byte_count == 3;

                           })

 

Thank you

Posted

This has nothing to do with sequences or anything else. The Cadence simulator doesn't support using queues inside constraints. You'll have to use dynamic arrays. You don't need an additional field for the array size as you can just use tx_err_bytes.size() == 3. You do have to pass in the size of the array which is annoying, but there's no way around it.

Posted

There certainly is a way around it.  Don't use `uvm_do_* and instead do

 

start_item(req);

req. tx_err_bytes.rand_mode(0);

req. tx_err_bytes = {4,5,7};

req.randomize() with   { tx_data_byte[0]=='h00;

                                     tx_data_byte[1]=='h11;
                                     tx_data_byte[2]=='h00;
                                     tx_data_byte[3]=='h99;
                                     tx_data_byte[4]=='h55;
                                     ///-----------------

                                     tx_no_of_bytes_to_send ==20;

}

finish_item(req);

Posted

You could also replace the uvm_do_with() call with:

 

`uvm_create(req) assert(req.randomize());

req.tx_data_byte[0]='h00;

req.tx_data_byte[1]='h11;

req.tx_data_byte[2]='h00;

req.tx_data_byte[3]='h99;

req.tx_data_byte[4]='h55;

req.tx_no_of_bytes_to_send =20;

req.tx_err_bytes = {4,5,7};

`uvm_send(req)

  • 4 weeks later...
Posted

Isn't this code from this thread just illegal according to LRM

 tx_err_bytes == {4,5,7};

unpacked array concatenation may be used only in assignment like context.

There is also rule saying that in constraint only integral variables can be used.

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