Procedures, variables and their scope.

Discussion in 'VHDL' started by Michel Bieleveld, Oct 27, 2004.

  1. Hi All,

    I have a problem, as far as I know procedures can change
    signals/variables as long as the procedures are defined within the
    scope where the variables are defined. Yet when i try to simulate my
    vhdl code the ISE synthesizer gives me the following warning :

    WARNING:Xst:1960 - C:/projects/redemption/ax88796.vhd line 86:
    Potential simulation mismatch, variable <register_uit> declared in
    block <$PROCESS1> is assigned in block <WriteReg>.

    My code looks basicly like the code shown here. It seems like that the
    variables within the procedure do not change the variable outside the
    procedure, which is what i was hoping for.

    Is there any Macro command or something in vhdl, because that is what
    i am using the procedure for.

    With regards,

    Michel Bieleveld.


    entity ax88796 is
    ...
    end ax88796;

    architecture RTL of ax88796 is
    ...
    begin
    process (nRST,CLK)
    ...
    variable operand : std_logic_vector(15 downto 0);

    procedure ReadReg(Ax_reg : in std_logic_vector(7 downto 0))is
    begin
    operand := B"00001110" & Ax_reg;
    return_state := current_state;
    next_state := st_ExRead;
    end ReadReg;

    begin
    ...

    blahblah ReadReg(X"00");
    ...
    end process;
    end rtl;
    Michel Bieleveld, Oct 27, 2004
    #1
    1. Advertising

  2. Michel Bieleveld wrote:

    > I have a problem, as far as I know procedures can change
    > signals/variables as long as the procedures are defined within the
    > scope where the variables are defined.


    Variables must be passed a parameters to a procedure.

    > It seems like that the
    > variables within the procedure do not change the variable outside the
    > procedure


    If you pass the process variable, the procedure can change
    its value. Variable scope is local to the procedure or process.
    Pass the variable or use a signal.

    -- Mike Treseler
    Mike Treseler, Oct 27, 2004
    #2
    1. Advertising

  3. But I thought the difference between (pure) functions and procedures
    is that procedures can have side effects. In this case changing a
    variable defined in the process from which I am calling the procedure.

    <Michel Bieleveld>


    Mike Treseler <> wrote in message news:<>...
    > Michel Bieleveld wrote:
    >
    > > I have a problem, as far as I know procedures can change
    > > signals/variables as long as the procedures are defined within the
    > > scope where the variables are defined.

    >
    > Variables must be passed a parameters to a procedure.
    >
    > > It seems like that the
    > > variables within the procedure do not change the variable outside the
    > > procedure

    >
    > If you pass the process variable, the procedure can change
    > its value. Variable scope is local to the procedure or process.
    > Pass the variable or use a signal.
    >
    > -- Mike Treseler
    Michel Bieleveld, Oct 27, 2004
    #3
  4. Michel Bieleveld wrote:
    > But I thought the difference between (pure) functions and procedures
    > is that procedures can have side effects.

    True

    > In this case changing a
    > variable defined in the process from which I am calling the procedure.


    Yes, but only if the variable is passed from process scope
    to procedure scope.

    -- Mike Treseler
    Mike Treseler, Oct 28, 2004
    #4
  5. Michel Bieleveld

    Alan Fitch Guest

    "Mike Treseler" <> wrote in message
    news:...
    > Michel Bieleveld wrote:
    > > But I thought the difference between (pure) functions and

    procedures
    > > is that procedures can have side effects.

    > True
    >
    > > In this case changing a
    > > variable defined in the process from which I am calling the

    procedure.
    >
    > Yes, but only if the variable is passed from process scope
    > to procedure scope.
    >


    Hallo Mike,
    I don't think that's correct. Michel is right, a procedure
    declared
    within a process can directly access variables declared within the
    process,
    just as it can directly access signals declared within the
    architecture that
    contains that process.

    Regarding the original problem, Michel can you post your actual code?

    regards
    Alan

    --
    Alan Fitch
    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.
    Alan Fitch, Oct 29, 2004
    #5
  6. Alan Fitch wrote:

    > I don't think that's correct. Michel is right, a procedure
    > declared within a process can directly access variables declared within the
    > process, just as it can directly access signals declared within the
    > architecture that contains that process.


    Sorry about that.
    Yes you and Michel are right, and
    I did not read his example carefully.

    As long as the variable is declared before the procedure
    it is directly visible to that procedure.

    My comments applied to packaged procedures
    that can be called from any process.

    -- Mike Treseler
    Mike Treseler, Oct 29, 2004
    #6
    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. Mark
    Replies:
    4
    Views:
    7,912
    mike_treseler
    Nov 9, 2004
  2. Steven T. Hatton
    Replies:
    9
    Views:
    449
  3. Replies:
    4
    Views:
    439
    rickman
    Jun 26, 2008
  4. Bobby Howell
    Replies:
    2
    Views:
    163
    Bob Barrows [MVP]
    Sep 17, 2005
  5. Talha Oktay
    Replies:
    8
    Views:
    203
Loading...

Share This Page