[Next] [Up] [Previous] [Contents]
Next: Defined types Up: Modules Previous: Instance hierarchies

Structured data types

A module with only type declarations and no parameters or assignments acts like a structured data type. For example, to define a data structure ``hands'' with fields ``left'' and ``right'', the following module might be defined:

        MODULE hands()
        {
          left, right : boolean;
        }

An instance of this structured type can be created as follows:

        party : hands();

This is exactly equivalent to

        party.left, party.right : boolean;

The two fields of this record can be referenced as

        party.left
        party.right

In fact, any signal belonging to a module instance can be referenced directly by name in this way. Normally, however, it is recommended that only inputs and outputs be referenced.

An array of a given structured type may be created in the same manner as an array of signals. For example,

        foo : array 1..0 of hands();
which would be equivalent to

        party[1].left, party[1].right : boolean;
        party[0].left, party[0].right : boolean;

As with signals, multidimensional arrays may be created.



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