Day of Week

Introduction

In this lab you will implement an algorithm to compute the day of the week given a date, month and year. Your vhdl entity will take as input integers for year, month and date and output an integer in the range of 0 to 6 for the corresponding day of the week. A start signal will initiate the computation and a done signal will signal the end of the computation. You may implement this processor using an FSMD.

Here is the algorithm:

1. Clear a variable named total.
2. Divide the last two digits of the year by 4, drop the remainder, store in total.
3. Add the last two digits of the year to total.
4. Add the date of the month to total.
5. Add the "Magic Number" for this month to total.
The magic numbers are: 1, 4, 4, 0, 2, 5, 0, 3, 6, 1, 4, 6.
6. If it is a leap year and it is January/February, subtract 1 from total.
7. Find the remainder when total is divided by 7. The remainder indicates the day of week as follows:
• 1 - Sunday
• 2 - Monday
• 3 - Tuesday
• 4 - Wednesday
• 5 - Thursday
• 6 - Friday
• 0 - Saturday

You should write a testbench to test your entity. To verify that your algorithm works, try it on today's date. Then, try it on your birth date. Did you know what day of the week you were born? When ready, demonstrate your design (code and simulation waves) to your TA.