50 likes | 248 Views
Ranjit S. Mann Exam 1 CSE-670 Day OF Week. 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; }
E N D
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
DATA PATH SW(1 to 8) 8 d1msel yearin demux4g monthin 8 8 dayin 8 cload regc year bload regb day rega month aload eload rege y fload regf day gload regg mout hload regh month y 8 d a = (14 - month)/12 mout (day + y/4 - y/100 + y/400 + m) % 7 m a monthcalc day 8 m= month+12*a-2 year 8 8 month 8 dayOFweek m 3 2 1 0 m1sel (31*m)/12 mux4g 16 r mout binbcd Note: century value is fixed at 2000 x7seg
Controller Sw1… Sw8 aload bload cload controller eload datapath fload gload hload d1msel month binbcd year day dayOFweek mux4g x7seg
State Machine 0/1 0 1 sA sF Wait for BTN4 up Wait for BTN4 down year<= SW display year s3 0 1 0 1 sB Wait for BTN4 down month <= SW display month sG Wait for BTN4 up 1 0 1 sC s0 Wait for BTN4 up 0 0 sD Wait for BTN4 down day <= SW display day display dayOFweek a = (14 - month)/12 s1 m= month+12*a-2 1 mout =(31*m)/12 1 sE s2 Wait for BTN4 up (day + y/4 - y/100 + y/400 + mout) % 7 0