EE306Fall2018FinalAnswerKey

pdf

School

University of Texas *

*We aren’t endorsed by this school

Course

306

Subject

Electrical Engineering

Date

Jan 9, 2024

Type

pdf

Pages

13

Uploaded by MateCloverWolverine31

Report
EE306 Introduction to Computing Fall 2018 Final Exam Dr. Nina Telang (TAs: Vignesh Radhakrishnan, Jefferson Lint, Dylan McCoy, Suhas Raja) UT EID: kega Printed Name: Ttlfi"g Your signature is your pledge that you have not and will not cheat on this exam, nor help other students to cheat on this exam. Signature: Instructions: 1. 2. 3. 4. This is a 180 minute closed book, closed notes exam. No calculators or other electronic devices are allowed. Please refer to the LC-3 ISA sheet, data path, state graph and other reference sheets which have been attached to the exam. Please answer all questions neatly in the space provided. WRITE YOUR FINAL ANSWER IN THE SPACE PROVIDED FOR EACH QUESTION. ONLY THE FINAL ANSWER WILL BE GRADED. NO PARTIAL CREDIT WILL BE GIVEN. Problem # 1 /20 Problem # 2 /15 Problem # 3 /10 Problem # 4 /10 Problem # 5 /10 Problem # 6 /15 Problem # 7 /10 Problem # 8 /10 . Nina K. Telang 1
1. {20 points] Answer the following short questions in the space provided. @) [2 points] Consider the LC-3 load instruction, LD. During which stages of the instruction cycle of this instruction are MAR and MDR updated. b Ynslvuckon, Pb"d,v Orb(wv\al,a (ii) [2 points] The INT signal for the keyboard is generated using bits 14 and 15 of the KBSR. Say that A = KBSR[15], and B = KBSR[14]. How would you generate the INT signal given only NOT and OR gates? Write the logic expression. nor (ot () o wot(8)) (iii) [4 points] Design a 4-to-16 decoder using two 3-to-8 decoders, one NOT gate, and AND gates (any number that you need). A \D/ ' (iv) [2 points] Write an LC-3 code snippet that performs the logical OR operation of the contents in R1 and R2, and puts the result in R3. NoT R4, A NOT Ll((LL And 13, &, 2 NoT K3, 13 Nina K. Telang 2
(v) [4 points] Shown below are the contents of registers before and after the LC-3 instruction at location x3210 is executed. Identify the instruction stored at x3210. Write the instruction in hexadecimal. Answers in any other format will not be considered. Before After RO | xFFID | xFFID RL__| x301C | x301C R2_ | x2F11 | x2FI1 R3_ | x5321 | x5321 R4 | x331F | x33IF X 4 8oF R5 | xIF22 | xIF22 R6 | x0IFF | xOIFF R7__ | x341F | x3211 PC_ | x3210 | x3220 N 0 0 Z 1 1 P 0 0 (vi) [6 points] A gated D-latch is shown in the figure below. Answer the following short questions: (a) What is the output A if inputs D and WE are both 1? | (b) What is the output A if D=0 and WE=1? 0 (c) List the values of S, R that can never occur given this D-latch? Why will these values never occur? §=0=0 wll never occr WE —¢ Nina K. Telang 3
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Bors Ze-\,\ s Frp Feockon . Nmznh%m' (;.;«a::k - A N=(-Y x |+ bod.bor &% '\ -1 [cere ) _ <z % 2. [15 pomts] lgata is stored e;’ LC-3 memory location x3456 in floating point format such that there is 1-bit for the sign, 5-bits for the exponent, and 10-bits for the fraction. A student wants to write a program that will output the data in decimal format (i.e. the screen will display a real number like 17.75 or -0.5). For this question, give all numerical responses in decimal. 0 ‘I'V 3 \ @ What are the smallest and largest exponents that can be represented using the given format? Note that “exponents” refers to the power of 2. v\ouvd/‘ RNVJ @b N“MAJA'LZJ CPate Donrenadined ) ~-15 o NSy E \ (’)\c,s g (i) Shown below is a code snippet of the student’s code. After the executlon of these lf lines of code, RS should contain the exponent of the normalized bi -15 = @ representation of the number stored in x3456 (e.g. if m[x3456] = 1 l* 4 khen RS will contain 4). A description of the subroutine BitShift is given in the comments [;)‘f - 3\), 6\0\5 E \b of the program. ; begin code snippet F0-15 {15 ; RO contains bits m- m[x3456] isolated in place Ro: AND RORORUT™ 1o, cf M’Tg’ N7 o~ 1 AND R1,R1,R1 l fool\ /_J ; BitShift bit shifts the value in R0 a certain direction m o ' ; it shifts the bits the number of times specified by the value in Rl JSR LD R4, VAL £ q_ ADD R5,R0,R4] 7 VAL =#° 5 )( - 9—71 as = ; end code snippet E%@ b ¥\5 pp z @ (a) What direction should BitShift shift the bits of RO (right or left)? @ (b) What value should R1 contain before BitShift is called for the program to work as intended? lo (c) What value should R4 be loaded with in order for R5 to contain the correct value after this program’s execution? -5 Nina K. Telang 4
(d) In the BitShift subroutine, the student’s code performed the following steps: Step 1: Saved the values of R0 through R7 in memory Step 2: Checked to see if R1=0 Step 3: If not, then divided the number in RO by 2, decremented R1, and looped back to Step 2. Step 4: IfR1 = 0, then restored the values in RO through R7, followed by RET. If RO = 16 and R1 = 2 before the execution of the subroutine, what will the values of R0 and R1 be after the execution? RO=16 , Ri=2 ¢ Does this subroutine work as intended? No p becanse RO 15 1 QsL-rlflo‘ Ia Yo lask si’br- Nina K. Telang 5
3. [10 points] Dr. Telang has decided to have you all implement another LC-3 instruction that will have the opcode 1101 (currently not used). This instruction will be called BIC and will clear a specified bit of a register. The format is as follows: 15(14)13}12(11|10|9 (8 (7 |6 |5 [4 [3 |2 |1 JoO 1|1 |0 |1 |DR SR X [x [x [x [x |x (i) The least significant 6 bits are marked with an “x.” Some of these bits are going to be reserved for the Selection field, which will identify which bit to clear in the SR and stored in the destination register DR. For example, if the Selection field = 12, then bit 12 of the SR will be cleared. What is the minimum number of bits marked with an “x” that need to be reserved for this field? q_ (i) How many memory accesses does this new instruction make? Include all stages of the instruction cycle. | (iii) Isit possible for this instruction to change the condition code bits? If so, give an example. Y,¢ I~ (iv) During the Fetch Operands phase, a temporary register, calle(@ is loaded with ' the value that corresponds to the Selection field (e.g. Selection field =3, TR = x0008). What logical structure can easily produce the value of TR? L1 (v) Write the microinstructions that take place in the Execute and Store Result phase of the instruction cycle. You are allowed to use the following registers: PC, IR, MAR, MDR, SR, DR, and TR. TR «— NOT(TQ) TR «— TR Avd> SR bR« TR Nina K. Telang 6
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
4. [10 points] An Aggie has tried implementing two new instructions for the new LC-4 machine, PUSH Rn pushes the data in register Rn onto the stack. Similarly, POP Rn pops the data at the top of the stack and loads into register Rn. The instructions are implemented in the following way: PUSH ADD R6, R6, #-1 STR Rn, R6, #0 POP LDR Rn, R, #0 (i) Is there an error in the code? If so, then how can you fix it? Qorer am POP \ P(H/J'\h Y\QA’LJo |0 be IILMM\’\DAA}U\ Q,’/Vh’\. ,0_5\4* 5 (ii) For the following stack operations (using the PUSH and POP instructions as implemented in the code shown above), trace the contents of registers. If the contents cannot be known with the given information, place a N/A in the box. m’ Other than R6, the registers initially contain R1=0x1111, R2=0x2222, e ...R7=0x7777. Each column shows the register contents after all previous operations (in previous columns). PUSHR2 POP R4 PUSH R6 PUSHRS5 PUSHRI PUSHR3 PUSHRI PUSHR3 POP R7 PUSH R4 POP RS POP R6 POP R5 PUSH R2 POPRI1 R1=0x1111 |RI=0xi11} RI= K11 Rl=pgh1t Rl= }z2z22 R2=0x2222 |R2=0y 2222 R2= %2222 R2=j 2222 R2= k2222 R3=0x3333 [R3= x3333 R3= x3333 R3=R>33> R3= X 3333 R4=0x4444 |Rd= r4uyy R4=N/p R4= N/A R4= nfp R5=0x5555 | R5= %6555 R5= k3333 R5=;Q3PFF R5= R 3FFF R6 =0x4000 | R6=K3PFF R6= K2PFF R6= X 3FFD R6= A3FFF R7=0x7777 |R7= X2222 R7= x2222 R7= p227L R7= p2227% 7 Nina K. Telang
5. [10 points] An LC-3 operating in Interrupt driven I/O mode has the following input devices connected to it: Keyboard: Interrupt Vector x80, Priority Level 4 Mouse: Interrupt Vector x20, Priority Level 3 The Interrupt Enable bits for both these devices are enabled by default. The following program starts at x3000. LD RO, Count Loop ADD RO, RO, #-1 ?[XLOOP T Count .FILL x02 The keyboard and the mouse-ISR both have 3 instructions each including RTI. The mouse raises an interrupt during the decode phase of the ADD instruction when RO = x01 and the keyboard raises an interrupt during the execute phase of ADD instruction when RO =x01. Your task is to complete the PC trace which captures the values of PC when entering the fetch phase of instruction cycle. Some of them are already filled for you. PC TRACE x3000 A 300] x3002 X200\ %3002 mYoxol80] m Yog ol s+ mite oigo)fal v x3002Y Myoxolp 7001251 mihroizie o %3003 Nina K. Telang 8
6. [15 points] It’s Throwback Thursday !! Back in the Fall of 1985, Dr. Telang, a freshman in IIT, was introduced to the microprocessor Intel 8085. Knowing about the 8085 was considered swag back then. It has been more than 3 decades now and Dr. Telang would like y’all to take a look at this vintage machine. Investigate the 8085 Microarchitecture/ISA(see attached sheets) and answer the ® (i) following questions: What is the maximum data width the 8085 ALU can operate? °} bl bs ‘What is the maximum number of memory locations that can be addressed by 80857 2\6: Flag Register is an 8-bit register in which five-bit positions contain the status of five condition codes which are Zero (Z), Sign (S), Carry (CY), Parity (P) and Auxiliary carry (AC). The flag register format is shown below: by bs bs bsbs b2 bi by [STZ[x[ACTx[P[x[CY] Sign (S) flag If the result of an operation is negative, this flag is set (1), otherwise it is reset (0). Zero (Z) flag Similar to ‘Z’ condition code of LC-3 Carry (CY) flag - If an instruction results in a carry (for addition operation) or borrow (for subtraction or comparison) out of the MSB, then this flag is set, otherwise reset. Auxiliary Carry (AC) flag If there is a carry/borrow out of bit 3 and into bit 4 resulting from the execution of an arithmetic operation, it is set otherwise reset. Parity (P) flag This flag is set when the result of an operation contains an even number of 1’s and is reset otherwise. The table shows the status of the bits in the flag register and accumulator after each of the following instructions are executed. Don’t make any assumptions on the initial state of the registers. Your task is to fill in the blanks. Some are already filled for you. Instruction | Accumulator [ S |Z |C (AC | P (Hexadecimal) XRA A * 00 ol ]o o |1 MVI B, x70 *00 0 [1]0j0 |1 MVI C, x0A X 0U 01110 lo0 |1 SUB B x40 €0 i [1 [ SBB C X %9 viploly 1O ADD C % &f 1101l o0 10 Nina K. Telang
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
(iv) The 8085 has the ability to combine two registers and use them as a register pair. B and C can be considered as one BC register with B in higher order bit position and C in lower order bit position. Similarly, D and E can be combined to DE, and Hand L to HL, where D and H are in higher order positions. MVID, x0 MVIE, x0 MVI B, xAB MVIC, x0 MOVL,B MOV H,C DAD B DCX H INXD What will be the value of the register pairs after the above program is executed? Fill in the table provided. [BC = xApoo |DE = x 000\ [HL = x Aphh ] Nina K. Telang 10
. [10 points] Design an FSM having one input X and one output Z, such that Z is the 2’s complement of X. The following are some example input sequences with their corresponding output sequences. In each example listed below the LSB is the rightmost bit, and the MSB is the lefimost bit. Note that the LSB will arrive at the machine input first followed by the more significant bits. Example 1: X=0001,Z=1111 Example 2: X =0001001,Z= 1110111 Example 3: X =1110111, Z = 0001001 @) Draw the state graph for this finite state machine. (i) How many storage elements do you need to implement this FSM? % (ili) Complete the state table for this FSM. You may not need all the rows. Present State Next State Z 8160 X=0 X=1 So 00 Sz Sy 0 5 04 S S3 ] Sa 0 Sg_ sl O Sy i S\ S3 o} (iv) Write the logic expression for output Z. 7= Q t go Nina K. Telang 11
8. [10 points] A queue is a data structure where elements are removed in the order they are added (like a bus queue). You would like to implement this data structure using 2 stacks, named inbox and outbox. The idea is that inbox is a stack where queue elements enter, To retrieve elements from the queue, you pop elements from stack outbox. When you PUSH a number to inbox, the number gets pushed to the top of inbox. Pushing a2 number to outbox works in the same way. Similarly, when you POP an element from either inbox or outbox, the element at the top of the stack gets popped. Jro? i. The first figure below,jtems that have lined up in the queue, with element X first, and element Z last. Write a sequence of pseuda instmictions such that the 2 stacks together implements this queue. Note that elements have already entered the queue, and your task is to use the stacks to get them out in the order they entered. The first pseudo instruction has been shown, with the outcome shown in the Inbox stack. - Z —> [ X 4 Y —_— Inbox Outbox ; Write your pseudo instructions below. The first one is written for you. PUSH Inbox PuUsSH Inbox sk [nbox PP lnbox Pusy O whbox PoP lnboy Pusit Ouwhbor PO? Vnbox Pusn Ovdhox Nina K. Telang 12
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
ii. The first figure below shows new elements A, B, C (in that order) have entered the queue. A snapshot of the two stacks shows that the previous elements X, Y, Z have not been processed yet. Write a sequence of pseudo instructions such that the 2 stacks together implements a queue. (e —_— & > 8 b A Sz —_— a> Inbox Outbox ; Write your pseudo instructions below. PoP Oulhoyw Pop Owrbox Pof O\/J’L:D)a J\ { oo Puon lnloox Pusn linbog P09 Vwhox Pusn Ovdhaox Nina K. Telang 13