ModelSim question/checking the value of a variable

K

kwaj

Guest
I am attempting to simulate a design in ModelSim. Is a command to get the
simulator to display the current value of a variable? For instance, I would
like to see the current value of a variable (note not signal) called
"nstates"...how might I do this? In matlab, simply typing the value of the
variable would give its current value...what is the vhdl equivalent?

cheers

- Kingsley
 
"kwaj" <k.otengNOSPAM@student.unsw.edu.auNOSPAM> wrote in
message news:c0v0t3$47t$1@tomahawk.unsw.edu.au...
I am attempting to simulate a design in ModelSim. Is a command to get the
simulator to display the current value of a variable? For instance, I
would
like to see the current value of a variable (note not signal) called
"nstates"...how might I do this?
You can specify a variable using a hierarchical path at the command
line, just as you would for a signal, but remembering to include
the name of its enclosing process. For example:

entity Device...
architecture D of Device is
begin
P: process
variable V: ...
begin
end process P;
end architecture D;

entity TopLevel...
architecture T of TopLevel is
begin
U: entity work.Device(D); -- instance
end architecture T;

Now you can refer to the variable V from ModelSim's command
line as
/TopLevel/U/P/V
NOTE the process name P in that path.

If you fail to name the process, ModelSim will cook up
a name for you based on its line number in the file.

From the ModelSim GUI, get the Process window, select
the process containing your variable, then bring up a
Variables window.

In matlab, simply typing the value of the
variable would give its current value...
what is the vhdl equivalent?
This is not a VHDL issue. When you're typing at the ModelSim
command prompt you are using Tcl, not VHDL. ModelSim adds
various commands to Tcl, such as [examine] and [force],
allowing you to interact with the running simulator's data
structures.

--

Jonathan Bromley, Consultant

DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * Perl * Tcl/Tk * Verification * Project Services

Doulos Ltd. Church Hatch, 22 Market Place, Ringwood, Hampshire, BH24 1AW, UK
Tel: +44 (0)1425 471223 mail: jonathan.bromley@doulos.com
Fax: +44 (0)1425 471573 Web: http://www.doulos.com

The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.
 
kwaj wrote:
I am attempting to simulate a design in ModelSim. Is a command to get the
simulator to display the current value of a variable? For instance, I would
like to see the current value of a variable (note not signal) called
"nstates"...how might I do this? In matlab, simply typing the value of the
variable would give its current value...what is the vhdl equivalent?
Unlike Verilog, VHDL simulation commands are not built into the language
so every simulator is different.

For ModelSim, you can display the value of a variable using the
"Variable" window or access it directly from the command line with:

examine /module_name/process_name/variable_name

You can display it in a wave window with:

add wave /module_name/process_name/variable_name

If you haven't named your processes then ModelSim will have given them
names based on the line numbers of your source file.

All this is covered in the ModelSim Command Reference Manual so I
suggest that next time you try reading the manual before posting.
--
Tim Hubberstey, P.Eng. . . . . . Hardware/Software Consulting Engineer
Marmot Engineering . . . . . . . VHDL, ASICs, FPGAs, embedded systems
Vancouver, BC, Canada . . . . . . . . . . . http://www.marmot-eng.com
 
I'm not sure if this exactly what you want but you can embed in your code an
assertion statement that reports the value of the variable in the ModelSim
command window like this:

myAssertStatement : assert false report "Value of nstates is " &
integer'image(nstates) & "." severity note;

Assuming that nstates is of type integer (for other types use appropriate
identifier)



"kwaj" <k.otengNOSPAM@student.unsw.edu.auNOSPAM> wrote in message
news:c0v0t3$47t$1@tomahawk.unsw.edu.au...
I am attempting to simulate a design in ModelSim. Is a command to get the
simulator to display the current value of a variable? For instance, I
would
like to see the current value of a variable (note not signal) called
"nstates"...how might I do this? In matlab, simply typing the value of
the
variable would give its current value...what is the vhdl equivalent?

cheers

- Kingsley
 

Welcome to EDABoard.com

Sponsor

Back
Top