Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I see a variable's value for debugging VHDL code in modelsim?

Tags:

vhdl

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):

I can see signal's value

But, I can't see value of the variable tmp:

I cannot see variable's value

How can I see also the value of variables?

like image 765
Mohsen Avatar asked Mar 11 '16 16:03

Mohsen


People also ask

How do I see variables in Modelsim?

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.

How do you assign a value to a variable in VHDL?

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 “<=”.

Where are variables declared in VHDL?

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.


2 Answers

You can oberserve the variable value by single-stepping through the respective process.

  1. Start the simulation and open the source file containing the respective process.

  2. Set a breakpoint at the beginning of the process and run the simulation until the breakpoint is triggered with the command run -all.

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

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

like image 161
Martin Zabel Avatar answered Sep 25 '22 12:09

Martin Zabel


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.

like image 38
Matthew Taylor Avatar answered Sep 22 '22 12:09

Matthew Taylor