140 likes | 417 Views
A Case Study. This case study is about specifying a video recorder ;. This Unit defines: underlying functionality “plumbing” together components dates (example of schema disjunction). Tutorial 3 is on extending this specification. +. Modulator mod_ch?. Tuner tune_ch?. Record.
E N D
A Case Study This case study is about specifying a video recorder; • This Unit defines: • underlying functionality • “plumbing” together components • dates (example of schema disjunction) • Tutorial 3 is on extending this specification.
+ Modulator mod_ch? Tuner tune_ch? Record Play Tape Tape Video recorder: basic functionality Antenna RF = Radio Frequency – all channels together RF RF RF YUV Sound • YUV Sound = Picture + Sound for a single channel • mod_ch?: channel on which recorder output is added to RF signal. • tune_ch?: channel that recorder is tuned to. YUV Sound
Terminology Two kinds of signals: RF and YUVSound. • RF (Radio Frequency) signal: • as picked up by antenna • also needed by the TV • contains all the channels. • Physical Channel: frequency band, numbered between 21 and 69. • YUVSound signal: information for a single channel • as used for tape deck • 4 information components: 3 for colour picture, 1 for sound • Tuner converts RF to YUVSound • selects signal for a given channel “tune_ch?” and extracts YUVSound information
Hardware specification • Can describe inputs and outputs for components. • Sorts – • RFsig for RF signal • YUVsig for YUVSound signal • CHAN = {n:N | 21 n 69} for physical channels • TAPE for tape signals • Expressions • empty: YUVsig for absent signal • s[ch]: YUVsig (s: RFsig, ch:CHAN) for signal on s at channel ch • sig(t): YUVsig (t:TAPE) YUVSound signal stored on tape
Tuner tuner_in?: RFsig tune_ch?: CHAN tuner_out!: YUVsig tuner_out! = tuner_in?[tune_ch?] Modulator mod_ch? Modulator mod_in?: YUVsig mod_ch?: CHAN mod_out!: RFsig mod_out![mod_ch?] = mod_in? "ch:CHAN. (ch mod_ch? mod_out![ch] = empty) mod_out! mod_in? Specifying components tuner_in? Tuner tune_ch? tuner_out!
Record (ignores detail about position of tape) rec_in?: YUVsig rec_out!: TAPE sig(rec_out!) = rec_in? Mix mix_in1?, mix_in2?, mix_out!: RFsig "ch:CHAN. ((mix_in1?[ch] = empty mix_out![ch] = mix_in2?[ch]) (mix_in2?[ch] = empty mix_out![ch] = mix_in1?[ch])) rec_in? play_out! Record Play rec_out! play_in? Play play_in?: TAPE play_out!: YUVsig play_out! = sig(play_in?) Mix mix_in1? mix_out! mix_in2?
Idle antenna?, TV!: RFsig Tuner Modulator Mix tuner_in? = mix_in1? = antenna? tuner_out! = mod_in? mod_out! = mix_in2? mix_out! = TV! Recording Idle Record rec_in? = tuner_out! Mix Tuner Modulator Record Mix Tuner Modulator Plumbing Can specify how components are connected together: Exercise: what are connections for playback?
Timer mode v. manual mode • Need to avoid conflict between recording and playback. • Assume machine has two modes: • Timer mode • Will record automatically according to recording schedule. It needs specifications of • time • schedule of programs • internal timer tick operation • Manual mode • Can record or play back under manual control. • Ignores recording schedule.
Dates month_lengths = {(1,31), (2,28), (3,31), (4,30), (5,31), (6,30), (7,31), (8,31), (9,30), (10, 31), (11, 30), (12, 31)} NormalDate d,m,y: N $n:N. ((m,n) month_lengths 1 d n) Feb29 d,m,y: N d = 29 m = 2 (y mod 4 = 0 y mod 100 0) y mod 400 = 0 Date = NormalDate Feb29
TomorrowNewYear DDate d = 31 m = 12 d' = 1 m' = 1 y' = y+1 TomorrowSameMonth DDate d' = d+1 m' = m y' = y TomorrowNewMonth DDate (m,d) month_lengths m 2 m 12 d' = 1 m' = m+1 y' = y Tomorrow Note: Axioms in Date and Date' ensure that both days are valid.
TomorrowMar1Non-leap DDate d = 28 m = 2 d' = 1 m' = 3 y' = y y mod 4 0 (y mod 100 = 0 y mod 400 0) TomorrowFeb29 DDate Feb29' d = 28 m = 2 y' = y TomorrowMar1Leap DDate Feb29 d' = 1 m' = 3 y' = y Tomorrow = TomorrowSameMonth TomorrowNewMonth TomorrowFeb29 TomorrowMar1Non-leap TomorrowMar1Leap TomorrowNewYear
Day1BeforeDay2 Date1 Date2 d1 < d2 m1 = m2 y1 = y2 MyBefore stat.Date stop.DateDay1BeforeDay2 [Date1/start.Date, Date2/stop.Date] Substitution Will might need to substitute variables in schema. Assume the schema Date given in slide 9. • Consider the following schema: • Consider “start.” and “stop.” as decorations. • Day1BeforeDay2 [Date1/start.Date, Date2/stop.Date] • Axioms of Day1BeforeDay2 but with d1 substituted with start.d d2 substituted with stop.d, m1 substituted with start.m, ect…