next up previous contents
Next: The Input and Output Up: Classification of Circuit Components Previous: The Wire Class

The Port Class

Ports provide a means whereby components are connected with the external world. It is through ports that components send and receive signals. In addition to maintaining a fan-out of the components that it feeds (which is inherited from Connector), each port must also maintain a pointer to the connector that ``feeds'' it. Note that a port can be fed by one, and only one, Connector. This means that a port may be fed by a single wire or by a single port; and not by, for example, two wires. Note, however, that a wire may feed one or more distinct ports. To keep track of the connector that feeds it, the Port class maintains a pointer to the specific Connector.

Since ports are somewhat too generalized, an Input and Output class will be derived from Port. To prevent the programmer from accidentally creating a Port object, the constructor will be kept protected and is therefore usable only by the Input and Output classes. The declaration of the Port class is as follows:

class Port : public Connector
friend  class Port_List;
        virtual Signal  get_Signal(ckt_time);
        virtual void    send_Signal(Signal);
        Port(Component *, Connector &, char* = "Port");
        Connector       *external;

The constructor accepts a pointer to the component which encapsulates the port, a reference to the connector that feeds the port and an optional name parameter. It then passes the name argument to its base class, Connector; assigns the address of the feeding connector to the protected external data member and finally adds the component to the fan-out list of the feeding connector.

Port::Port(Component *cmp, Connector &con, char *name) : 
        Connector(name), external(&con)

Note that as in the Wire class, the get_Signal() and send_Signal() methods have been redefined by this class. Their definitions are explained in detail in the next chapter.

The Port_List class, described in the next section, is made a friend of the Port class. This is done so the methods of Port_List can efficiently access the fan-out of the Port class during the simulation. This will be explained in more detail in the next chapter.

Diagrams portray ports as small circles embedded within the boxes representing components. Where possible, input ports are placed on the left of the box, whereas output ports are usually placed on the right side of the box.

next up previous contents
Next: The Input and Output Up: Classification of Circuit Components Previous: The Wire Class

Donald Craig
Sat Jul 13 16:02:11 NDT 1996