subprogram parameter list

Discussion in 'VHDL' started by =?ISO-8859-1?Q?Sch=FCle_Daniel?=, Jul 9, 2006.

  1. Hello,

    I have a simple question and my book doesn't have the answer

    given a procedure declaration in the package and
    its definition in a package body


    package X is
    procedure xxx(variable a: out integer); -- a
    end;

    package body X is
    procedure xxx(variable b: out integer) is -- b --(2)
    begin
    b := 1; -- (1)
    end;
    end;

    is it allowed to rename the parameters in such way?
    ghdl gives an error message at (1) that 'b' is not declared
    however (2) was accepted.

    Regards, Daniel
     
    =?ISO-8859-1?Q?Sch=FCle_Daniel?=, Jul 9, 2006
    #1
    1. Advertising

  2. =?ISO-8859-1?Q?Sch=FCle_Daniel?=

    reuven Guest

    Schüle Daniel wrote:
    > Hello,
    >
    > I have a simple question and my book doesn't have the answer
    >
    > given a procedure declaration in the package and
    > its definition in a package body
    >
    >
    > package X is
    > procedure xxx(variable a: out integer); -- a
    > end;
    >
    > package body X is
    > procedure xxx(variable b: out integer) is -- b --(2)
    > begin
    > b := 1; -- (1)
    > end;
    > end;
    >
    > is it allowed to rename the parameters in such way?
    > ghdl gives an error message at (1) that 'b' is not declared
    > however (2) was accepted.
    >
    > Regards, Daniel


    No, it is not allowed, the procedure declaration is the interface to
    the procedure implementation in the package body. How will ghdl know
    the procedure body matches the interface declaration. By the way,
    procedures in VHDL can be overloaded. To extend your example:

    package X is
    procedure xxx(variable a: out integer); -- a
    procedure xxx(variable a: out real); -- a
    end;

    package body X is
    procedure xxx(variable a: out integer) is -- b --(2)
    begin
    b := 1; -- (1)
    end;
    procedure xxx(variable a: out real) is -- b --(2)
    begin
    b := 1.0; -- (1)
    end;
    end;
     
    reuven, Jul 10, 2006
    #2
    1. Advertising

  3. reuven schrieb:
    > Schüle Daniel wrote:
    >> Hello,
    >>
    >> I have a simple question and my book doesn't have the answer
    >>
    >> given a procedure declaration in the package and
    >> its definition in a package body
    >>
    >>
    >> package X is
    >> procedure xxx(variable a: out integer); -- a
    >> end;
    >>
    >> package body X is
    >> procedure xxx(variable b: out integer) is -- b --(2)
    >> begin
    >> b := 1; -- (1)
    >> end;
    >> end;
    >>
    >> is it allowed to rename the parameters in such way?
    >> ghdl gives an error message at (1) that 'b' is not declared
    >> however (2) was accepted.
    >>
    >> Regards, Daniel

    >
    > No, it is not allowed, the procedure declaration is the interface to
    > the procedure implementation in the package body. How will ghdl know
    > the procedure body matches the interface declaration.



    I think it is more a matter of design
    it would be easy to ignore the name the way C does it

    int foo(int x);
    int foo(int y);
    int foo(int); // all the same

    hence my question, whether the names are part of subprogram
    signature or not.

    I stumbled over this with names res <-> ret (meaning result <-> return)


    By the way,
    > procedures in VHDL can be overloaded. To extend your example:
    >
    > package X is
    > procedure xxx(variable a: out integer); -- a
    > procedure xxx(variable a: out real); -- a
    > end;


    yes, I use it heavily

    BTW is it possible to overload a function on its return type?
    (something that can't be done in C++)

    Regards, Daniel
     
    =?ISO-8859-1?Q?Sch=FCle_Daniel?=, Jul 13, 2006
    #3
  4. =?ISO-8859-1?Q?Sch=FCle_Daniel?=

    john Doef Guest

    Schüle Daniel a écrit :

    > reuven schrieb:
    > > Schüle Daniel wrote:
    > >> Hello,
    > >>
    > >> I have a simple question and my book doesn't have the answer
    > >>
    > >> given a procedure declaration in the package and
    > >> its definition in a package body
    > >>
    > >>
    > >> package X is
    > >> procedure xxx(variable a: out integer); -- a
    > >> end;
    > >>
    > >> package body X is
    > >> procedure xxx(variable b: out integer) is -- b --(2)
    > >> begin
    > >> b := 1; -- (1)
    > >> end;
    > >> end;
    > >>
    > >> is it allowed to rename the parameters in such way?
    > >> ghdl gives an error message at (1) that 'b' is not declared
    > >> however (2) was accepted.
    > >>
    > >> Regards, Daniel

    > >
    > > No, it is not allowed, the procedure declaration is the interface to
    > > the procedure implementation in the package body. How will ghdl know
    > > the procedure body matches the interface declaration.

    >
    >
    > I think it is more a matter of design
    > it would be easy to ignore the name the way C does it
    >
    > int foo(int x);
    > int foo(int y);
    > int foo(int); // all the same
    >
    > hence my question, whether the names are part of subprogram
    > signature or not.

    Yes they are! Cf LRM 2.7

    > I stumbled over this with names res <-> ret (meaning result <-> return)
    >
    >
    > By the way,
    > > procedures in VHDL can be overloaded. To extend your example:
    > >
    > > package X is
    > > procedure xxx(variable a: out integer); -- a
    > > procedure xxx(variable a: out real); -- a
    > > end;

    >
    > yes, I use it heavily
    >
    > BTW is it possible to overload a function on its return type?
    > (something that can't be done in C++)

    Yes it is. LRM 10.5

    JD.
     
    john Doef, Jul 13, 2006
    #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. David Jones

    Hiding of subprogram designators

    David Jones, Nov 17, 2003, in forum: VHDL
    Replies:
    1
    Views:
    571
    Alan Fitch
    Nov 18, 2003
  2. Taras_96
    Replies:
    2
    Views:
    4,899
    Taras_96
    Aug 3, 2005
  3. Replies:
    1
    Views:
    689
    Paul Uiterlinden
    Sep 8, 2006
  4. John Smith
    Replies:
    10
    Views:
    800
    Jonathan Bromley
    Jul 3, 2007
  5. skyworld

    question on subprogram parameter

    skyworld, Oct 29, 2012, in forum: Python
    Replies:
    1
    Views:
    197
Loading...

Share This Page