Jump to content

Calling a print method through the message APIs


AWhooley

Recommended Posts

Hi,

Is it possible to control when the print method of an object is called through the message APIs e.g. 'uvm_info? For example I want to print out the contents of the transaction received by the driver but only when debugging my code. Thus I would like to be able to do the following:

`uvm_info("",$sformatf("Verbosity is %s", tx.print), UVM_DEBUG);

Obviously this does not work. I also tried accessing the enumerated type that UVM_DEBUG belongs to (uvm_verbosity) but it does not look like I can access it. It is possible I trued to access it incorrectly as I did not provide any hierarchical path to it or anything like that.

if (uvm_verbosity == UVM_DEBUG)

tx.print

Anyway what would be the best approach to achieve what I would like to achieve? Should I specify "UVM_NOPRINT" for all the properties in my transaction and then write a do_print function where I print the properties using uvm_info instead?

Thanks

Alan

Edited by tzar
Formatting
Link to comment
Share on other sites

uvm_report_enabled is method of uvm_report_object and so is available in uvm_component, but not in uvm_transaction or uvm_sequence_item

so in case where you want to print something based on verbosity, there seems to be no way, except you define a function that converts all your prints to a string and returns string...

For example, a sequence item has a payload (dynamic array) of size 1-1000 . Obviously, one would not want to print the whole array every time, but only when verbosity is UVM_DEBUG or UVM_FULL.

one way to do this is

foreach (payload[j]) begin
  `uvm_info(get_type_name(), $sformatf("payload[%d] = 0x%h",j, payload[j]),UVM_FULL)
end

but this would print uvm-message tag in every line and is ugly.. What one would want to do is something like, what we can do for uvm_component .i.e.

from within do_print method of transaction.....
if (uvm_report_enabled(UVM_FULL)) begin
   foreach (data[i]) begin
     printer.print_int($sformatf("data[%d]",i),data[i],$bits(data[i]),UVM_HEX);
   end
end

How can that be done ?

I hope, this is what original user wanted to ask.

Link to comment
Share on other sites

hi,

all messaging is done through the context. this is either the component you are in OR via the global context which routes the msg to uvm_root. this means you simply have to pick a component and use uvm_report_enabled(). for a sequence you can use the get_sequencer() for a transaction you could choose anything applicable.if you dont know your real context you may use uvm_root.

/uwe

Link to comment
Share on other sites

Thanks..

Two questions here:

1) How do I know the context for a uvm_transaction that is flowing through multiple components.(note I do not want to use components uvm_report_enabled() function for a reason.

2) Curious to know, what type of problems could be created if uvm_transaction is extended of uvm_report_object instead of uvm_object in uvm ?

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.

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