Upload
hilmi92
View
215
Download
0
Embed Size (px)
Citation preview
8/10/2019 Date Display Subsystem
1/6
1
Date Display Subsystem
Mohd Zulhilmi Bin Ramli
Universiti Teknologi MalaysiaFaculty of Electrical Engineering
Abstract - In a standard calendar system, the number of
days in a month is either 28, 29, 30 or 31. For example, the
number of days for February is 28 for common year and
29 for leap year. In this project, a system which can
determine the number of days in a month and whether a
given year is a leap year is designed. Leap years are all the
years divisible by 4, except that years divisible by 100 are
not leap years. Years divisible by 400 are also leap years.
As an example, the year 1900 is not a leap year because it
is divisible by 100 but not divisible by 400.
1. INTRODUCTION
Leap Years are needed to keep our calendar in alignment
with the Earth's revolutions around the sun. It takes the Earth
approximately 365.242199 days or 365 days, 5 hours, 48
minutes, and 46 seconds (a tropical year) to circle once
around the Sun. However, the Gregorian calendar has only
365 days in a year, so if we didn't add a day on February 29
nearly every 4 years, we would lose almost six hours off our
calendar every year. After only 100 years, our calendar would
be off by approximately 24 days [1].
In this project, a calendar system is designed so that it
should be able to display the number of days using two 7-
segment displays and a red LED to show whether the given
year is leap year or not. The month number is set by four
toggle switches according to binary number system. The 4-
digit year is represented in BCD number format, and is set
using 14 toggle switches. The 14 toggle switches is called as
YM2YM1 (millennium digit - assume YM8 and YM4 are
tight to logic 0), YH8YH4YH2YH1 (hundredth digit),
YT8YT4YT2YT1 (tenth digit), YO8YO4YO2YO1 (ones
digit). After the month and year values have been set, the
system will display the number of days on two 7-segment
displays and a red LED if the year is a leap year.
In example if the 14 toggle switches is set to
01100110010010 which is represent 1992 in decimal, the red
LED will light on indicating the year is a leap year. If the
remaining 4 toggle switches is set to respective month in
binary, it will shows the number of days in the particular
month. If it was set to 0010 which is February, the 7-segment
displays will show 29. This imply that February is the leap
month. However in this project the leap month is swapped
with March. That mean when 0011 is entered, it will shows 29
if the year is leap year.
2. MATERIALS AND METHOD
The very first step in designing this system is identify the
input and output of the system.
Figure 1: Input Output Diagram of the System
The figure above show the IOBD of the system. From the
diagram there are 14 inputs of the system, 10 inputs for the
Year and 4 inputs for the Month. Since this is combinationa
circuit, no clock is needed.
Next, a truth table based on the condition for the leap to
occur is constructed. According to the condition, a leap year is
occurred if the year is divisible by 4. However, if the year is
divisible by 100 and not divisible by 400, that particular year
is not a leap year. Therefore, there is 3 set of rules need to be
designed for the condition to meet.
The first set of rule is need to detect numbers 0, 4, 8 for
LSB digit, and numbers 2, 6. Need to detect whether tens digit
(the next LSB digit) is even or odd.
LED
Days
Year
Month
Date
Display
Subsystem
8/10/2019 Date Display Subsystem
2/6
2
Next, the truth table for the month entered producing
output of the number of the days is designed. For each month
entered, the 7-segment display will shows the number of day
at that particular month. In example, if the input for month is
entered as 0001, the output will be 31, indicating January has
31 days.
From the first rule, the obtained logic gates is as follow:
Y08 Y04 Y02 Y01 F1
0 0 0 0 1
0 0 0 1 0
0 0 1 0 0
0 0 1 1 0
0 1 0 0 1
0 1 0 1 0
0 1 1 0 0
0 1 1 1 0
1 0 0 0 1
1 0 0 1 0
1 0 1 0 0
1 0 1 1 0
1 1 0 0 01 1 0 1 0
1 1 1 0 0
1 1 1 1 0
Table 1: 0, 4, 8
Y08 Y04 Y02 Y01 F2
0 0 0 0 1
0 0 0 1 0
0 0 1 0 1
0 0 1 1 0
0 1 0 0 1
0 1 0 1 0
0 1 1 0 10 1 1 1 0
1 0 0 0 1
1 0 0 1 0
1 0 1 0 0
1 0 1 1 0
1 1 0 0 0
1 1 0 1 0
1 1 1 0 0
1 1 1 1 0
Table 2: Even 2nd
LSB
Y08 Y04 Y02 Y01 F3
0 0 0 0 00 0 0 1 0
0 0 1 0 1
0 0 1 1 0
0 1 0 0 0
0 1 0 1 0
0 1 1 0 1
0 1 1 1 0
1 0 0 0 0
1 0 0 1 0
1 0 1 0 0
1 0 1 1 0
1 1 0 0 0
1 1 0 1 0
1 1 1 0 0
1 1 1 1 0
Table 3: 2, 6
Y08 Y04 Y02 Y01 F4
0 0 0 0 00 0 0 1 1
0 0 1 0 0
0 0 1 1 1
0 1 0 0 0
0 1 0 1 1
0 1 1 0 0
0 1 1 1 1
1 0 0 0 0
1 0 0 1 1
1 0 1 0 0
1 0 1 1 0
1 1 0 0 0
1 1 0 1 01 1 1 0 0
1 1 1 1 0
Table 4: Odd 2nd
LSB
Figure 2: Logic equivalent of first rule
The second rule is obtained as follow:
Y08 Y04 Y02 Y01 F5
0 0 0 0 1
0 0 0 1 0
0 0 1 0 0
0 0 1 1 0
0 1 0 0 0
0 1 0 1 0
0 1 1 0 0
0 1 1 1 0
1 0 0 0 0
1 0 0 1 0
1 0 1 0 0
1 0 1 1 0
8/10/2019 Date Display Subsystem
3/6
3
1 1 0 0 0
1 1 0 1 0
1 1 1 0 0
1 1 1 1 0
Table 5: Divisible by 100
Figure 3: Logic equivalent of second rule
The third rule is obtained by using similar step as
Divisible by 4, but this time the output is AND with Divisible
by 100.
Figure 4: Logic equivalent of the third rule
According to the condition, a leap year is occurred if the
year is divisible by 4. However, if the year is divisible by 100
and not divisible by 400, that particular year is not a leap year.
Combining all these rules resulting the following output:
Figure 5: The leap logic
If the year is leap year, the Leap output will become 1,
turning the LED on. Else, the output is 0.
Next, the Leap output is combined with the input of the
Month. The truth table is constructed. For this project, we
swapped February with March.
A3 A2 A1 A0 D4 D3 D2 D1 D0
0 0 0 0 0 0 0 0 0
0 0 0 1 1 1 1 1 1
0 0 1 0 1 1 1 1 1
0 0 1 1 1 1 1 0 0 (1)
0 1 0 0 1 1 1 1 0
0 1 0 1 1 1 1 1 1
0 1 1 0 1 1 1 1 0
0 1 1 1 1 1 1 1 1
1 0 0 0 1 1 1 1 1
1 0 0 1 1 1 1 1 01 0 1 0 1 1 1 1 1
1 0 1 1 1 1 1 1 0
1 1 0 0 1 1 1 1 1
1 1 0 1 0 0 0 0 0
1 1 1 0 0 0 0 0 0
1 1 1 1 0 0 0 0 0
Table 6: Month and its respective number of days
The output with the bracket indicates that month is leap
month. The equivalent logic gates is as follow.
Figure 6: Input for month
8/10/2019 Date Display Subsystem
4/6
4
The output D4 to D0 is represented in BCD. Before this
output is connected to 7-segment display, it first split into
single digit.
Leap D2 D1 D0 O3 O2 O1 O0
0 0 0 0 0 0 0 0
0 0 0 1 0 0 0 0
0 0 1 0 0 0 0 0
0 0 1 1 0 0 0 0
0 1 0 0 1 0 0 0
0 1 0 1 1 0 0 1
0 1 1 0 0 0 0 0
0 1 1 1 0 0 0 1
1 0 0 0 0 0 0 0
1 0 0 1 0 0 0 0
1 0 1 0 0 0 0 0
1 0 1 1 0 0 0 0
1 1 0 0 0 0 0 0
1 1 0 1 0 0 0 0
1 1 1 0 0 0 0 0
1 1 1 1 0 0 0 0
Table 7: Splitting Month output to BCD for LSB
From the table, the desired output is only 28, 29, 30 and
31. However, for 29, it is interchanged during leap year,
separated by multiplexer.
Figure 7: BCD output
Figure above is the final output of the system. It is
attached to 7446 BCD to 7-segment display so the display can
show the correct numbers. The mux input is only attached to
IN0 and IN1 because the rest of the input is not needed.
After the system is successfully implemented, the system
is compiled in Quartus II.
Figure 8: Compilation result
After the compilation, the system is assigned with the pin
provided by the board. In this project, Altera DE2 FPGA
which is using Cyclone II chip is used [2].
Figure 9: Pin Assignment
After completed the pin assignment, the project is
recompiled. When compilation is completed, the project is
8/10/2019 Date Display Subsystem
5/6
5
uploaded into the board using build in programmer. Final step
is the system is tested on the board.
3. RESULT
The board is tested by set the year and the month. Both
leap and non-leap year is tested.
Figure 10: Leap year and February days
Figure 11: Leap year and March days
Figure 12: leap year and June days
From the figure above, the year is set to leap year and the
LED is light on indicates the year is leap. Figure 10 shows
February, showing 31 days. Figure 11 is March, has 29 days
because it is leap month and finally figure 12 is June, has 30
days.
Figure 13: Non-leap year and June days
8/10/2019 Date Display Subsystem
6/6
6
Figure 14: Non-leap year and March days
Figure 15: Non-leap year and January days
From the figure above, the year is set to non-leap year and
the LED is light off indicates the year is non-leap. Figure 13
shows June, showing 30 days. Figure 14 is March, has 28 days
because it is non-leap month and finally figure 15 is January,
has 31 days.
4. DISCUSSION
Figure 10, 11, and 12 show a leap year indicator on
because it met the condition the system imposed which is
All year divisible by 4 is leap year, except for the year
that divisible by 100 but not divisible by 400.
The year in those figure is 2000. Comparing it to the
conditions, 2000 is divisible by 4. It also divisible by both 100
and 400. Therefore the year is a leap year.
For figure 13, 14 and 15, the leap year indicator is off
because the year set is not a leap year, which is 2001. This is
due to 2001 is not divisible by 4.
For the number of day, referring to Table 6 and Figure 6
the input is valid only from 1 to 12. Any than that will yield 0.
From figure 10, the input for month is 0010. Looking back at
the truth table in Table 6, it will give output of 11111, which is
31 in decimal. The rest of the month will give it respective
days, as in Table 6. Exception is during leap year, where the
output for last bit of number of day is interchanged if the year
is leap year. For example, during non-leap year, March last bi
is 0. However during leap year, the 0 is interchanged with 1
using multiplexer.
5.
CONCLUSION
From the result, it can be concluded that the system
designed successfully emulate the Date Display Subsystem
with Leap Year Indicator. For any year is inserted, the system
will automatically detect whether the system is leap year or
not and for any month inserted, it also display the number o
month in that particular month.
6.
REFERENCE
[1] http://www.timeanddate.com/date/leapyear.html
[2] Dr. Rabia Bakhteri, VLSI System Design Lab,
Faculty of Electrical Engineering, Universiti
Teknologi Malaysia, 2014
http://www.timeanddate.com/date/leapyear.htmlhttp://www.timeanddate.com/date/leapyear.htmlhttp://www.timeanddate.com/date/leapyear.html