这是一篇来自美国的关于熟悉顺序逻辑设计和仿真,将使用四英尺进行合成,并进行模拟。 你的任务是实现一个闹钟的作业代写

 

Part 1: Basic Alarm Clock

Behavior: At its simplest, an alarm clock has two functions – keeping track of the current time and buzzing when the current time matches the alarm time. We need to be able to program the alarm time and the current time. Setting the current time and setting the alarm time are very similar tasks, with similar implementations in hardware.

Keeping track of the current time is straightforward. At least in the initial formulation, we shall keep track of hours, minutes, and seconds, and leave days and dates to subsequent parts. The relationship between the three units of time is captured in Figure 1, wherein the eccentric yet subtly elegant Babylonian system of 24 hours, 60 minutes and 60 seconds which we conventionally use is described.

The buzzing part of the alarm is an equality check between the minutes and hours of the current time and the alarm time, complete with an AlarmOn switch that is used to turn the buzzer on and off, in case the user doesn’t want to be rudely awakened on a day of leisure (See switch “S5” in Figure 2 and Figure 4). The setting of the alarm time and the current time is shown in Figure 3. The user will enable the setting of the time with a pair of switches, SetCurrentTime (switch “S1”) and SetAlarmTime (Switch “S2”). If neither switch is on, the user will be unable to set either; otherwise, the user will be able to set the current time if SetCurrentTime is on, or the alarm time if SetAlarmTime is on. While the user is setting either the current time or the alarm time, a pair of switches (actually “pushbuttons”, as we will see), IncMinute (Switch “S3”) and IncHour (Switch “S4”), will be used to increment the hours and minutes, respectively.

Figure 1: Clock Tick Behavior

Structure: Now that you see the behavioral description of the alarm clock, it is time to move on to a structural description. For the purpose of this exercise, the structural description can be thought of as comprising two parts: the components used to build the clock and their interconnections.

The best way to determine the required components is to look at the behavioral description and identify functionalities that map to known hardware components. Looking at the behavioral diagram of Figure 1, one realizes that a component is needed that will keep track of the time and increment it appropriately with each passing unit of time. This component should increment the seconds on a clock pulse. When the seconds reach 59, instead of being incremented to 60, they will roll over to 0 with the minutes being incremented. Similarly, the minutes, when incremented past 59, will roll over to 0 and trigger the hours to be incremented, which will in turn roll over from 23 to 0 as necessary. For the first part of this exercise, no further increments of other counters are required upon rolling over of the hours.

The behavioral description in Figure 2 that illustrates the buzzing functionality necessitates an equality check between the current time and alarm time. This may be achieved with a simple comparator module, which can compare two 17 bit values corresponding to the alarm time and the real time.

Figure 3 illustrates the behavioral description for setting the correct time. To complete the implementation of Figures 2 and 3, you need an analogous component to set the alarm time.

Figure 2: Alarm Buzz Behavior

You will also need a MUX. A MUX, short for multiplexer, is a circuit component which acts as a “decider” among possible output alternatives. The MUX receives 2 inputs, each of which may be multiple bits, and outputs one of them based on a third input S, or “Select”. The reason for  including this component is perhaps not as evident from the behavioral description that we have provided you. One issue is that while an Alarm Clock normally would display the current time, when you are setting the alarm time, it would be necessary to have the clock display the Alarm Time so that you know how close you are getting to the desired alarm time. So, a MUX will be needed to switch between displaying the current time (most of the time) and displaying the alarm time (when the user is setting the alarm time).

Figure 3: Time and Alarm Set Behavior

SetCurrentTime and SetAlarmTime together determine the functionality that the user is interested in. In Figure 3, these two switches are modeled by S1 and S2, respectively. When both SetCurrentTime and SetAlarmTime are off (we shall use the notation “(S1, S2) = (0, 0)”), the clock should passively tick and display the current time. If (S1, S2) = (1, 0), the user should be able to set the current time (the display should show the current time). If (S1, S2) = (0, 1), the user should be able to set the alarm time (the display should show the alarm time, so that the user can see it as it changes.) (S1, S2) = (1, 1) will behave identically to (S1, S2) = (0, 0), i.e. increment neither. The selection of functionality can be implemented by using a decoder, which expands a binary input into a one-hot encoding scheme.

Now that we have taken a high-level look at the components, it’s time to guide you through their interconnections to complete our structural analysis. One way to think about it is to start from the outputs. What is the expected computation of the circuit? The final outputs of the alarm clock are supposed to be a time (typically the current time, but occasionally the alarm time) and a signal indicating the status of the buzzer. You will therefore need some LCD displays. Then, we can ask where do these display components receive information from? The LCDs, for example, must output either the current time or the alarm time depending on the switches SetCurrentTime and SetAlarmTime. Thus, the inputs of the LCD come from multiplexers which will choose between clock time and alarm time based on the system configuration. We ask ourselves again about the multiplexers: where do they receive inputs from? After mulling the question recursively, we come down to the base case at primary inputs – the clock, buttons and switches which are used to control the clock by the user.

A high-level structural schematic that embodies this discussion is presented in Figure 4.

Figure 4: Alarm Clock Structural Schematic

Figure 4 comments: 1) If Timeset (SetCurrentTime) = 0, S cnt increments on posedge Pulse. If Timeset = 1, S cnt freezes.   2) M cnt increments on posedge Pulse if Szero flag from S cnt = 1 OR if TimeSet = MinAdv (IncMinute) = 1.

Input/Output: The inputs to this simple alarm clock we’re developing are: AlarmOn, SetCurrentTime and SetAlarmTime, and the IncHour and IncMinute pushbuttons. You should also have a binary switch “Clear” hooked to the CLR inputs to be able to reset the clock. The outputs will be the current time (or alarm time) on the LCD Displays and the state of the buzzer. No additional inputs or outputs should be necessary for this device, nor should they be included.

Implementation hints:

  • Youshould use a Binary Switch to activate the alarm functionality (AlarmOn). (Refer to switch S5 in Figure 2 and Figure )
  • Youshould implement the logic that will enable the user to set the alarm time and the current  You should use two switches (Refer to switches S1 and S2 in Figure 3 and Figure 4) and a decoder component, to implement the following cases:
    • IfS1=1 and S2=0, then the user can set the current time;
    • IfS1=0 and S2=1, then the user can set the alarm time;
    • Otherwise,no user modifications to current time or alarm time take
  • There will be an output for the BUZZERthat will go high when the alarm is on, and the hours and the minutes of the clock match the alarm  If the user turns the alarm off, the BUZZER signal should go down.
  • Todisplay the time, you should be using LCD displays connected to an LCD Interface. There should be one single set of LCDs, as in our regular alarm clocks, which shows the alarm time only when we select that switch to set the alarm time. You can use a MUX to select between the

Part 1 Deliverables:

  • All of your Verilog source text (.sv) files, and a Verilog source testbench (.sv) showing correct functionality
  • Inthe pdf format report, explain how you tested your alarm clock and including:
    • A screenshot of the RTL viewer top level schematic/block diagram in Quartus
    • A screenshot of the Modelsim transcript, showing correct alarm functionality
  • Project files (mpf, qpf) and waveform view (wlf) files are not

Part 2: Days of the Week

Your next task is to extend the functionality of the alarm clock to also track and display the days of the week.  Using your expertise gained from the previous implementation of the alarm clock, you will design and implement this new feature.  You may use the original alarm clock implementation as a reference, as this feature is more of an extension of existing functionality rather than a completely unique addition.

However, our implementation of the days of the week will have one special feature.  As much of the working world follows a traditional, 5-day work week from Monday to Friday, there is much less incentive to wake up on Saturdays and Sundays.  One could simply shut off the alarm feature on Friday evening, but this runs the inherent risk of forgetting to turn it back on before Monday! Your implementation of the alarm clock will remove the risk of user error by automatically disabling the alarm on weekends (Saturday and Sunday), overriding whether the alarm is turned on or not by the user.

With additional information to be tracked, you will likely need to modify the existing modules that track the current time and the alarm time.  Analogous to how the minutes increment when the seconds roll over and the hours increments when the minutes roll over, you will need to have a counter for the day of the week that increments when the hours roll over.

Implementation hints:

  • The days of the week will be denoted by numbers 0-6, with 0 corresponding to Monday, through 6 corresponding to Sunday.
  • The alarm will never buzz on Saturdays (day 5) or Sundays (day 6), regardless of whether the alarm is enabled or not.
  • You will need to add LCD displays to also show the day of the week.  The display should show the numerical number of the day of the week (0 for Monday and 6 for Sunday).  Only a single digit display is necessary.
  • The day of the week should be able to be set independently for the current time, similarly to how the hours and minutes may be set.
  • The day of the week does not need to be set for the alarm functionality, since the alarm will activate for all days of the week, except Saturday and Sunday.
  • The testbench from Part 1 should be extended to also test for the days of the week functionality.

Part 2 Deliverables:

  • A set of all necessary Verilog files separate from the files for Part 1.
  • An expanded testbench that covers and checks the day of the week functionality
  • A summary report explaining day of the week enhanement and including
    • A screenshot of the RTL viewer schematic in Quartus
    • A screenshot of the Modelsim transcript, showing correct day of the week functionality

 

Part 3 Deliverables:

Those aspiring for an A in this course should add  a date and month function. These are counters that increment every time the hour rolls over from 23 back to 0. The challenge is that the day counter will be modulo 28, 30, or 31, depending on the current value of the month counter.