Docsity

LC-3 Exam 1, Fall 2008: Electrical and Computer Engineering Problems, Exams of Introduction to Aerospace Engineering

Toggle sidebar
bg1
ECE190 Exam 1, Fall 2008
Thursday 25 September
Name:
•Be sure that your exam booklet has 9 pages.
•The exam is meant to be taken 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 8.5×11"sheet of handwritten notes.
•Absolutely no interaction between students is allowed.
•Challenging problems are marked with ***.
•Show all of your work.
•Don’t panic, and good luck!
“...there would be no more wars, the nations were so economically interdependent.”
—S. Foster Damon, remembrance ca. 1912
Problem 1 20 points
Problem 2 20 points
Problem 3 10 points
Problem 4 25 points
Problem 5 25 points
Total 100 points
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download LC-3 Exam 1, Fall 2008: Electrical and Computer Engineering Problems and more Exams Introduction to Aerospace Engineering in PDF only on Docsity!

ECE190 Exam 1, Fall 2008

Thursday 25 September

Name:

• Be sure that your exam booklet has 9 pages.

• The exam is meant to be taken 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 8. 5 × 11 " sheet of handwritten notes.

• Absolutely no interaction between students is allowed.

• Challenging problems are marked with ***.

• Show all of your work.

• Don’t panic, and good luck!

“...there would be no more wars, the nations were so economically interdependent.” —S. Foster Damon, remembrance ca. 1912

Problem 1 20 points

Problem 2 20 points

Problem 3 10 points

Problem 4 25 points

Problem 5 25 points

Total 100 points

Name: ____________________________________________ 2

Problem 1 (20 points): Short Answers

Please answer concisely. If you find yourself writing more than a few words or a simple drawing, your answer is probably wrong.

Part A (5 points): Using an 8-bit 2’s complement data type, what is the smallest positive number that

generates an overflow when added to itself?

Part B (5 points): How many positive integers are represented in a 13-bit 2’s complement data type?

Part C (5 points): Using one or more LC-3 instructions, implement a branch if positive (BRp) to an

address outside the range of the branch instruction. Assume that the address to which you want to branch is stored in R5. Write your instruction(s) in binary. Note: you may not need all the lines provided below.

Address Instruction

x3000: ______________________________

x3001: ______________________________

x3002: ______________________________

x3003: ______________________________

Part D (5 points): The current LC-3 memory contains a total of 1 Megabit (2 20 bits). If we were to make

the memory byte-addressable (a byte is 8 bits) without changing its size, and without changing the size of the instructions (16 bits), how many bits would be necessary in the following registers?

MAR IR

Name: ____________________________________________ 4

Problem 3 (10 points): Memory

In a typical memory, setting the write enable input (WE) to 1 causes all bits of the selected memory location to accept new values. For a certain ECE445 (senior design) project, we need a 4-address, 3-bit addressable memory that allows us to write to each bit at a location separately. To do so, we hired a computer engineer from the University of Michigan.

The design is done by modifying the 4-address, 3-bit, memory that we discussed in class. Except for the WE input, all inputs and outputs remain the same. More specifically, ADDR is a 2-bit input for address selection, Din is a 3-bit input for providing bits when writing to a memory location.

As for the WE input, the modified memory structure no longer has a single WE input to all bits. Rather, when a location is selected, 3 WEout signals will independently determine if each bit in that location will be written. This modification has already been done by an Illinois student.

The Michigan engineer proposes to construct a combinational logic that provides a nice external interface for using the memory. The logic translates a 4-bit WE external input signal into the internal 3-bit WEout signals as follows:

WE is 4 bits wide and behaves as follows: WE [3:0] = 0001 => write to bit 0 only WE [3:0] = 0010 => write to bit 1 only WE [3:0] = 0100 => write to bit 2 only WE [3:0] = 1000 => write to all the bits WE [3:0] = 0000 => do not write to any of the bits WE [3:0] = other => treat as a read cycle

Part A (6 points): For a first round of testing, we executed the six cycles shown on the left below.

Assuming correct implementation and assuming that all the bits in the memory are initialized to 1, fill in the table on the right to reflect the final state of the memory (after the six cycles).

Cycle # ADDR[1:0] WE[3:0] Din[2:0] 1 00 0100 000 2 10 1000 010 3 10 0000 110 4 01 0010 001 5 11 0001 011 6 00 1000 100

address bit 2 bit 1 bit 0

Part B (4 points): The memory designed by the Michigan alumnus passed the first test. However, the

next round of tests revealed some undesired behavior. Examining his design, we found the following logic for generating the signals that specify whether or not each individual bit is written (WEout[2:0]).

In 25 words or less, explain the undesired behavior.

Name: ____________________________________________ 5

Problem 4 (25 points): Finite State Machines

A certain finite state machine implements a pattern recognition system that recognizes specific sequences of inputs. Each input represents a letter, such as A or B. An input sequence can be written as a sequence of letters such as “ABAAABBBABA…”. For this finite state machine, the output Z is 1 when an input sequence has an even number of A’s and an odd number of B’s. Otherwise, the output Z is 0. The states needed are named as follows:

S (^) EE even number of A’s and even number of B’s S (^) EO even number of A’s and odd number of B’s S (^) OO odd number of A’s and odd number of B’s S (^) OE odd number of A’s and even number of B’s

Part A (8 points): Draw a high-level finite state machine transition diagram for the system. States and

state names have been drawn for you. Add appropriate output values and all transition arcs. Label arcs as either A or B.

The circuit below shows an implementation of the finite state machine using two flip-flops and state representation (bits P 1 P 0 ) given by S (^) EE = 00, S (^) EO = 01, S (^) OO = 10, and S (^) OE = 11. The blocks labeled 1 and 2 use the current state P (^) 1P 0 and the inputs X 1 X 0 to calculate the next state, N 1 N (^) 0. The letter A is represented as X 1 X (^) 0=00, and the letter B is represented as X 1 X (^) 0=01.

Name: 7

Problem 5 (25 points): The von Neumann Model

An LC-3 is about to perform an instruction FETCH. The contents of the register file, PC, MAR, MDR, IR, and part of memory are shown to the right.

You may wish to consult the last page of this exam, which gives the LC-3 instruction set encoding and RTL.

Part A (8 points): On the lines below, write RTL

for the next four instructions to be executed by the LC-3. For PC-relative addressing modes, write addresses relative to PC rather than calculating the actual address to be used, e.g., write “PC+x12” rather than adding the two values for that instruction.

R0 xA5A5 x3A06 x6CBC R1 x1000 x3A07 x1FF R2 x1298 x3A08 x R3 x1981 x3A09 x R4 x4345 x3A0A x R5 x0BEE x3A0B x R6 x3A0F x3A0C x R7 xF025 x3A0D x09FD x3A0E xF PC x3A0A x3A0F xFFF MAR x39A3 x3A10 x MDR x0E66 x3A11 x IR x0E66 x3A12 x x3A13 x6CBC ...

Address RTL

Part B (6 points): Using hexadecimal notation, write the contents of the registers R0 through R7, PC,

MAR, MDR and IR after the LC-3 processes the first three instructions.

R0 PC

R1 MAR

R2 MDR

R3 IR

R

R

R

R

Part C (4 points): Using hexadecimal notation, write the contents of the PC, MAR and MDR after

the LC-3 processes one additional instruction after Part B, i.e., four instructions in all.

PC MAR

IR MDR

Part D (7 points): The instruction xF025 halts LC-3 execution (i.e., no further instructions are pro-

cessed after xF025). What are the contents of R0 and R1 when the LC-3 halts?

R0 R

Name: 8

Use this page for scratchwork.