Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > subprogram parameter list

Reply
Thread Tools

subprogram parameter list

 
 
=?ISO-8859-1?Q?Sch=FCle_Daniel?=
Guest
Posts: n/a
 
      07-09-2006
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
 
Reply With Quote
 
 
 
 
reuven
Guest
Posts: n/a
 
      07-10-2006

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;

 
Reply With Quote
 
 
 
 
=?ISO-8859-1?Q?Sch=FCle_Daniel?=
Guest
Posts: n/a
 
      07-13-2006
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
 
Reply With Quote
 
john Doef
Guest
Posts: n/a
 
      07-13-2006

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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
question on subprogram parameter skyworld Python 1 10-29-2012 03:35 AM
default value for subprogram parameter John Smith VHDL 10 07-03-2007 08:22 PM
problems with readline function within a subprogram ed.agunos@gmail.com VHDL 1 09-08-2006 10:14 PM
Simulating testbench waveform error: "No feasible entries for subprogram write" Taras_96 VHDL 2 08-03-2005 02:55 AM
Hiding of subprogram designators David Jones VHDL 1 11-18-2003 09:37 AM



Advertisments