Download TBoaP User Manual - Bit Accurate Modelling
Transcript
5 5.1 Base Numeric Configuration Classes SimNumericConfiguration The SimNumericConfiguration abstract class provides an interface for passing data that specifices the behaviour of a particular numerical type. For example, it might contain information such as how many bits of precision to use, and how to handle overflow and divide-by-zero events. Normally, each instance of a numeric type sharing the same configuration will be given a reference to the same single instance of a SimNumericConfiguration , to reduce duplication of data. The particular data will be specific to the SimNumericType that implements it, but extending this abstract class allows that data to be passed between C4Hardware objects without them needing to know for which specific numerical type it refers. 5.1.1 Static Constants Each class extended from SimNumericConfiguration will need to set the configType variable in its constructor, so that other classes can check that it is the correct version of SimNumericConfiguration before forcing a cast. This is achieved by defining the CT constants. static const int CT RealFloat = 1; These constants allow a numerical class to be instructed on how to handle overflow anomalies : // Overflow handling techniques static const int OF crop = 1; // discard the overflowed bits static const int OF staturate = 2; // set value to max/min possible static const int OF throw = 3; // throw an exception The next set of constants were designed for the RealFloatValue class, but could be readily be applied to other types. They specify how the numeric class should behave when not in hardware emulation mode. It is up to the programmer of the base numeric class to determine the specific behaviour. // Emulation mode constants static const int EM components = 0; // Use C pseudo-modelling of type static const int EM double = 1; // Use C internal double precision static const int EM single = 2; // Use C internal single precision The following constants are designed to allow the specification of alternative ways of performing certain calculations. Currently unused, but provided for future expansion : // Multiplication Methods static const int MUL standard = 1; // Use C++ * operator // Division Methods static const int DIV standard = 1; // Use C++ / operator // Square Root Methods static const int SQRT standard = 1; // Use C++ sqrt() // Inversion Methods static const int INV standard = 1; // Use C++ 1/x // Inverse Square Root Methods static const int ISQRT standard = 1;// Use C++ sqrt operator // Squaring Methods static const int SQR standard = 1; // Use C++ * operator 20