HW4.

Slides:



Advertisements
Similar presentations
1 Lecture 3: MIPS Instruction Set Today’s topic:  More MIPS instructions  Procedure call/return Reminder: Assignment 1 is on the class web-page (due.
Advertisements

CS/COE0447 Computer Organization & Assembly Language
Branches Two branch instructions:
CDA 3100 Recitation Week 8. Question 1.data A:.word 21,3,2,9,100,22,6,15,33,90.text.globl main main: la $a0, A li $a1, 17 li $a2, 10 jal funct li $v0,
Lecture 9: MIPS Instruction Set
CDA 3100 Recitation Week 15. What does the function f1 do:.data A:.word 10,21,45,8,100,15,29,12,3,19 B:.word 2,5,33,5,20,1,53,52,5,5 C:.word 6,8,5,4,5,22,53,12,33,89.text.globl.
1 Procedure Calls, Linking & Launching Applications Lecture 15 Digital Design and Computer Architecture Harris & Harris Morgan Kaufmann / Elsevier, 2007.
SPRING 2015 QtSpim Demo & Tutorial. 2 By DGP Outline How to write your own MIPS assembly language program How to use QtSpim simulator.
SPIM and MIPS programming
Syscall in MIPS Xinhui Hu Yuan Wang.
MIPS Function Continued
Ch. 8 Functions.
Input and Output CS 215 Lecture #20.
.text fact: addiu $sp, $sp, -32 sw $ra, 20($sp) sw $fp, 16($sp) addiu $fp, $sp, 28 sw $a0, 0($fp) bgtz $a0, L2 li $v0, 1 b suffix L2: addi $a0, $a0,
Writing an Embedded Controller. It usually consists of two parts – Initialization – A main loop Experience: – The main loop usually has to deal with many.
ECE 0142 Recitation #5.
Assembly Process. Machine Code Generation Assembling a program entails translating the assembly language into binary machine code This requires more than.
Feb 18, 2009 Lecture 4-2 instruction set architecture (Part II of [Parhami]) MIPS encoding of instructions Spim simulator more examples of MIPS programming.
CSCE 212 Quiz 2 – 2/2/11 1.What is the purpose of the jal instruction? 2.What are the two conditional branching (if, goto; not the slt instruction) instructions.
Writing an Embedded Controller. It usually consists of two parts – Initialization – A main loop More challenging than HW3 because HW3 is stateless, the.
MIPS I/O and Interrupt. SPIM I/O and MIPS Interrupts The materials of this lecture can be found in A7-A8 (3 rd Edition) and B7-B8 (4 th Edition).
Writing an Embedded Controller. It usually consists of two parts – Initialization – A main loop More challenging than HW3 because HW3 is stateless, the.
MIPS I/O and Interrupt. .data val1:.float 0.6 val2:.float 0.8 msg_done:.asciiz "done\n".text.globl main main: li.s $f0, mfc1 $a0, $f0 jal calsqrt.
April 23, 2001Systems Architecture I1 Systems Architecture I (CS ) Lecture 9: Assemblers, Linkers, and Loaders * Jeremy R. Johnson Mon. April 23,
Subroutines, parameters and the stack Bryan Duggan.
Lecture 10: MIPS Simulator Today’s topic –SPIM Simulator Readings –Appendix B 1.
MIPS I/O and Interrupt.
Lecture 161 Lets examine a SPIM program in detail. io.asm This program is a simple routine which demonstrates input/output using assembly code. SPIM.
HW4. A TV controller Let’s use this lecture to start to develop a simple TV controller together.
EE 3755 Datapath Presented by Dr. Alexander Skavantzos.
Addressing Modes. Register Addressing Immediate Addressing Base Addressing Indexed Addressing PC-Relative Addressing.
The Assembly Process Computer Organization and Assembly Language: Module 10.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patterson and Hennessy Text.
CS 312 Computer Architecture & Organization
MIPS Assembly Language Programming
MIPS Instruction Set Advantages
Introduction to Lab #1 José Nelson Amaral.
Writing an Embedded Controller
MIPS I/O and Interrupt.
MIPS instructions.
Lab Find Live CMPUT 229.
MIPS I/O and Interrupt.
MIPS I/O and Interrupt.
MIPS Procedures.
MIPS Functions.
MIPS coding.
MIPS Functions.
While Loops and If-Else Structures
Instruction encoding The ISA defines Format = Encoding
MIPS coding.
Review.
MIPS interrupt continued
While Loops and If-Else Structures
While Loops and If-Else Structures
MIPS function continued
Компьютерийн зохион байгуулалт, ассемблер CS201
MIPS Functions.
While Loops and If-Else Structures
MIPS Coding.
MIPS I/O and Interrupt.
While Loops and If-Else Structures
Writing an Embedded Controller
Review.
While Loops and If-Else Structures
Program Assembly.
ECE 352 Digital System Fundamentals
While Loops And If-Else Structures
CS 286 Computer Architecture & Organization
MIPS function continued
MIPS Functions.
Presentation transcript:

HW4

A TV controller Let’s use this lecture to start to develop a simple TV controller together.

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.”

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

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

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!”

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.” Allows wraparound.

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.” Do not allow wraparound.

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.

Specifications Sleep timer. Should use ‘s’ key on the keyboard. When hitting the sleep timer key, at the first time, do not change the status of the sleep timer and just show the current status. If the sleep timer key is pressed again within 3 seconds, then starts to modify the status of the sleep timer. That is, if the sleep timer is off, set the sleep timer to be 5 sec. If the sleep timer is on, increment the sleep timer by 5 sec. If the sleep timer exceeds 200 sec after the increment, set the sleep timer to be off. 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!”

View history The “View history” key. When pressed, print out the most watched 5 channels in a descending order. The channel is ordered according to the total amount of seconds this channel is watched since the TV is turned on. The time must be stored as single precision floating number.

Extra credits -- “Go-back” key The “Go-back” key (the `b’ key on the keyboard). When pressed, the TV should automatically switch back to current channel after 10 seconds. That is, if you pressed the “Go-back” key when watching channel 10 at time 1000 sec, at time 1010 sec, the TV should automatically go back to channel 10, regardless of what channel you are in.

Extra credit – Keyboard input with Interrupt Use the interrupt to implement the keyboard input function. Basically, you may use the interrupt to capture the input key value and write it to a register only for this purpose. In this assignment, let’s reserve $s7 for this. $s7 should be initialized with some impossible value such as 100000. You main loop should be constantly checking $s7, and if it is storing some value that is within 0-255, it means that the interrupt has written a value to it. The main loop should then reset it to be the impossible value.

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.

.data msg_tvworking: .asciiz "tv is working\n" .text .globl main main: li $s0, 300 mainloop: # 1. get external input, and process it lui $t0, 0xFFFF lw $t1, 0($t0) andi $t1, 1 beq $t1, $0, mainloopnext1 # call the process_input function here lw $a0, 4($t0) li $v0, 1 syscall # 2. check sleep timer mainloopnext1: # 3. delay for 10ms jal delay_10ms # 4. print status addi $s0, $s0, -1 bne $s0, $0, mainloopnext4 la $a0, msg_tvworking li $v0, 4 mainloopnext4: j mainloop li $v0,10 # exit delay_10ms: li $t0, 3000 delay_10ms_loop: addi $t0, $t0, -1 bne $t0, $0, delay_10ms_loop jr $ra