[sv-bc] Using type from interface in ANSI-style port declaration

From: Brad Pierce <Brad.Pierce_at_.....>
Date: Mon Oct 24 2005 - 13:14:42 PDT
Unlike class specializations, interface specializations cannot be used
in a module port declaration. For example, the following is disallowed

   module m #(parameter N) (IFC#(N) ifc, input [N-1:0] in);

I'm guessing that the methodological motivation for this difference is
that the declaration of the module should be written to depend on
whichever interfaces are eventually connected up to its instances.
(Whether the LRM should be imposing methodology is a different
question.)

Unfortunately, other restrictions of SV syntax force people that want to
follow this methodology into using old-style port declarations instead
of the so-called ANSI-style declarations introduced with V2K.

This is because the only way to get elaboration-time info about an
object in an interface instance is to declare a type for the object in
the interface, redeclare the name inside the module whose instance will
be connected to the interface instance, and then ask a question about
the locally redeclared type.

For example, to make the size of a port depend on the size of a variable
in an interface instance, you need to declare a name for its type in the
interface and then do something like

   module m (io, ifc);
   IFC ifc; 
   typedef ifc.T T;
   localparam N = $size(T);
   inout [N-1:0] io;

-- Brad
Received on Mon Oct 24 13:14:47 2005

This archive was generated by hypermail 2.1.8 : Mon Oct 24 2005 - 13:16:53 PDT