Download presentation
Presentation is loading. Please wait.
1
Ranjit S. Mann Exam 1 CSE-670 Day OF Week
2
Day OF Week int dayofweek (int year, int month, int day) { int a = (14 - month)/12; int y = year - a; int m = month + 12*a -2; return (day + y + y/4 - y/100 + y/400 + (31*m)/12) % 7; } /* 0 = Sunday, 1 = Monday, 2 = Tuesday, 3 = Wednesday, 4 = Thursday, 5 = Friday, 6 = Saturday */ Ranjit S. Mann
3
DATA PATH SW(1 to 8) 8 demux4g regb dayrega monthregc year 8 8 8 aloadbloadcload yearin monthin dayin rege yregf dayfloadeloadregg moutgloadregh monthhload a = (14 - month)/12 m= month+12*a-2 (31*m)/12 mout (day + y/4 - y/100 + y/400 + m) % 7 mux4g m1sel d1msel binbcd x7seg 8 8 8 8 8 a monthcalc m mout month day year dayOFweek r16 3 2 1 0 d y Note: century value is fixed at 2000 m
4
Controller controller datapath Sw1… Sw8 aload bload cload eload fload gload hload d1msel month day year dayOFweek mux4g binbcd x7seg
5
State Machine sA sB sC sD sE sF sG s0 s1 s2 s3 1 Wait for BTN4 down month <= SW display month 0 Wait for BTN4 up 0 1 1 0 0 1 Wait for BTN4 down day <= SW display day Wait for BTN4 up 1 Wait for BTN4 down year<= SW display year 0 0 1 0 1 Wait for BTN4 up a = (14 - month)/12 m= month+12*a-2 mout =(31*m)/12 (day + y/4 - y/100 + y/400 + mout) % 7 0/1 display dayOFweek
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.