DOC PREVIEW
UIUC ECE 190 - ECE 190 Midterm Exam 2

This preview shows page 1-2-3-4 out of 13 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 13 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 13 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 13 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 13 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 13 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

ECE 190 Midterm Exam 2 Spring 2011 Practice Exam Name: NetID: Programming studio section (mark only the one you attend): DCL 440 DCL 520 9:00 AM [ ] AD4 [ ] AD6 12:00 PM [ ] AD5 [ ] AD8 1:00 PM [ ] AD3 [ ] AD7 2:00 PM [ ] AD9 3:00 PM [ ] AD1 [ ] AD2 - Be sure your exam booklet has 8 pages. - Do not tear the exam booklet apart. - Write your name at the top of each page. - This is a closed book exam. - You may not use a calculator. - You are allowed one handwritten 8.5 x 11" sheet of notes. - Absolutely no interaction between students is allowed. - Be sure to clearly indicate any assumptions that you make. - Don’t panic, and good luck! Problem 1 10 points _______________________________ Problem 2 10 points _______________________________ Problem 3 5 points _______________________________ Problem 4 5 points _______________________________ Problem 5 10 points _______________________________ Total 40 points _______________________________Page: 2 Name: ___________________________________________ Problem 1 (10 points): FSM Example problem 1: Design FSM and combinational circuit necessary to implement the FSM logic for controlling traffic danger sign described in section 3.6.4 of the textbook. Part A (1 point): Draw state diagram. Part B (2 points): Fill in state transition and output truth tables. Part C (2 points): Using Programmable Logic Array, design combinational logic circuit that implements the traffic danger sign controller logic. Example problems 2 & 3: Solve problems 3.41 and 3.43 from the textbook.Page: 3 Name: ___________________________________________ Problem 2 (10 points): Von-Neumann model The following LC-3 program fragment, represented as three hexadecimal numbers, is stored in memory at the indicated locations and the following values are stored in registers: address instruction register Value … R0 x000A x3000 x903F R1 x000B x3001 x1021 R2 x000C x3002 x1201 R3 x000D … R4 x000E Part A (6 point): Assuming PC is initially set to x3000, trace the execution of three steps of the given program segment and fill in the table below. Write down values stored in PC, IR, MAR, MDR, N, Z, and P registers at the end of the instruction cycle. Values for PC, IR, MAR, and MDR should be written in hexadecimal. Values for N, Z, and P should be written in binary. PC IR MAR MDR N Z P Part B (2 point): How many memory accesses will take place during the execution of this program segment? Answer: _______________________ Part C (2 point): What hexadecimal value will be stored in R1 once all three instructions are executed? Answer: _______________________Page: 4 Name: ___________________________________________ Problem 3 (5 points): LC-3 ISA A TA spilled a cup of coffee on his LC-3 computer. As a result, the computer was damaged in some ways. Explain how this damage will manifest itself in computer‟s ability to execute some instructions. Part A (1 points): If MSB of IR is always stuck at one, which LC-3 instructions will be affected and how? List instructions that will be affected: ______________________________________________ Explain what will happen to them. Part B (2 points): If the MSB of the global bus is shorted to ground, what impact would that have on executions of RET? Part C (2 point): Computer skips every other instruction. What damage to its PC register might cause this?Page: 5 Name: ___________________________________________ Problem 4 (5 points): LC-3 I/O Example problem 1: Draw a detailed flowchart describing the sequence of steps for sending an ASCII value to LC-3 output display. You can assume that ASCII value of a character to be displayed is stored in register R0. Your flowchart should show all interactions with DDR, DSR, R0 and any additional registers you use. Example problem 2: Draw a detailed flowchart describing the sequence of steps for receiving input from LC-3 keyboard device. You can assume ASCII value of the character to be received from the keyboard is to be stored in register R0. Your flowchart should show all interactions with KBDR, KBSR, R0 and any additional registers you use. Example problem 3: Draw a detailed flowchart for the procedure of sending a string of characters stored in LC-3 memory to the LC-3 output display. You can assume the starting address of the string to be printed is already pre-loaded in register R0. Your flowchart should show all interactions with DDR, DSR, R0, LC-3 memory and any additional registers you use.Page: 6 Name: ___________________________________________ Problem 5 (10 points): Stack The follow snippet of code uses a stack to determine if a string input has balanced parentheses. A string has balanced parentheses if there is one left-parenthesis for each right-parenthesis and if there is no right-parenthesis before any unclosed left-parenthesis. The code should branch to location PASS if the string has balanced parentheses, otherwise it should branch to FAIL. The code uses 3 subroutines which manipulate a stack: PUSH: pushes the contents of R0 onto the stack POP: pops the top element off of the stack and saves the element in R0 EMPTY: loads R0 with x0001 if the stack is empty, otherwise loads R0 with x0000 The subroutines are callee-saved and the stack is initially empty. LEA R1, INPUT ;load address of string ADD R1, R1, #-1 LD R2, LPAREN_NEG LD R3, RPAREN_NEG LOOP ADD R1, R1, #1 LDR R0, R1, #0 ;load next char from string BRz DONE ;done if we reach null char ADD R4, R2, R0 ;check if char is left parenthesis BRnp NOT_LPAREN JSR PUSH ;push onto stack if left parenthesis BRnzp LOOP NOT_LPAREN ADD R4, R3, R0 ;check if char is right parenthesis BRnp LOOP ;go back to loop if not right parenthesis JSR EMPTY ;check if the stack is empty BR___ ___________ ;PASS or FAIL if stack is empty JSR POP BRnzp LOOP DONE JSR EMPTY BR___ ___________ ;PASS or FAIL BR___ ___________ ;PASS or FAIL LPAREN_NEG .FILL xFFD8 ; 2’s complement negative of ascii code for ‘(’ RPAREN_NEG .FILL xFFD7 ; 2’s complement negative of ascii code for ‘)’ For problems that ask you to draw the stack, assume that the stack starts at the bottom of the table and grows upward. If a location on the


View Full Document
Download ECE 190 Midterm Exam 2
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view ECE 190 Midterm Exam 2 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view ECE 190 Midterm Exam 2 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?