CSE 140L

Lab 1 Digital Alarm Clock

Due October 14th, 2024

Part 1

Conventional Alarm Clock

Conventional Alarm Clock

Behavioral Description:

  • Adjustable clock and alarm time
  • Seven segment display
    • Displays the alarm time when adjusting the alarm
    • Displays the current time in all other cases
  • Toggleable alarm
  • Alarm rings when the time matches the set alarm minutes and hours

Conventional Alarm Clock

                flowchart LR
                    A[Wait 1s]
                    B["seconds = seconds + 1"]
                    C{seconds ≥ 59?}
                    C1["seconds = 0"]
                    D["minutes = minutes + 1"]
                    E{minutes ≥ 59?}
                    E1["minutes = 0"]
                    F["hours = hours + 1"]
                    G{hours ≥ 23?}
                    G1["hours = 0"]


                    A --> B
                    B --> C
                    C -->|No| A
                    C -->|Yes| C1
                    C1 --> D
                    D --> E
                    E -->|No| A
                    E -->|Yes| E1
                    E1 --> F
                    F --> G
                    G -->|No| A
                    G -->|Yes| G1
                    G1 --> A

                    class B,C1,D,E1,F,G1 smallerText
                    classDef smallerText font-size:5px
              
Behavioral Clock Diagram

Conventional Alarm Clock

                flowchart LR
                    A[Wait 1s]
                    A1[BUZZ = 0]
                    B{minutes == alarm_minutes?}
                    C{hours == alarm_hours?}
                    D{ALARM_EN == 0?}
                    E[BUZZ = 1]


                    A --> B
                    B -->|Yes| C
                    B -->|No| A1
                    C --> |Yes| D
                    C --> |No| A1
                    D -->|Yes| E
                    D -->|No| A1
                    E --> A

                    A1 --> A
              
Behavioral Alarm Diagram

Conventional Alarm Clock

              flowchart LR
                  A{SETUP_TIME == 1?}
                  A1{SETUP_ALARM == 1?}
                  A2{SETUP_ALARM == 1?}
                  B{MIN_ADV ⎽⎽/⎺⎺ ?}
                  B1{MIN_ADV ⎽⎽/⎺⎺ ?}
                  C["minutes = minutes + 1"]
                  C1["alarm_minutes = alarm_minutes + 1"]
                  D{HR_ADV ⎽⎽/⎺⎺ ?}
                  D1{HR_ADV ⎽⎽/⎺⎺ ?}
                  E["hours = hours + 1"]
                  E1["alarm_hours = alarm_hours + 1"]

                  A -->|No| A1
                  A -->|Yes| A2

                  subgraph alarm [setting alarm]
                  A1 -->|Yes| B1 & D1
                  A1 -->|No| G["Do Nothing"]
                  B1 --> C1
                  D1 --> E1
                  end 

                  subgraph time [setting time]
                  A2 -->|No| B & D
                  A2 -->|Yes| F["Not possible"]
                  B -->|No| C
                  D -->|No| E
                  end

                  time & alarm -->|After Operation| A
              
Behavioral Setup Diagram

Part 2

French Republican Alarm Clock

French Republican Alarm Clock

  • French Republican Calendar was created during the French Revolution
  • Used by the French government for ~12 years (1793 to 1805)
  • Highly regular, decimal based

French Republican Alarm Clock

Behavioral Description

  • Operation is similar to conventional alarm clock
  • Time scale
    • 100 seconds in a minute
    • 100 minutes in a hour
    • 10 hours in a day
    • 10 days in a week
    • 3 weeks in a month
    • 12 months in a year
  • 5 days are an end-of-the-year holiday
    • 6 days on leap years
    • These are called complementary days
  • Only keep track of hours, minutes, and seconds for this part

Implementation of a Clock

Part 3

French Republican Calendar

French Republican Calendar

Behavioral Description

  • Alarm clock should now keep track of years, months, and days as well
  • Alarm clock should buzz when months, weeks, days, hours, and minutes match; not years
  • Accounting for the complementary days is extra credit

French Republican Calendar

Handling complementary days

  • Complementary days are the 5 extra days in a year (6 for a leap year)
  • Keep track of the extra days by creating a 13th month
  • Need to rollover the 13th month after 5-6 days (depending on leap year)
  • Leap years satisfy:
     year mod 4 = 3 

French Republican Calendar

Hint

  • Leap years will always have what value in the last two LSB?
  • At which point do you roll over the 13th month and what affects that logic?