Alarm Clock Example - PowerPoint PPT Presentation

1 / 8
About This Presentation
Title:

Alarm Clock Example

Description:

... are equivalent and alarmOn is set, the alarm should be sounded. ... Alarm Clock. use time_types; facet alarmClockStruct() is. timeIn, displayTime:: time; ... – PowerPoint PPT presentation

Number of Views:109
Avg rating:3.0/5.0
Slides: 9
Provided by: csAdela
Category:
Tags: alarm | clock | example

less

Transcript and Presenter's Notes

Title: Alarm Clock Example


1
Alarm Clock Example
  • Kylie Williams

2
The Alarm Clock Example
  • When the setTime bit is set, the timeIn is stored
    as the clockTime and output as the display time
  • When the setAlarm bit is set, the timeIn is
    stored as the alarmTime and output as the display
    time
  • When the alarmToggle bit is set, the alarmOn bit
    is toggled
  • When clockTime and alarmTime are equivalent and
    alarmOn is set, the alarm should be sounded.
    Otherwise it should not.
  • The clock ncrements its time value when time is
    not being set.

3
Mux
  • use time_types
  • facet mux(timeInin time displayTimeout time
  • clockTimein time
    setAlarmin boolean setTimein boolean) is
  • begin state_based
  • l1 if setAlarm true then displayTime'
    timeIn
  • l2 if setTime true then displayTime'
    timeIn
  • l3 if not (setTime or setAlarm) then
    displayTime' clockTime
  • end mux

4
Store
  • use time_types
  • facet store(timeInin time setAlarmin
    boolean setTimein boolean
  • toggleAlarmin boolean
    clockTimeout time
  • alarmTimeout time
    alarmOnout boolean) is
  • begin state_based
  • l1 if setAlarm true
  • then alarmTime' timeIn
  • else alarmTime' alarmTime
  • endif
  • l2 if setTime true
  • then clockTime' timeIn
  • else clockTime' clockTime
  • endif
  • l3 if toggleAlarm true
  • then alarmOn' -alarmOn
  • else alarmOn' alarmOn
  • endif
  • end store

5
Counter
  • use time_types
  • facet counter(clockTimeinout time) is
  • begin state_based
  • l4 clockTime' increment-time(clockTime)
  • end counter

6
Comparator
  • use time_types
  • facet comparator(alarmOnin boolean alarmTime
    in time
  • clockTimein time
    alarmout boolean) is
  • begin state_based
  • l1 if (alarmOn true and (alarmTime
    clockTime)) then
  • alarm' true
  • else alarm false
  • end comparator

7
Alarm Clock
  • use time_types
  • facet alarmClockStruct() is
  • timeIn, displayTime time
  • alarm, setAlarm setTime, alarmToggle
    boolean
  • clockTime, alarmTime time
  • alarmOn boolean
  • begin logic
  • store_1 store(timeIn, setAlarm, setTime,
    alarmToggle, clockTime,
  • alarmTime, alarmOn)
  • counter_1 counter(clockTime)
  • comparator_1 comparator(setAlarm, alarmTime,
    clockTime, alarm)
  • mux_1 mux(timeIn, displayTime, clockTime,
    setAlarm, setTime)
  • end alarmClockStruct

8
How might this be verified?
Write a Comment
User Comments (0)
About PowerShow.com