The OUTPUT_PORT macro takes the task’s output port selected by portid and associates the bound channel with an identifier; this identifier is an external variable of type CHAN. The macro may be used as a declaration in any file used to build a task.
Note that as the variable is external its name must be unique or the linker will report errors.
Portid can be:
|
| • | an integer constant index into the task’s output port vector, selecting a particular port; |
|
|
| • | the name of a CONNECT statement in the configuration file, selecting the output port specification for this task. |
|
See also INPUT_PORT, which includes a technique for accessing ports from several separately-compiled modules.
For example, given the following extract of a configuration file:
TASK A .... OUTS=4
TASK B ....
CONNECT control A[1] B[2]
The main function of A could include the following:
OUTPUT_PORT(control, control_out)
OUTPUT_PORT(3, data_out);
main(int argc, char *argv[], char *envp[],
CHAN *in_ports[], int ins,
CHAN *out_ports[], int outs) {
...
chan_out_message(16, b, out_ports[1]);
chan_out_message(16, b, &control_out); // same as above
chan_out_message(12, b, out_ports[3]);
chan_out_message(12, b, &data_out); // same as above
|