User guide
CIF Peripheral Model - SimpleTimer
CoMET Version 5.9 – Tutorial 97
Events and Responses in Behavioral Code
We can now review the Event and Response table derived from the specification, adding the
information on how our behavioral code handles the response to events.
Event Response Behavioral Code Function
Reset Deassert
outputs, clear all
registers
Reset - deassert output on entering reset, clear
registers on exiting reset
MTR (Match Timer
Register) equal to
General Timer register
Corresponding
MatchInterrupt
Port goes high if
Match Enabled
and Interrupt
Enabled
Match - callback, called when a scheduled
match event takes place. Set the GTR to show
the correct count, set the TIFR to show the
required interrupt flag, generate the interrupt by
changing the MatchInterrupt port value,
schedule an UnMatch event on the next tick.
Bus Read Return value of
register
determined by
address
ReadRegister - Decode required register from
address offset.
In the case of GTR (General Timer Register)
determine the value at the time of the read
Bus Write
GTR General Timer
Register
General Timer
Register set to
new value
WriteRegister - In the case of GTR (General
Timer Register) determine the value at the time
of the write. Call SetupNextMatch to reschedule
match events.
Bus Write
Match Timer Register
n (MTRn)
MTRn set to
value.
WriteRegister - Write value to MTR register,
cancel any scheduled callbacks and call
SetupNextMatch to reschedule match events.
Bus Write
Timer Enable Register
(TER)
Enable or
disable MTRn
depending on
value written
WriteRegister - In the case of TER change
value of register, clear corresponding interrupts
(ClearMatchInterrupts), call SetupNextMatch
to reschedule match events.
Bus Write
Timer Interrupt Enable
Register (TIER)
Enable or
disable interrupt
n depending on
value written
WriteRegister - In the case of TIER change
value of register, clear corresponding interrupts
(ClearMatchInterrupts), call SetupNextMatch
to reschedule match events.
Bus Write
Timer Interrupt Flag
(TIFR)
Enable or
disable interrupt
n depending on
value written
WriteRegister - In the case of TIFR change
value as required and deassert corresponding
interrupt ports (ClearMatchInterrupts). Call
SetupNextMatch to reschedule match events.
Unmatch (MTR
(Match Timer
Register) equal to
General Timer
register). Note that
this takes place one
click tick after a
Match.
Prepare for next
match
UnMatch - Callback scheduled by Match
function. Schedule next match event.