ModelSim question/checking the value of a variable

Discussion in 'VHDL' started by kwaj, Feb 18, 2004.

  1. kwaj

    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, Feb 18, 2004
    #1
    1. Advertising

  2. "kwaj" <> wrote in
    message news:c0v0t3$47t$...
    > 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:
    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.
    Jonathan Bromley, Feb 18, 2004
    #2
    1. Advertising

  3. 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
    Tim Hubberstey, Feb 18, 2004
    #3
  4. 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" <> wrote in message
    news:c0v0t3$47t$...
    > 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
    >
    >
    Grigorios Angelis, Feb 18, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. walala
    Replies:
    1
    Views:
    731
    Kai Harrekilde-Petersen
    Sep 12, 2003
  2. -
    Replies:
    0
    Views:
    317
  3. Dan Rawson
    Replies:
    7
    Views:
    339
    Michele Simionato
    Aug 6, 2003
  4. Mir Nazim
    Replies:
    2
    Views:
    341
    Mir Nazim
    Dec 21, 2008
  5. rwdfan
    Replies:
    6
    Views:
    1,992
Loading...

Share This Page