|HOME |ABOUT |ARTICLES |ACK |FEEDBACK |TOC |LINKS |BLOG |JOBS |


Tutorials



VMM LOG




The vmm_log class provides an interface to the VMM message service so that all messages, regardless of their sources, can have a common "look and feel". Not always we require all type of messages. During normal simulation, we need only note, error and warning messages. While you are debugging, you may need debug messages and trace messages. vmm_log allows you to control the messages. This helps in debugging. vmm_log has a uniform message format which helps for post processing the log file using scripts if needed. You can also convert a error message to warning message which is required in some specific testcases. The message service describes and controls messages based on several concepts:

Message source:
A message source can be any component of a TestBench. They can be Transactors, scoreboards, assertions, environment or a testcase.

Message filters:
Filters can prevent or allow a message from being issued. They can be promoted or demoted based on the identifier, type, severity or content.



Vmm Message Type



Individual messages are categorized into different types.

FAILURE_TYP : For reporting error messages.
NOTE_TYP : Normal message used to indicate the simulation progress.
DEBUG_TYP : Message useful for debugging purpose.
TIMING_TYP : For reporting timing errors.
XHANDLING_TYP: For reporting X or Z on signals
INTERNAL_TYP : Messages from the VMM base classes.
REPORT_TYP,PROTOCOL_TYP,TRANSACTION_TYP,COMMAND_TYP,CYCLE_TYP :
Additional message types that can be used by transactors.




Message Severity



Individual messages are categorized into different severities

FATAL_SEV : An error which causes a program to abort.
ERROR_SEV : Simulation aborts after a certain number of errors are observed.
WARNING_SEV: Simulation can proceed and still produce useful result.
NORMAL_SEV : This message indicates the state of simulation.
TRACE_SEV : This message identifies high-level internal information that is not normally issued.
DEBUG_SEV : This message identifies medium-level internal information that is not normally issued.
VERBOSE_SEV: This message identifies low-level internal information that is not normally issued.



Vmm Log Macros



We can use the following predefined macros to select the message severity.


`vmm_fatal(vmm_log log, string msg);
`vmm_error(vmm_log log, string msg);
`vmm_warning(vmm_log log, string msg);
`vmm_note(vmm_log log, string msg);
`vmm_trace(vmm_log log, string msg);
`vmm_debug(vmm_log log, string msg);
`vmm_verbose(vmm_log log, string msg);


The second argument in the above macro can accept only a string. So if we want to pass a complex message, then convert it to string using a $psprintf() system task.

These macros are simple to use and the macro expansion is easy to understand. Following is a expansion of `vmm_not macro. Other macros also have same logic with different Message severity levels.


`define vmm_note ( log, msg )

do
if (log.start_msg(vmm_log::NOTE_TYP)) begin
void'(log.text(msg));
log.end_msg();
end
while (0)



To change the severity and verbosity of the messages services at simulation time , use +vmm_log_default=SEVERITY TYPE. Where SEVERITY TYPE can be ERROR, WARNING, NORMAL, TRACE, DEBUG OR VERBOSE. We will see the demo of this service in the example.



Message Handling



Different messages require different action by the simulator once the message has been issued.

ABORT_SIM : Aborts the simulation.
COUNT_ERROR: Count the message as an error.
STOP_PROMPT: Stop the simulation immediately and return to the simulation runtime-control command prompt.
DEBUGGER : Stop the simulation immediately and start the graphical debugging environment.
DUMP_STACK : Dump the call stack or any other context status information and continue the simulation.
CONTINUE : Continue the simulation normally.



To use this vmm feature, take the instance of vmm_log and use the message macros. For most of the vmm classes like vmm_env,vmm_xactor,vmm_data etc, this instantiation is already done internally, so user dont need to take a separate instance of vmm_log.



vmm_log log = new("test_log","log");



Following is a simple program which demonstrates the usages of different severity levels.
This program creates the object of a vmm_log class and uses log macros to define various messages. You can also see the usage of $psprintf() system task.



program test_log();

vmm_log log = new("test_log","log");

initial begin
`vmm_error(log,"This is a ERROR Message");
`vmm_warning(log,"This is a WARNING Message");
`vmm_note(log,$psprintf("This is a NOTE Message at time %d",$time));
`vmm_trace(log,"This is a TRACE Message");
`vmm_debug(log,"This is a DEBUG Message");
`vmm_verbose(log,"This is a VERBOSE Message");
`vmm_fatal(log,"This is a FATAL Message");
end

endprogram

(S) Download the source code


vmm_log.tar
Browse the code in vmm_log.tar


(S) Simulation commands
vcs -sverilog -f filelist -R -ntb_opts rvm -ntb_opts dtm



You can see the following messages on the terminal. You can only see Normal, Error, warning and fatal messages.


(S) Log file report:

!ERROR![FAILURE] on test_log(log) at 0:
This is a ERROR Message
WARNING[FAILURE] on test_log(log) at 0:
This is a WARNING Message
Normal[NOTE] on test_log(log) at 0:
This is a NOTE Message at time 0
*FATAL*[FAILURE] on test_log(log) at 0:
This is a FATAL Message



Run the simulation with command option +vmm_log_default=DEBUG
You can see the following messages on the terminal. You can see that Debug and trace message is also coming.


(S) Log file report:

!ERROR![FAILURE] on test_log(log) at 0:
This is a ERROR Message
WARNING[FAILURE] on test_log(log) at 0:
This is a WARNING Message
Normal[NOTE] on test_log(log) at 0:
This is a NOTE Message at time 0
Trace[DEBUG] on test_log(log) at 0:
This is a TRACE Message
Debug[DEBUG] on test_log(log) at 0:
This is a DEBUG Message
*FATAL*[FAILURE] on test_log(log) at 0:
This is a FATAL Message



Run the simulation with command option +vmm_log_default=VERBOSE
You can see the following messages on the terminal. You can see that Trace, Debug and Verbose messages are also coming.


(S) Log file report:

!ERROR![FAILURE] on test_log(log) at 0:
This is a ERROR Message
WARNING[FAILURE] on test_log(log) at 0:
This is a WARNING Message
Normal[NOTE] on test_log(log) at 0:
This is a NOTE Message at time 0
Trace[DEBUG] on test_log(log) at 0:
This is a TRACE Message
Debug[DEBUG] on test_log(log) at 0:
This is a DEBUG Message
Verbose[DEBUG] on test_log(log) at 0:
This is a VERBOSE Message
*FATAL*[FAILURE] on test_log(log) at 0:
This is a FATAL Message



Counting Number Of Messages Based Of Message Severity



Some time we need to count the number of messages executed based of the severity type. vmm_log has get_message_count() function which returns the message count based on severity type, source and message string.

user dont need to implement a logic to print the state of test i.e TEST PASSED or TEST FAILED, vmm_env has already implemented this in the report() method. We will see this in next topic.


virtual function int get_message_count(int severity = ALL_SEVS,
string name = "",
string instance = "",
bit recurse = 0);




Following is a example which demonstrations the get_message_count() function. The following example , also demonstrates the use of $psprintf which will be use full to print message when there are variable arguments to print.


program test_log();

vmm_log log = new("test_log","log");
int fatal_cnt ;
int error_cnt ;
int warn_cnt ;

initial begin
`vmm_note(log,$psprintf("This is a NOTE Message at time %d",$time));

`vmm_error(log,"This is a ERROR Message 1 ");
`vmm_error(log,"This is a ERROR Message 2 ");
`vmm_error(log,"This is a ERROR Message 3 ");


`vmm_warning(log,"This is a WARNING Message 1 ");
`vmm_warning(log,"This is a WARNING Message 2 ");


fatal_cnt = log.get_message_count(vmm_log::FATAL_SEV, "/./", "/./", 1);
error_cnt = log.get_message_count(vmm_log::ERROR_SEV, "/./", "/./", 1);
warn_cnt = log.get_message_count(vmm_log::WARNING_SEV, "/./", "/./", 1);

$display("\n\n");
$display(" Number of Fatal messages : %0d ",fatal_cnt);
$display(" Number of Error messages : %0d ",error_cnt);
$display(" Number of Warning messages : %0d ",warn_cnt);
$display("\n\n");

end

endprogram


(S) Download the source code


vmm_log_1.tar
Browse the code in vmm_log_1.tar


(S) Simulation commands
vcs -sverilog -f filelist -R -ntb_opts rvm -ntb_opts dtm






(S) Log file report:


Normal[NOTE] on test_log(log) at 0:
This is a NOTE Message at time 0
!ERROR![FAILURE] on test_log(log) at 0:
This is a ERROR Message 1
!ERROR![FAILURE] on test_log(log) at 0:
This is a ERROR Message 2
!ERROR![FAILURE] on test_log(log) at 0:
This is a ERROR Message 3
WARNING[FAILURE] on test_log(log) at 0:
This is a WARNING Message 1
WARNING[FAILURE] on test_log(log) at 0:
This is a WARNING Message 2


Number of Fatal messages : 0
Number of Error messages : 3
Number of Warning messages : 2





Sometimes we would like to wait for a specific message and execute some logic. For example, you want to count number of crc error packets transmitted by dut in some special testcase or you want to stop the simulation after a specific series of messages are received. vmm_log has a method to wait for a specific message.


virtual task wait_for_msg(string name = "",
string instance = "",
bit recurse = 0,
int typs = ALL_TYPS,
int severity = ALL_SEVS,
string text = "",
logic issued = 1'bx,
ref vmm_log_msg msg);



Following is a simple example which demonstrates the use of above method. In this example, wait_for_msg() method wait for a specific string.



program test_log();

vmm_log log = new("test_log","log");
vmm_log_msg msg = new(log);

/* This logic is some where in the monitor */
initial
repeat (4) begin
#($urandom()%10)
`vmm_error(log,"Packet with CRC ERROR is received");
end


/* In testcase you are counting the error messages */

initial
forever begin
log.wait_for_msg("/./","/./",-1,vmm_log::ALL_TYPS,vmm_log::ERROR_SEV,"Packet with CRC ERROR is received",1'bx,msg);
// You can count number of crc errored pkts rcvd.
// or do whatever you want.
$display(" -- Rcvd CRC ERROR message at %d --",$time);
end

endprogram


(S) Download the source code


vmm_log_2.tar
Browse the code in vmm_log_2.tar


(S) Simulation commands
vcs -sverilog -f filelist -R -ntb_opts rvm -ntb_opts dtm

(S) Log file report:


!ERROR![FAILURE] on test_log(log) at 8:
Packet with CRC ERROR is received
-- Rcvd CRC ERROR message at 8 --
!ERROR![FAILURE] on test_log(log) at 8:
Packet with CRC ERROR is received
-- Rcvd CRC ERROR message at 8 --
!ERROR![FAILURE] on test_log(log) at 11:
Packet with CRC ERROR is received
-- Rcvd CRC ERROR message at 11 --
!ERROR![FAILURE] on test_log(log) at 11:
Packet with CRC ERROR is received
-- Rcvd CRC ERROR message at 11 --

Index
Introduction
Vmm Log
Vmm Env
Vmm Data
Vmm Channel
Vmm Atomic Generator
Vmm Xactor
Vmm Callback
Vmm Test
Vmm Channel Record And Playback
Vmm Scenario Generator
Vmm Opts

Report a Bug or Comment on This section - Your input is what keeps Testbench.in improving with time!





<< PREVIOUS PAGE

TOP

NEXT PAGE >>

copyright 2007-2017 :: all rights reserved www.testbench.in::Disclaimer