mwhite_cp

UVM print with array objects

8 posts in this topic

Hello,

When I print topology or transactions with arrays, it prints the 1st 5 and the last 5 array elements if the array is big. This is good most of the time. Once in a while, I would like to see the whole array elements. Is there a way to control the size of arrays to be displayed?

Thank you!

Share this post


Link to post
Share on other sites

Hello, You are able to control the size of the arrays printed via the table printer by using the printer knobs.

For example,

uvm_table_printer printer;

printer = new();

printer.knobs.begin_elements = -1; // this indicates to print all

Optionally you can specify numbers for begin/end

printer.knobs.begin_elements = 10;

printer.knobs.end_elements = 2;

Then when you print - you use the print(printer) command.

I hope this helps.

Kathleen

Share this post


Link to post
Share on other sites

Hi Kathleen,

Thank you for your response. I suppose I should apply the code in the class where print function is getting used? What is the easiest way to apply this to all in the environment?

Thank you!

Share this post


Link to post
Share on other sites

Hi,

I think you can do this in your test class or your testbench class or the top module.

I tried a simple example in a top module but I'm pretty sure it will work in the test or env:

initial begin

uvm_default_printer = uvm_default_table_printer;

uvm_default_printer.knobs.begin_elements=-1;

...

packet.print();

end

This seemed to work fine. Let me know if it does not work for you and I can create a simple example using a test class (or a env).

Kathleen

Share this post


Link to post
Share on other sites

OK - I tried it in my base test.

function void start_of_simulation_phase(uvm_phase phase);

super.start_of_simulation_phase(phase);

// Setting default printer info

uvm_default_printer = uvm_default_table_printer;

uvm_default_printer.knobs.begin_elements=-1;

...

In this case - when I printed a packet anywhere in the design it printed everything.

Kathleen

Share this post


Link to post
Share on other sites

This will always work in a .log file or a directed file (based on a knob value) -- but it doesn't work when viewing transactions in the waveform windows. I also do not know if this works in the stripe chart window. I think we can't change the behavior in the GUI windows, but it will ALWAYS be displayed fully in the .log or other files. To redirect to other than the default simulator output file, you need to change .knobs.mcd to change the file pointer:

mcd

int mcd = UVM_STDOUT

This is a file descriptor, or multi-channel descriptor, that specifies where the print output should be directed.

By default, the output goes to the standard output of the simulator.

I think currently, you can't change the transactions in the GUI windows (waveforms and Transaction strip chart) -- it will always default to 5 first and the 5 last. I'll try it and report back

Share this post


Link to post
Share on other sites

another approach may look like this:

function void do_print(uvm_printer printer);

    foreach( array ) begin

       printer.print_object("entry", array);

       if( i == NUMBER_OF_ENTRIES_TO_PRINT)  break;

    end

endfunction

Share this post


Link to post
Share on other sites
On 12/21/2012 at 7:23 AM, lisakb1963 said:

I think currently, you can't change the transactions in the GUI windows (waveforms and Transaction strip chart) -- it will always default to 5 first and the 5 last. I'll try it and report back

 

You can do something like as shown below. It works fine in Simvision waveform browser.

For example, if you have packet class extended from uvm_sequence_item in which you declared a data item rand bit [9:0] payload[];
and then for this data item, you shall have a field automation macro with the following trick 

`uvm_field_array_int(payload, UVM_ALL_ON | UVM_NORECORD)
// UVM_NORECORD will exclude the field in vendor-specific transaction recording.

You need to define a function as shown below inside this class

virtual function void do_record( uvm_recorder recorder );
    super.do_record( recorder );
    foreach (payload)
      recorder.record_field($sformatf("payload[%d]",i),payload,10,UVM_NORADIX);
  endfunction: do_record
 

You will be able to see a transaction in which payload will have all of its elements.

Hope this will help!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now