exam_final_109_spring_2018_sol

docx

School

North Carolina State University *

*We aren’t endorsed by this school

Course

109

Subject

Electrical Engineering

Date

Apr 3, 2024

Type

docx

Pages

19

Uploaded by CountPartridgePerson987

Report
Name: ________________________________________ Section : ____________ ECE 109 Final Exam w/ Solutions May 4, 2018 Cover Sheet This exam is Closed Note, Closed Book, Closed Calculator, No Electronics, Earbuds. No correspondence is allowed with anyone other than the instructor/proctor. Absolutely NO IMs, E-Mails, Verbal Messages, or other communications during the exam! No Cell Phones, e-watches, pagers, or other communications devices, may be used. It is OK to work on separate paper, but please write answer back into space on test pages . STAPLE the extra sheets to your exam and write your name on ALL sheets! All work must be completed in PENCIL . No ink pen allowed! This is a 180 minute exam. Students who arrive late will NOT be given extra time on the exam. You WILL be required to show your work for full credit! Partial Credit will be Generous! Please turn in your exam when asked! I consider it cheating to continue to work on an exam when told to stop and will count this as an Honor Offence!! Exam Problem Grading: 10% For Trying. Writing anything intelligent on the test paper. Things like “Mary had a little lamb” will not count! 40% for choosing the correct methods and formulae 50% for placing the proper values into the proper places and for carrying through the math to get the final answer Failure to abide by these rules and the NCSU Honor Policy will result in a zero on the exam and will be treated as a violation of the NCSU Code of Student Conduct. Read and sign the following statement. Failure to sign the statement will result in a zero on the exam. I have neither given nor received unauthorized assistance on this test. I have notified the proctor of any violations of the above policies. Signature: __________________________________________________
Name: __________________________ Except for name, DO NOT WRITE ON THIS PAGE. Grader : _____________________________________________ ECE 109 Spring 2018 Final Exam w/ Solutions Page 2 of 20 Question Points Topic Score 1 10 Transistor Gates 2 15 POS/SOP 3 25 State Diagrams 4 10 Instruction Flow 5 20 Assembly / Machine Conversions 6 10 Subroutines 7 25 Code Segments 8 20 IEEE 32-bit, Hex, Binary, Decimal 9 15 Code Line Counting 10 10 Stack TOTAL 160
Name: __________________________ [1] [10 pts. Total] Complete the truth table for the following transistor circuit. Is this a legal circuit? Solving for intermediate nodes is not required but may help you in solving the final solution at node Z. Solving for nodes R and Q is not required but may help you solve the final answer. Legal Circuit ECE 109 Spring 2018 Final Exam w/ Solutions Page 3 of 20
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
Name: __________________________ [2] [15 pts total ] Complete the following logic questions. [a] [10 pts] Draw a SOP or POS combinational logic circuit (using AND, OR, etc.) that implements the function described by the truth table below. This table has 4 inputs ABCD and one output X. ECE 109 Spring 2018 Final Exam w/ Solutions Page 4 of 20
Name: __________________________ [b] [5 pts] Use any combination of 2-input AND, 2-input OR, and 1-input NOT gates to ensure winning the Stanley Cup from the material supplied. You must use all items shown. You may use multiple gates of each type, you do not have to use all gates. You may use a “bubble” on any input or output instead of an inverter. Many acceptable ways to solve this. Students may show “bubbles” on gate inputs rather than use an inverter. ECE 109 Spring 2018 Final Exam w/ Solutions Page 5 of 20
Name: __________________________ [ 3] [25 points total] State Machines For the following circuit, determine the Next State Truth Table [15 pts] and the State Diagram [10 pts]. There are two inputs X1 and X0, X1 is the MSB. ECE 109 Spring 2018 Final Exam w/ Solutions Page 6 of 20
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
Name: __________________________ Format of Next State Truth Table Above or Below are Acceptable ECE 109 Spring 2018 Final Exam w/ Solutions Page 7 of 20
Name: __________________________ ECE 109 Spring 2018 Final Exam w/ Solutions Page 8 of 20
Name: __________________________ [4] [10 points] Instructions Version A [a] [8 pts] Using the figure below, illustrate the dataflow of the RET instruction. (Show where and when data moves during the execution phase of the instruction.) [b] [2 pts] Briefly (in English) describe each step shown in your diagram. (1) The contents of R7 are sent to the Program Counter (PC) ECE 109 Spring 2018 Final Exam w/ Solutions Page 9 of 20 R7
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
Name: __________________________ [4] [10 points] Instructions Version B [a] [8 pts] Using the figure below, illustrate the dataflow of the JMP Rx instruction. (Show where and when data moves during the execution phase of the instruction.) [b] [2 pts] Briefly (in English) describe each step shown in your diagram. (1) The contents of Rx are sent to the Program Counter (PC) ECE 109 Spring 2018 Final Exam w/ Solutions Page 10 of 20 R7
Name: __________________________ [5] [20 points] Assembly Language and Machine Code Using the symbol table shown on the right, translate each LC-3 assembly language statement to machine language. If the statement cannot be translated, write ILLEGAL, and explain why the translation cannot be performed. In each case , assume that the statement being translated is at memory location x3050 . Assembly Language Machine Language BRnp CAROLINA ____ 0000 101 0 0100 0000 ___ JMP KURE Illegal - JMP operand is register, not label ____ ADD R1, R3, #-7 ____ 0001 001 011 1 11001 ___ ST R2, TOPSAIL ____ 0011 010 1 1010 0010 ______ OUT ____ 1111 0000 00100001 _____ ECE 109 Spring 2018 Final Exam w/ Solutions Page 11 of 20 Symbol Value CAROLINA x3091 KURE x30FF TOPSAIL x2FF3 WRIGHTSVILLE x3130 MYRTLE x3F30 VIRGINIA x3030 HOLDEN x3001
Name: __________________________ [6] Subroutines [10 pts] [a] [2 pts] Where is the return address from a subroutine stored?? R7 [b] [5 pts] How far ahead/back can a subroutine jump in the code?? 11 bit PC offset, so +1023/-1024 memory locations [c] [3 pts] How is a TRAP command mainly different from a subroutine call JSR? TRAP is a call to an Operating System routine, usually in the OS memory space. JSR is a jump to a routine in User Space. ECE 109 Spring 2018 Final Exam w/ Solutions Page 12 of 20
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
Name: __________________________ [7] [25 points] Code Segments [a] [10 points] Write a code segment to count the number of characters in a string. This string MYSTRING is guaranteed to contain an EVEN number of characters. Put the total in R4 and the total divided by 2 in R5. Assume the string is already set up in memory for us. ; ; Hard to Divide in LC3 Assembly. So have two counters since EVEN number of Characters. ; R4 counts every character, R5 counts every-other character so is equivalent to R4 div 2 ; LEA R1, MYSTRING ; Get address of first char AND R4, R4, #0 ; Clear Counter AND R5, R5, #0 ; Clear counter AND R3, R3, #0 ; Odd/Even Counter LOOP1 LDR R0, R1, #0 ; get char from string BRz ALLDONE ; skip out if NULL end of string ADD R4, R4, #1 ; increment counter ADD R1, R1, #1 ; bump up pointer to next location ADD R3, R3, #1 ; increment Odd/Even counter AND R6, R3, x0001 ; test for odd BRpn ALMOST ; don’t increment ADD R5, R5, #1 ; increment div 2 counter ALMOST BRnzp LOOP1 ALLDONE [b] [2 pts] Clear R3 AND R3, R3, #0 [c] [3 pts] Put x21 into R5 AND R5, R5, #0 ; clear R5 LD R6, NUM21 ; Load x21, too big for immediate mode ADD R5, R5, R6 ; add BRnzp NEXT ; must jump around .Fill NUM21 .FILL x21 NEXT ECE 109 Spring 2018 Final Exam w/ Solutions Page 13 of 20
Name: __________________________ [d] [ 4 pts] Add x845 to R3, then subtract the result from R2 LD R4, MY8 ; Load x845 ADD R3, R3, R4 ; add to R3 NOT R3, R3 ; Make 2sC ADD R3, R3, #1 ADD R2, R2, R3 ; subtract R2 – (R3+x845) BRnzp NEXT2 MY8 .FILL x845 NEXT2 [e] [6 pts] Add every third number between #3 and #39, starting with #3, and put the answer into R0. AND R0, R0, #0 ; clear counter for sum AND R3, R3, #0 ; clear counter for 3s AND R1, R1, #0 ADD R1, R1, #3 ; set R1 to 3 LD R2, NEG39 ADD R3, R3, #3 ; set to 3 LOOP1 ADD R3, R3, #-1 ; dec R3 BRp GO1 ; not 3 rd value, skip ADD R0, R0, R1 ; 3 rd value, add to sum ADD R3, R3, #3 ; reset 3 counter GO1 ADD R1, R1, #1 ; increment number 3 to 39 ADD R5, R1, R2 ; Test for -39 BRnp LOOP1 BRz HOME NEG39 .FILL #-39 HOME ECE 109 Spring 2018 Final Exam w/ Solutions Page 14 of 20
Name: __________________________ [8] [20 pts total] Binary Math, Floating Point [a] [10 pts] Convert the decimal value into the 32-bit IEEE floating-point binary number below. You must show your work to get full credit. -1372.09375 Show work: Sign = 1, negative Fraction = 0.09375 = .00011 (base 2) Number = 1372 decimal = 101 0101 1100 (base 2) Number = 10101011100.00011 (base 2) x 2 10 Number = 1.0101011100.0001 (base 2) x 2 10 Exponent = 10 + 127 = 137 IEEE Binary floating-point: 1 10001001 01010111000001100000000 ECE 109 Spring 2018 Final Exam w/ Solutions Page 15 of 20 n 2 n -8 0.00390625 -7 0.0078125 -6 0.015625 -5 0.03125 -4 0.0625 -3 0.125 -2 0.25 -1 0.5 0 1 1 2 2 4 3 8 4 16 5 32 6 64 7 128 8 256 9 1 0 512 1024
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
Name: __________________________ [b] [10 pts] Complete the following math problems. You must show your work to get full credit. Show all results in 8-bit 2sC Hex Coding . All values are 8-bit 2sC integers. I chose to convert to decimal, do the math, then convert to hex. x26 #38 + b11110111 #-9 x1D #29 #11 #11 + x27 #39 x32 #50 xFFE7 #-25 + b01001110 #78 x35 #53 ECE 109 Spring 2018 Final Exam w/ Solutions Page 16 of 20
Name: __________________________ [9] [15 pts] Suppose the LC-3 registers contain the values shown on the left. Show the value of each register after the code is executed -- up to, but not including the HALT. (DO NOT execute the HALT instruction!!!) Write your answers in hexadecimal format. Before: R0: x4000 R1: xFFFF R2: x1010 R3: xDCBA R4: x9876 R5: x00FE R6: xC0D4 R7: x3250 ECE 109 Spring 2018 Final Exam w/ Solutions Page 17 of 20 .ORIG x3250 LEA R0, PR ; start here PUTS LDI R3, MM JSR J1 PUTS HALT ; stop -- don't execute PR .STRINGZ "AbCdEf" MM .FILL x3273 J1 ST R1, D1 ST R2, D2 ST R3, D3 ADD R1, R0, #0 XX LD R3, D3 LDR R2, R1, #0 BRz ZZ AND R3, R3, R2 BRp YY ADD R2, R2, R3 STR R2, R1, #0 YY ADD R1, R1, #1 BRnzp XX ZZ LD R3, D3 LD R2, D2 LD R1, D1 RET D1 .BLKW 1 D2 .BLKW 1 D3 .BLKW 1 .FILL x20 .FILL x40 .FILL x80 .END After execution... R0 = ____x3256___________ R1 = _____xFFFF__________ R2 = ____x1010___________ R3 = ___x0040____________ R4 = ___x9876____________ R5 = ___x00FE____________ R6 = ___xC0D4____________ R7 = __x3255_____________
Name: __________________________ [10] [10 points] Stack A section of a user program is shown: .ORIG x5000 COLORRED .FILL x02C0 COLORBLUE .FILL x01F0 ASCIINEG .FILL xFFD0 STACKP .BLKW x0008 TEST0 .FILL x0030 [a] [2 pts] How large is the space allocated for the stack? x08 or #8 [b] [2 pts] What should be the initial location for the Stack Pointer SP ?? Bottom of stack is at x5003. Add x08, Top of Stack will be x500B [c] [2 pts] After 4 PUSH operations, what will be the value of the Stack Pointer? X5007 [d] [2 pts] After 4 more PUSH operations, Then 2 POP Operations, what will be the value of the Stack Pointer? X5007 – 4 + 2 = x5005 [e] [2 pts] What will happen after 6 more PUSH operations? Overflow Error ECE 109 Spring 2018 Final Exam w/ Solutions Page 18 of 20
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
Name: __________________________ ECE 109 Spring 2018 Final Exam w/ Solutions Page 19 of 20 TRAP TABLE