[Next] [Up] [Previous] [Contents]
Next: Structured data types Up: Modules Previous: Input and output declarations

Instance hierarchies

Modules may, of course, contain instances of other modules, and so forth, provided the module references are not circular. So we can, for example, create three-bit counter module, as follows:

MODULE counter3(carry_in, clear, count, carry_out)
{
  INPUT carry_in, clear : boolean;
  OUTPUT count : array 2..0 of boolean;
  OUTPUT carry_out : boolean;

  carry : array 3..1 of boolean;

  bit0 : counter_bit(carry_in, clear, carry[0], carry[1]);
  bit1 : counter_bit(carry[1], clear, carry[1], carry[2]);
  bit2 : counter_bit(carry[2], clear, carry[2], carry[3]);

  carry_out := carry[3];
}

If we then instantiate this module with

        foo : counter(cin,clr,cnt,cout);
we will have, for example, an instance of counter_bit called foo.bit0, which defines signals

        foo.bit0.carry_in
        foo.bit0.clear
        foo.bit0.bit_out
        foo.bit0.carry_out

MODULE declarations may not appear inside other MODULE declarations, however. That is, all MODULE declarations must be in the outermost scope.



Ken McMillan
Sat Jun 6 21:41:59 PDT 1998