Coolquest, Inc. | Home | Products | Support | About | Contact | |||
|
<<< Previous | CBOLD Reference Home | Next >>> |
auto_reg registers most class members without any special input from the designer. In some cases, however, the designer must add directives to control auto_reg. The auto_reg directives are end-of-line comments containing special tokens.
auto_reg Directives:
Directive | Meaning |
---|---|
// AR_ON | Starting with this line, enable auto registration of members. |
// AR_OFF | Starting with this line, do not auto register any members until next AR_ON (if any). |
// AR_IGNORE | Do not auto register the member(s) on this line. |
// AR_BUS(L,R) | Auto register the port(s) on this line as busses with range L:R, e.g., // AR_BUS(31,0) |
// AR_INCL | Include the remainder of this line in Register(). See Advanced Features. |
Only one AR_... can be used per line. It takes effect at the beginning of the line. AR_BUS() applies to the entire line on which it is placed and does not affect any other lines. AR_BUS() will blindly attempt to register the member(s) on its line as busses. A compile-time error will result if non-port members are so registered.
Except in the case of AR_INCL, auto_reg ignores the remainder of the line once it has parsed the directive. Thus the remainder of the line is suitable for comments, for example:
class TMyModule: TModule { public: port CS_N; port D; // AR_BUS(31:0) 32-bit data bus port A; // AR_BUS(23:0) 24-bit address bus virtual void Connect() { ... } virtual void Register() { reg( CS_N ); // auto_reg <-- these lines were inserted by auto_reg regb( D, 31, 0 ); // auto_reg regb( A, 23, 0 ); // auto_reg } };
By default, auto registration is enabled at the beginning of the source file. The source file can disable it with AR_OFF and then re-enable it with AR_ON.
To minimize the need for AR_OFF and AR_IGNORE, auto_reg will not register class members with C++ built-in types (e.g., bool, int, char*, etc.) as well as type uint, which is a commonly typedef'd shorthand for unsigned. auto_reg will also ignore member functions, keywords such as public:, etc.
If, upon reaching the declaration of class member function virtual void Register(), auto_reg has found no members to register, auto_reg will skip over the Register() declaration, even if it contains lines marked with the tag comment (// auto_reg). In general, this behavior is unimportant, but in rare cases the user will need to manually delete undesired lines that were inserted by previous runs of auto_reg.
auto_reg supports a wide range of declaration formats, for example:
port RESET; // simple declaration port CE0, CE1, CE2; // list declaration port BE0; port BE1; // multiple declaration port FOO; port BAR0, BAR1; // mixed declaration port DIN, DOUT; // AR_BUS(31,0) -- both DIN and DOUT are 32-bit busses port DIF_PAIRS[5]; // AR_BUS(1,0) -- array of 2-bit busses CP_CDC CDC[ cdc_count ]; // array declaration
<<< Previous | CBOLD Reference Home | Next >>> |
Legal | Copyright © 2007 by Coolquest, Inc. | Contact |