|
CONNECT statement |
Top Previous Next |
|
connect statement = "CONNECT", new identifier, output port spec, input port spec, output port spec, output link spec, input link spec, input port spec, {connect attribute}; output port spec = port spec; input port spec = port spec; output link spec = link spec; input link spec = link spec; connect attribute = connection type | "SHORT", "=", constant; connection type = "PHYSICAL" | "VIRTUAL";
The CONNECT statement connects an output port on one task with an input port on another task. For example:
connect ? driver[0] upc[0] ! connect output port 0 of driver to input port 0 of upc
connect ? upc[0] driver[0] ! connect output port 0 of upc to input port 0 of driver
While the WIRE statement describes a hardware connection in both directions between two processors, the CONNECT statement describes a logical, uni-directional connection from one task to another. The connection creates two new channels: an input channel and an output channel. The output channel is bound to the output port of one task, and the input channel is bound to the input port of the other task. The configurer arranges for output sent to the output channel to be received by the input channel. Communication in both directions between a pair of tasks therefore requires two CONNECT statements, as in the example above.
The tasks being connected need not be on the same processor. In some implementations, the CONNECT statement is supported by sophisticated run-time software which arranges for messages to be forwarded to the appropriate task, wherever it is. In others, the CONNECT statement is mapped directly onto hardware link connections, and hence there may be restrictions on the placement of tasks which are joined in this way.
The order in which you give physical CONNECT statements is used to determine which links are used for the associated channels. The channels created by the first CONNECT statement are allocated the fastest links available, the second CONNECT uses the next fastest links, and so on.
Connections between tasks on attached processors do not need any WIRE to be be declared to join the processors; appropriate wires are created for you, silently and invisibly, by the configurer. The order of the relevant connect statements is significant in this case, as wires are allocated in turn with the fastest available links being used first.
Connections may be named. This allows you to give a name to the input or output channel that the named connection has created for the task. You can then access the channel directly using its name. This is described under INPUT_PORT and OUTPUT_PORT. If you do not name the connections, or do not wish to name the channels, you access the channels by indexing into the vectors of ports passed to the task as arguments to main.
The CONNECT statement can also be used to connect a port directly to a link on the same processor.
CONNECT ? driver[1] root[MyLink:4] CONNECT ? node[OtherLink:2] worker[0]
This form of the CONNECT statement allows the replacement of the obsolete link functions with the standard channel functions. There are a few limitations:
The first use of a link in a CONNECT statement determines the initial state of the link. A link that is connected to an input port will be initialized as an input and a link connected to an output port will start as an output. Hardware-dependent restrictions may override this.
A number of optional connection attributes may follow the input port specifier in a CONNECT statement, in any order.
|