I

Top  Previous  Next
INPUT_PORT

#include <chan.h>

INPUT_PORT (

   portid,

   identifier

)

 stand-alone

The INPUT_PORT macro takes the task’s input port selected by portid and associates the bound channel with an identifier; this identifier is used to create 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 input port vector, selecting a particular port;

the name of a CONNECT statement in the configuration file, selecting the input port specification for this task.

 

See also OUTPUT_PORT.

 

For example, given the following extract of a configuration file:

 

TASK A ....

TASK B .... INS=4

CONNECT control A[1] B[2]

 

The main function of B could include the following:

 

INPUT_PORT(control, control_in)

INPUT_PORT(3, data_in);

 

main(int argc, char *argv[], char *envp[],

     CHAN *in_ports[], int ins,

     CHAN *out_ports[], int outs) {

   ...

   chan_in_message(16, b, in_ports[2]);

   chan_in_message(16, b, &control_in); // same as above

 

   chan_in_message(12, b, in_ports[3]);

   chan_in_message(12, b, &data_in);    // same as above

is...