|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object avrora.sim.clock.Clock avrora.sim.clock.ClockPrescaler
The ClockPrescaler
class represents a clock that is another clock scaled appropriately; e.g.
8x slower.
Field Summary | |
protected long |
base
The base field stores the cycle count of the underlying clock at the last time that this
clock was reset. |
protected int |
divider
The divider stores the number of cycles of the underlying clock are equivalent to one
cycle of this clock. |
protected Clock |
driveClock
The driveClock field stores a reference to the clock that the prescaler is derived from. |
protected long |
ticksBeforeBase
The ticksBeforeBase field stores the number of ticks that were recorded before the
prescaler was reset. |
Fields inherited from class avrora.sim.clock.Clock |
hz, name |
Constructor Summary | |
ClockPrescaler(java.lang.String n,
Clock drive,
int divider)
The constructor of the ClockPrescaler creates a new clock that is an integer multiple
slower than the clock that it is derived from. |
Method Summary | |
long |
getCount()
The getCount() method returns the number of clock cycles (ticks) that have elapsed for
this clock. |
long |
getTotalCount()
The getTotalCount() method returns the total number of clock cycles (ticks) that have
elapsed for this clock. |
void |
insertEvent(Simulator.Event e,
long delta)
The insertEvent() method inserts an event into the event queue of the clock with the
specified delay in clock cycles. |
void |
removeEvent(Simulator.Event e)
The removeEvent() method removes an event from the event queue of the clock. |
void |
reset()
The reset() method resets the internal clock prescaler to zero. |
Methods inherited from class avrora.sim.clock.Clock |
getHZ, getName |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected final Clock driveClock
driveClock
field stores a reference to the clock that the prescaler is derived from.
protected final int divider
divider
stores the number of cycles of the underlying clock are equivalent to one
cycle of this clock. For example, with a divider or 8, the underlying clock ticks 8 times for each tick
of this clock.
protected long base
base
field stores the cycle count of the underlying clock at the last time that this
clock was reset.
protected long ticksBeforeBase
ticksBeforeBase
field stores the number of ticks that were recorded before the
prescaler was reset. This is used in the calculation of the total number of ticks that have elapsed.
Constructor Detail |
public ClockPrescaler(java.lang.String n, Clock drive, int divider)
ClockPrescaler
creates a new clock that is an integer multiple
slower than the clock that it is derived from. Additionally, the phase at which this clock fires can be
adjusted by resetting.
n
- the name of the new clockdrive
- the clock that drives this derived clockdivider
- the muliple by which the derived clock is slower than the sourceMethod Detail |
public long getCount()
getCount()
method returns the number of clock cycles (ticks) that have elapsed for
this clock. In the implementation of the ClockPrescaler
, this method calculates the number
of scaled cycles since the last reset.
getCount
in class Clock
public long getTotalCount()
getTotalCount()
method returns the total number of clock cycles (ticks) that have
elapsed for this clock. In the implementation of the ClockPrescaler
, this method
calculates the number of scaled cycles since the last reset, plus the number of ticks elapsed before
the reset.
public void insertEvent(Simulator.Event e, long delta)
insertEvent()
method inserts an event into the event queue of the clock with the
specified delay in clock cycles. The event will then be executed at the future time specified. In the
implementation of ClockPrescaler
, the event will be scheduled in the underlying clock,
with the delay calculated correctly from the last time that the prescaler was reset.
insertEvent
in class Clock
e
- the event to be inserteddelta
- the number of (scaled) cycles in the future at which to firepublic void removeEvent(Simulator.Event e)
removeEvent()
method removes an event from the event queue of the clock. The
comparison used is reference equality, not .equals()
.
removeEvent
in class Clock
e
- the event to removepublic void reset()
reset()
method resets the internal clock prescaler to zero. Thus, the prescaler's
previous phase is broken, and the clock signal continues with the same frequency, only that the first
tick will happen divider
cycles from now.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |