index previous next




file name: clockbas.hpp, clockbas.cpp
classification: simulation
contents: class CClock, class CClockTemplate
use: provides a basic interface for accessing the register structure of the UTCSU, plus the template used for obtaining an object of the currently used interface (hardware or software)


global items used by CClock:


global variable defined in the implementation file:

 clockTemplate (template.hpp)


local items used by CClock:

 const double TwoPow16:
 const double TwoPow56: Some powers of two needed for internal computations.


member variables of CClock:

 double granularity_: the external clock granularity (configurable).
default: DefaultClockGranularity

 double granularityAcc_: the accuracy transmission loss (configurable).
default: DefaultAccGranularity

 double granularityDT_: the granularity of the duty timers (fixed).
default: 2^-16

 double granularityOsc_: the oscillator granularity (fixed).
default: 1/oscillatorFrequency

 double granularityS_: the internal clock granularity (fixed).
default: 2^-56

 double oscillatorFrequency_: the frequency of the clock oszillator.
default: set to the f parameter of the constructor

 INT32 utcinten1_: The current value of register UTCINTEN1. The value is only valid if there are no direct accesses to the UTCINTEN1 register.
default value: 0

 INT32 utcinten2_: The current value of register UTCINTEN2. The value is only valid if there are no direct accesses to the UTCINTEN2 register.
default value: 0

 SUtcsuRead *utcsuRead_: A pointer to the register structure of the clock used for read access. In hardware-based simulation, the UTCSU is memory mapped and the pointer will contain the base address of the UTCSU. In pure simulation, it points to a buffer that is allocated to store the contents of the read registers.
default: set to the read parameter of the constructor

 SUtcsuWrite *utcsuWrite_: A pointer to the register structure of the clock used for write access. Again, in hardware-based simulation the UTCSU is memory mapped and the pointer will contain the base address of the UTCSU (which is the same for read and write access). In pure simulation, it points to a buffer that is allocated to store the contents of the write registers. Read and write buffers will not be at the same address.
default: set to the write parameter of the constructor


member functions of CClock:

 CClock (double f, UTCSU_READ32 *read, UTCSU_WRITE32 *write): Sets all members to their default values. If f is not positive, or if read or write is NULL, an assert fails.

 virtual ~CClock(): Empty.

 virtual EBool DisableInterrupt (int area, INT32 mask1, INT32 mask2): Disables the interrupts whose bits are set in the masks. mask1 corresponds to UTCINTEN1, mask2 to UTCINTEN2. The bits set in the masks are masked out in the internal members utcinten1/2 and the UTCINTEN registers are then set to the values of these members. The function always returns True.
Note: this method is only safe if all accesses to the UTCINTEN registers go through this function and its peer, EnableInterrupt(). This will do for pure simulation, but CHardwareClock must overload the functions and there call the corresponding global functions.
Note: the area parameter is only needed for the hardware clock and is ignored in this function.

 virtual EBool EnableInterrupt (int area, INT32 mask1, INT32 mask2): Enables the interrupts whose bits are set in the masks. mask1 corresponds to UTCINTEN1, mask2 to UTCINTEN2. The masks are or-ed to the internal members utcinten1/2 and the UTCINTEN registers are then set to the values of these members. The function always returns True.
Note: the area parameter is only needed for the hardware clock and is ignored in this function.

 double GetFrequency () const: Returns the (ideal) oscillator frequency.

 double GetGranularity () const: Returns the external granularity G.

 double GetGranularityAcc () const: Returns the external accuracy granularity G_A.

 double GetGranularityDT () const: Returns the duty timer granularity G_DT.

 double GetGranularityOsc () const: Returns the oscillator granularity G_osc.

 double GetGranularityS () const_: Returns the internal granularity G_S.

 virtual EBool GetParameter (SParameter& param) const: Returns True if the parameter could be read. All supported parameters assume that param is of type SSingleParameter.

All other parameters are not supported, and False is returned.

 virtual EBool SetParameter (const SParameter& param): Returns True if the parameter could be set. All supported parameters assume that param is of type SSingleParameter.

All other parameters are not supported, and False is returned.


The access functions to the clock registers all obey the same naming conventions, so a general prototype should be sufficient to work with the functions:

 virtual INT32 GetNAME(): The prototype of the function for accessing a read register with the name NAME (the name can be found by looking up the appropriate register in utcsu.hpp). The only exceptions from this prototype are functions accessing registers of duplicated units (SSU and GPU): these take an ESSUnit or EGpsUnit as their first parameter.
Take care: unit numbering starts with 0, whereas in the unit names themselves numbering starts with 1. Also, the access functions do not check the range of unitnumber, so there are two possibilities to goof up...

 virtual void SetNAME (INT32 value): The prototype of the function for setting a write register with the name NAME. Again, functions accessing registers of duplicated units (SSU) take an ESSUnit as their first parameter.


global items used by CClockTemplate:


member functions of CClockTemplate:

Note: clockTemplate (template.hpp) is instantiated in clockbas.cpp.

 virtual CClock *NewClock (double frequency, SINT32 nodeID, int area): The function should return a new object of the currently used interface class (hardware or software clock). The implementation of the function is left to the programmer of the interface class.
Note: nodeID is only needed for the software clock and can be ignored in the hardware.


last modified: Fri Feb 5 18:56:02 1999