Coolquest, Inc. | Home | Products | Support | About | Contact | |||
|
<<< Previous | CBOLD Reference Home | Next >>> |
Register() may contain code in addition to registering macros. This is important for advanced techniques, such as selective registering.
For example:
class CM_MyModule : public TModule { public: CM_Decoupling Decoupling; // decoupling capacitors for this module ... virtual void Register() { Decoupling.SetCapCount5( 8 ); // request 8 capacitors for VCC5 Decoupling.SetCapCount3( 16 ); // request 16 capacitors for VCC3_3 reg( Decoupling ); ... } };
In this example, CM_Decoupling is a module that contains an array of decoupling capacitors for each of two power supplies.
Before registering Decoupling, the user must tell it how many capacitors to register for each supply. This is done by calling CM_Decoupling's SetCapCount...() methods. By convention, methods like SetCapCount...() do not register the capacitors. Instead, they just record the requested number of capacitors in private variables. When Decoupling's Register() is called by the CBOLD framework, it used the values in the private variables to register the requested number of capacitors:
class CM_Decoupling : public TModule { private: int CapCount5; int CapCount3; public: port VCC5; port VCC3_3; CP_CDC CDC5[ 50 ]; CP_CDC CDC3[ 50 ]; CM_Decoupling() { CapCount5 = 0; CapCount3 = 0; } // constructor void SetCapCount5( int Count ) { if ( Count > 50 ) Count = 50; CapCount5 = Count; } void SetCapCount3( int Count ) { if ( Count > 50 ) Count = 50; CapCount3 = Count; } virtual void Register() { reg( VCC5 ); reg( VCC3_3); for ( int i = 0; i < CapCount5; ++ i ) regn( CDC5, i ); for ( int i = 0; i < CapCount3; ++ i ) regn( CDC3, i ); } virtual void Connect() { ... // e.g., wire up only those caps that were registered } };
<<< Previous | CBOLD Reference Home | Next >>> |
Legal | Copyright © 2007 by Coolquest, Inc. | Contact |