I want to see a variable's value for debugging my code. But, I can see only signals and input and outputs value when I put mouse pointer on them, like in this picture (state
is a signal here):
But, I can't see value of the variable tmp
:
How can I see also the value of variables?
In Modelsim, the Objects window never displays variables. Variables can be enabled by first showing processes. This is done by right clicking on the design that you want to view the variables for. Go down to Show, and check that Processes are being shown.
Similar to a signal, a variable can be of any data type. Variables are local to a process. They are used to store the intermediate values and cannot be accessed outside of the process. The assignment to a variable uses the “:=” notation, whereas, the signal assignment uses “<=”.
Declaration of Variables. Variables are the basic unit of storage in a programming language. These variables consist of a data type, the variable name, and the value to be assigned to the variable. Unless and until the variables are declared and initialized, they cannot be used in the program.
You can oberserve the variable value by single-stepping through the respective process
.
Start the simulation and open the source file containing the respective process
.
Set a breakpoint at the beginning of the process
and run the simulation until the breakpoint is triggered with the command run -all
.
Now, you can observe the variable value by
a) hovering the mouse over it, or by
b) selecting menu View -> Locals and navigating to the process in the design hierarchy.
Now, you can single-step through the process with the command step
. You will see, how the variable value changes until the process suspends. Continue the simulation with run -all
until the breakpoint is triggered again.
There's one way:
i) Run the simulation for a very short time, eg 1 ns.
ii) Click on View -> Locals
iii) Navigate to the point in your design where the variable is and you will see it in the Locals window. Add it to the Waves.
iv) Run the rest of your simulation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With