next up previous contents
Next: The Component_List Class Up: Classification of Circuit Components Previous: Classification of Circuit Components

The Component Class

Components are responsible for getting inputs, processing them and producing outputs. In order for components to get their inputs from and send their outputs to the external world, ports must be made part of the components in some way. To increase the ease at which the simulation algorithm can access the component's ports, pointers to both the input and output ports will be stored in separate linked lists within the components. Therefore, there are at least two elements of the Component class: two linked lists of input and output port pointers. Since ports form the interface of a component, these linked lists are placed in the public section of the class. Note, however, that the operations that can be performed on this linked list are limited by the public interface of the Port_List class, which is discussed later.

Next, the user should be given the option of assigning some name to a component, which will be useful from a debugging viewpoint. Therefore, a pointer to a character (string) will be placed in the class. In addition, in this particular implementation, every component maintains its own local time during the simulation. This concept of local time will be further explained in the next chapter. Since nothing else outside of the class should be allowed to access the name or local time, these two data members should be placed in the private section of the class so they can be accessed only by methods of this class, such as the constructor.

Every component also has a delay which represents how long it takes to produce its outputs upon receiving its inputs. During the simulation, objects derived from Component should be permitted to change the delay time of the component (for example, the delay time could increase during the simulation, modelling the effect of a component getting warmer, hence increasing its resistance). Since classes derived from Component are the only ones able to change the delay, the delay data member is protected in the class.

Two public methods are declared, which are used extensively during the simulation of the circuit. These two methods, process() and simulate() are discussed in greater detail in the next chapter.

Finally, a constructor is required which is used to actually build the component. Since a component is too abstract a concept to be useful from an instantiation perspective, only specialized classes derived from Component may call this constructor. Therefore the Component constructor is made a protected member of the class.

The final class declaration for Component looks as follows:

class Component
        Port_List       I_List;
        Port_List       O_List;
        virtual void    process(ckt_time);
        void            simulate();
        Component(ckt_time = UNDEF_TIME, char* = "Component");
        ckt_time        delay;
        char            *name;
        ckt_time        local_time;

Note that the Component constructor accepts two parameters, a ckt_time argument, which is used to initialize the delay of the component (ckt_time is simply typedef'fed to long), and a char * which is used to initialize the name of the component. Both of these arguments have default values, so the derived class does not have to call this constructor explicitly when constructing its Component base. The constructor for Component is simply:

Component::Component(ckt_time t, char *nm) : 
        delay(t), name(nm), local_time(INIT_TIME)
{ }

This constructor assigns the arguments t and nm to data members delay and name respectively. The local_time data member is set to some constant value representing initial time. Note that the I_List and O_List data members are initialized implicitly by the Port_List default constructor, as discussed later in this chapter.

As is the convention among hardware designers, boxes will be used to represent components in the diagrams following in this report.

next up previous contents
Next: The Component_List Class Up: Classification of Circuit Components Previous: Classification of Circuit Components

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