Presentation is loading. Please wait.

Presentation is loading. Please wait.

MIPS interrupt continued

Similar presentations


Presentation on theme: "MIPS interrupt continued"— Presentation transcript:

1 MIPS interrupt continued

2 Let’s use this lecture to start to develop a simple TV controller together.
What is left should be finished in homework 4.

3 TV controller It accepts simple commands like vol+/-, channel +/-, channel digit input (0-99), sleep timer, and power on/off. When there is no input, roughly every 3 seconds, print out the current state of the TV, in the format of Current second, Power On (of Off), Channel (current channel watching), volume (current volume), Sleep timer remaining. For example, “At 100 second, Power On, Channel 10, Volume 30, sleep timer 120 sec remaining.” If power is off, only output “At 100 sec, Power off.”

4 I didn’t find a timer facility in SPIM, so the time is approximated using delay loops.

5 Specifications Initialization. When the code is run, the initial state is Power on Channel 0 (0-99) Volume 50 (0-99) Sleep timer off

6 Specifications Power key (should be ‘p’ on the key board)
When power key is pressed, if the power is currently off, turn on the TV immediately by printing “Power On!” When power key is pressed, if the power is currently on, turn on the TV immediately by printing “Power Off!”

7 Specification Channel +/-. Should use ‘u’ as + and ‘d’ as -. Once pressed, change the current watching channel accordingly (but not out of range of 0-99), and print out, for example, “Channel 30.”

8 Specifications Vol +/-. Should use ‘l’ as + and ‘k’ as -. Once pressed, change the current volume accordingly (but not out of range of 0-99), and print out, for example, “Volume 30.”

9 Specification Digit input. Use 0-9 key on key board. Used to change channels. Once a digit key is pressed, print out the intended channel immediately. For example, `1’ is pressed, print out “1-” immediately. The controller should be expecting another digit input for another 2 seconds. If any other key is pressed during these two seconds, abort the digit input. For example, if `1’ is pressed at 1000 second and `channel +’ is pressed at 1001 second, the controller should perform the channel + function and “forget” about the digit input. If no other key is pressed during the two seconds, the controller switches to channel 1. If another digit key is pressed within the two seconds, for example, `2’ is pressed, the controller switches to channel 12 immediately.

10 Specifications Sleep timer. Should use ‘s’ key on the keyboard.
When sleep timer key is pressed, if the sleep timer is off, set the sleep timer to be 10 sec. If the sleep timer is on, increment the sleep timer by 10 sec. If after that the sleep timer exceeds 200 sec, set the sleep timer to be off. Show the status of the sleep timer after processing the input immediately. If the sleep timer is on, it decrements by 1 every second. Once it becomes 0, turn the TV off immediately and print out “Power Off Due To Sleep Timer!”

11 Structure of the main loop
Check for new key board input and process the input. If power is on, check if sleep timer hits 0. Loop for 0.01 second. Print out the status if 3 seconds elapsed since last status print. Jump to the beginning of the loop.


Download ppt "MIPS interrupt continued"

Similar presentations


Ads by Google