Appendix I - Listing Ports

The behaivoral description of a model can get a listing of the ports connected to it's box-instance.
The following functions return the number of respective ports, and an array of the port-names: The formal definitions are:
char **list_in_ports( int *nports );

char **list_out_ports( int *nports );

An example usage is:

      {
	int num;
	char **plist;

	plist = list_in_ports( &num );

	csim_printf("My input ports are:\n");
	for (i=0; i<num; i++)
	 printf(" %s\n", plist[i] );
       }


This example prints the device's input ports.

The above functions list the ports actually connected to the particular box-instance calling them. Ports that are not connected to another device, or that are connected to /dev/null, will not be shown in the list. This is preferred for most uses. However, occasionally the list of all ports is needed for a given device class/type. The following calls list all ports:

char **CSIM_LIST_ALL_IN_PORTS( int *nports );

char **CSIM_LIST_ALL_OUT_PORTS( int *nports );

Except for the extra ports, these operate similarly to the calls above. For example, suppose boxes of device-type alpha have sixteen (16) input ports, but box Q5, an instance of type alpha, has only eleven (11) of its input ports connected. Then list_in_ports() would return with eleven (11) ports, while CSIM_LIST_ALL_IN_PORTS() would return with sixteen (16) ports.

For a port to be connected, it must connect through a link to another leaf-box. It does not have to be connected directly to a leaf-box on the same diagram. It can connected to the other leaf-box through the hierarchy, such as through a module or external port connection. If a link connects to a module, but does not connect to anything within the module, or inversely, if it connects to an external port which is not connected outside the module, then the link is not connected. A good way to think about it, is to consider the flattened hierarchy.



Finding Device (or Box) Attached to a Given Port

From within a given box, the CSIM_GET_DEVICE_ATTACHED_TO_PORT function returns the name of the neighboring device connected to a specific port on the box. It also returns the name of the port on the remote device linking the two boxes.

Formal function definition:

void CSIM_GET_DEVICE_ATTACHED_TO_PORT( char *portname, char *remote_boxname, int maxchar1, char *remote_portname, int maxchar2 );