RE: [vhdl-200x-ft] Generic packages and Generic Subprograms

From: Peter Ashenden <peter@ashenden.com.au>
Date: Thu Dec 23 2004 - 22:49:18 PST

Jim and Karl,

Funny how we sometimes go around in circles! My original proposal had the
generic clause in subprograms following the subprogram name. However, since
a parameter is different from a port, I proposed the optional keyword
"parameter" to introduce the parameter list. The syntax was

  subprogram specification ::=
      procedure designator
          [ generic ( generic_list ) ]
          [ [ parameter ] ( formal_parameter_list ) ]
   | [ pure | impure ] function designator
          [ generic ( generic_list ) ]
          [ [ parameter ] [ ( formal_parameter_list ) ] return type_mark

However, committee members decided they didn't like the syntax, and
preferred to have the generic clause precedure the rest of the subprogram
specification. I think Jim has raised a valid point about the "Hamming
distance" between different constructs, so the committee may wish to
reconsider the syntax. I personally prefer my original proposal, on the
grounds of consistency among constructs that have a generic list and a
port/parameter list. Jim's comments strengthen my preference.

Cheers,

PA

--
Dr. Peter J. Ashenden                        peter@ashenden.com.au
Ashenden Designs Pty. Ltd.                   www.ashenden.com.au
PO Box 640                                   Ph:  +61 8 8339 7532
Stirling, SA 5152                            Fax: +61 8 8339 2616
Australia                                    Mobile: +61 414 70 9106
> -----Original Message-----
> From: owner-vhdl-200x-ft@eda.org 
> [mailto:owner-vhdl-200x-ft@eda.org] On Behalf Of Karl Eisenhofer
> Sent: Friday, 24 December 2004 06:07
> To: Jim Lewis
> Cc: vhdl-200x-ft@eda.org
> Subject: Re: [vhdl-200x-ft] Generic packages and Generic Subprograms
> 
> 
> To be more consistent with the entity generic declarations, it seems 
> that the generic declaration should not appear before the subprogram 
> declaration.  However, the generic names need to be 
> introduced prior to 
> the parameter list.  Therefore, I suggest putting the 
> subprogram generic 
> declarations just after the function name, but just before 
> the parameter 
> list as so:
> 
> function a_generic_fun generic (type fun_type) (L: fun_type) returns 
> fun_type;
> 
>  From a new user point of view, the syntax should ideally be 
> consistent 
> for all generic/port declarations, i.e.
> 
> entity <name>
>     [generic <list>]
>     [port <list>]
> is
> ...
> 
> package <name>
>     [generic <list>]
> is
> ...
> 
> function <name>
>     [generic <list>]
>     [[port] <list>]            -- optional port keyword, 
> allows current 
> function syntax
>     returns <type>
> is
> ...
> 
> procedure <name>
>     [generic <list>]
>     [[port] <list>]
> is
> ...
> At first glance it would seem to be possible to support both current 
> syntax (wherein for entities, the generic and port lists come 
> after the 
> "is") and this proposed syntax for backward compatibility. 
> 
> Thoughts?
> 
> Karl
> 
> Jim Lewis wrote:
> 
> > Peter,
> > With the generic clause following the generic package and
> > the generic clause preceding the generic 
> procedure/function, seems to 
> > lead to some interesting syntax errors.
> >
> >
> > Case 1:
> > Generics on package and subprogram (no issues, baseline case)
> > ------------------
> >
> > package a_generic_pkg is
> >   generic(type pkg_type) ;
> >
> >   generic(type fun_type)
> >   function a_generic_fun(L: pkg_type) return fun_type ;
> > end a_generic_pkg ;
> >
> >
> > Case 2:
> > Generics on package and but not on subprogram
> > Issue:  If leave off ";", then the generic belongs to
> >         the function and not the package.
> > ------------------
> > library ieee ;
> > use std_logic_1164.all ;
> > package a_generic_pkg is
> >   generic(type pkg_type) ;
> >
> >   function a_generic_fun(L: pkg_type) return std_logic_vector ; end 
> > a_generic_pkg ;
> >
> >
> > Case 3:
> > Generics not on package and on subprogram
> > Issue:  If add ";", then the generic belongs to
> >         the package and not the function.
> > ------------------
> > library ieee ;
> > use std_logic_1164.all ;
> > package a_normal_pkg is
> >
> >   generic(type fun_type)
> >   function a_generic_fun(L: fun_type) return std_logic_vector ; end 
> > a_normal_pkg ;
> >
> >
> >
> > At one point in time I think there was a goal to keep
> > a hamming distance between correct functionality.
> > Should we consider moving the generic clause for the
> > package before the package like the subprogram or
> > alternately should we consider moving the generic
> > clause to after the subprogram declaration.
> >
> > Cheers,
> > Jim
> 
> 
Received on Thu Dec 23 22:49:20 2004

This archive was generated by hypermail 2.1.8 : Thu Dec 23 2004 - 22:50:38 PST