Coolquest, Inc. Home Products Support About Contact
cbold_logo_gif C++BOLD Reference Manual cbold_logo_gif

<<< Previous CBOLD Reference Home Next >>>


18. Technical Details

Under Construction

18.1. Port Range Implementation

The expression of port ranges with parentheses is implemented by overloading the function call operator (operator()) for classes TPort and TPortRange.

Square brackets were not chosen for this functionality, because (1) square brackets are needed for array subscripting, e.g., subscripting of arrays of ports, and (2) the semantics of the subscripting operator seemed less natural than those of the function call operator. E.g., Port1( 7, 0 ) seems more natural than Port1[ 7 ][ 1 ].

18.2. Error Handling

CBOLD handles errors using the C++ exception mechanism. Two CBOLD macros, BEGERR and ENDERR, standardize the throwing of exceptions. Though there is rarely need to do so, the designer is free to use these macros to report errors detected in user code. For example, the FPGA wrapper class in the IROD example design double-checks that it connects the expected number of FPGA pins to each of its bank ports. It makes this check after connecting each bank and reports any error using BEGERR/ENDERR:

// from file std_fpga.h
if ( i + (V ? 3 : 0)   !=  IO_PerBank[ b ] )
  BEGERR << "CM_STD_FPGA:Connect(): IO_PerBank mismatch, attempt to connect " << i << " pins to bank " << b << ENDERR;

BEGERR creates a memory stream object to which a detailed error message can be written using the standard stream output operators, e.g., <<. ENDERR throws this object as an exception. The exception handler, located near the end of main(), prints the contents of the thrown object, waits for a keypress, and then exits the program.

See also Runtime Errors.


<<< Previous CBOLD Reference Home Next >>>

Legal Copyright © 2007 by Coolquest, Inc. Contact