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 11:36:37 2004
This archive was generated by hypermail 2.1.8 : Thu Dec 23 2004 - 11:37:00 PST