





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






Spring 2011
Wednesday, March 16, 2011
Attach label here
Workstation #:
Be sure your exam booklet has 9 pages. Do not tear the exam booklet apart; you can only detach pages 8 and 9. Feel free to keep pages 8 and 9 for the programming exam. Do NOT start the programming exam until you have turned in the written. This is a closed book exam. You may not use a calculator. You are allowed two handwritten 8.5 x 11" sheets 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 _______________________________
Problem 1 (10 points): FSM
Design FSM and combinational circuit necessary to implement the FSM for controlling an elevator going between four floors. The elevator has only two buttons: UP(=1) and DOWN(=0). In response to these buttons, the elevator can only move one floor up or one floor down. The elevator also has 4 independent lights that when combined indicate which floor the elevator is currently on. For example, when light #1 is on, the elevator is on the 1st^ floor, when lights #1 & #2 are on, the elevator is on the 2nd^ floor, and so on.
Part A (3 points): Draw state diagram. State 00 corresponding to the elevator been on the 1st^ floor is pre-filled as an example. Assume that transition between states is triggered by pressing the elevator buttons.
00 01 10 11
Part B (4 points): Fill in state transition and output truth tables.
External input
Present state Next state Elevator lights (output) S 1 present S 0 present S 1 next S 0 next # 1 # 2 # 3 # 4 DOWN 0 0 UP 0 0 DOWN 0 1 UP 0 1 DOWN 1 0 UP 1 0 DOWN 1 1 UP 1 1
Part C (3 points): Design combinational logic circuit that implements control logic for controlling elevator lights.
Problem 3 (5 points): LC-3 data path
While fixing an LC-3 computer, a TA accidentally struck it’s mainboard with a screwdriver. As a result, the computer was damaged even more. Explain how this damage manifests itself in computer’s ability to execute some instructions. ( Note: formats of the entire LC-3 instruction set are provided on page 8 and LC-3 data path diagram is provided on page 9. MSB is bit #15 and LSB is bit #0. )
Part A (1 point): If register 7 stops functioning, we can simply stop using it in our programs. But a few instructions are hard-coded to use this register! Which instructions will need to be modified, and how, to make the computer function as normal?
Part B (2 points): If the MSB of the IR is shorted to ground, what impact would that have on execution of control instructions?
List instructions that will be affected: ______________________________________________
Explain what will happen to them.
Part C (2 points): Immediate mode arithmetic instructions ADD and AND no longer function as expected. Damage to what parts of the data path relevant to the execution of these instructions might cause this? (Assume all other instructions still function as expected.)
Problem 4 (5 points): LC-3 I/O
You are asked to design TRAP routine for trackball --a new LC-3 input device consisting of a ball held by a socket containing sensors to detect a rotation of the ball about two axes—like an upside-down mouse with an exposed protruding ball. The interface to this device is to be implemented using memory-mapped I/O using four new device registers: TDR_X, TDR_Y, TDR_B (trackball data registers), and TSR (trackball status register) mapped into some memory addresses. The trackball produces 2-dimensional input (passed via TDR_X and TDR_Y registers) which indicates the amount of rotation of the ball around the x and y axes, and a buttons status input (passed via TDR_B register) which indicates which of the three buttons available on the trackball base were pressed by the user. The most significant bit of TSR register indicates when a new input is available and the least-significant bit of TSR register indicates which input has been transmitted to LC-3 computer. That is, if TSR[15] is set, there is a new input loaded into trackball data registers; if TSR[0] is cleared, the input is due to the buttons pressed by the user; if TSR[0] is set, the input is from the trackball sensors due to the ball rotation by the user. Once data is read by LC-3 computer, TSR[15] needs to be cleared by the TRAP routine to indicate that LC-3 is done receiving the input.
Draw a detailed flowchart describing the sequence of steps for receiving data from the trackball input device. Ball sensor values are to be stored in R0 and R1. Button’s data value is to be copied to R2. Unused output registers (R0-R2) are to be cleared. Be specific , your flowchart should show all interactions with TDR_*, TSR, R0-R2 and any other registers you decide to use.
Also indicate if the stack is empty, and IF the stack is NOT empty be sure to draw an arrow
clearly pointing to the element on the top of the stack. Also for this implementation of the stack
if the string of three characters “abc” were pushed onto the stack and “c” is then POPed off, the
stack would look like this:
Part A (2 points): For INPUT string “aaabbbaaa”, fill in the contents of the stack at the moment the program branches to LOOP3 for the first time.
Part B (2 points): For INPUT string “aaabbbaaa”, fill in the contents of the stack at the moment the program branches to either PASS or FAIL.
Part C (2 points): For INPUT string “aaaabbaa”, fill in the contents of the stack at the moment the program branches to LOOP3 for the first time.
Part D (2 points): For INPUT string “aaaabbaa”, fill in the contents of the stack at the moment the program branches to either PASS or FAIL.
Part A Part B Part C Part D
Part E (2 points): Given your results, fill in the code with the missing BR condition codes and branch locations (the three missing branches either jump to PASS or FAIL).
b a