Monday, September 27, 2010

Questasim: How to find all signals with X value in simulation

Modelsim/Questa currently doesn't have a built in command to list all X signals in the design.

Solution

 The following is an example of a TCL script that can be used to print out a list of all signals in the design that have an X or U value at the current simulation time.

foreach item [find signals -r /*] {

    if { [examine -expr $item'hasX] eq "true"} {

        echo "$item [examine $item]"

}

}


To run this script:

1) Save the code to a file.

2) On the modelsim command line or transcript use the 'do' command followed by the path and name of the script file to run the script. If the file was saved in the current directory as "script.do" the command would look like this:

> do script.do


The following is a brief explanation of the script functionality.

The script uses the 'find' command to build an array recursively from the root of the design hierarchy of all signals, and then that array is iterated through a foreach loop.

foreach item [find signals -r /*] {

The following line tests if each item has an X or U value

if { [examine -expr $item'hasX] eq "true"} {


Finally, if it does, the signal and its value are printed to the transcript.

echo "$item [examine $item]"


1 comment:

  1. How do i find the time at which those signals are X ?? $now gives the last value of time.

    ReplyDelete