exam_final_109_fall_2019_A_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

16

Uploaded by CaptainVultureMaster1051

Report
Name: ________________________________________ Section : ____________ ECE 109 Final Exam w/ Solutions December 10, 2019 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. Cell phones MUST be left w/ TAs during bathroom breaks. 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 Fall 2019 Final Exam w/ Solutions Page 2 of 16 Question Points Topic Score 1 10 Transistor Gates 2 16 POS/SOP 3 25 State Diagrams 4 10 Instruction Flow 5 20 Assembly / Machine Conversions 6 25 Code Segments 7 10 IEEE 32-bit, Hex, Binary, Decimal 8 20 Code Line Counting 9 14 Interrupts TOTAL 150
Name: __________________________ [1] [10 pts. Total] Transistor Circuits Complete the transistor circuit for the truth table and equations. Solving for intermediate nodes R and Q is not required but may help you in solving the final solution at node Z. ECE 109 Fall 2019 Final Exam w/ Solutions Page 3 of 16
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] [16 pts total ] Complete the following logic questions. [a] [10 pts] Complete the circuit for the truth table logic circuit shown. Choose your design to use the lowest number of gates. ECE 109 Fall 2019 Final Exam w/ Solutions Page 4 of 16
Name: __________________________ [b] [6 pts] Draw a truth table and a logic circuit to implement the following conditions: Output F is = 1 when A equals B but is NOT equal to C, or when C = A but is NOT equal to B. ECE 109 Fall 2019 Final Exam w/ Solutions Page 5 of 16
Name: __________________________ [ 3] [25 points total] State Machines Ever see this in your rear-view mirror? The Flash Bar of a N.C. State Trooper car is as shown here. The segments of the bar light in the order of [none; 1 & 2; 1, 2, 3, & 4; all]. A single switch for on/off is the input to this system. [a] [10 pts] Draw a State Diagram showing the operation of this flash bar. Use Symbolic state names. ECE 109 Fall 2019 Final Exam w/ Solutions Page 6 of 16
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] [6 pts] Draw the complete Symbolic Next State and Output Table for the State Diagram. [c] [6 pts] Draw the complete Encoded Next State and Output Table for the State Diagram. You may choose your own state encoding. [d] [3 pts] How many memory devices are needed to hold these states? 2 ECE 109 Fall 2019 Final Exam w/ Solutions Page 7 of 16
Name: __________________________ [4] [10 pts] Instructions [a] [ 5 pts] Using the figure below, illustrate the dataflow of the JSRR instruction. (Show where and when data moves during the execution phase of the instruction.) [b] [5 pts] Briefly (in English) describe each step shown in your diagram. (1) Contents of the PC is saved in R7. (2) Contents of the Base Register become the new PC ECE 109 Fall 2019 Final Exam w/ Solutions Page 8 of 16
Name: __________________________ [5] [20 points] Assembly Language and Machine Code [a] [14 pts] For the following table convert the assembly language commands to machine code. Assume that each command is located at PC=x3100. This code is NOT sequential. 1. STR R2, R5, x0C 0111 010 101 001100 2. LD R2, VIR 0010 010 1 1010 0100 x1A4 3. ST R2, RATLANTA 0011 010 0 1001 1100 x09C 4. BRnp RAMERICA Illegal, too far 5. LEA R5, SEBRING 1110 101 1 1111 1111 x1FF 6. AND R2, R5, x09 0101 010 101 1 01001 7. ADD R0, R2, R1 0001 000 010 0 00 001 8. LDI R3, DAYTONA 1010 011 0 0010 0110 x026 Assume the following Symbol Locations: SEBRING x3100 DAYTONA x3127 VIR x30A5 RATLANTA x319D RAMERICA x465E WATKINS x31DE BARBER x3164 LAGUNA x316A [b] [12 points] For the following table convert the machine language commands to assembly code. Assume that each command is located at PC=x3100. This code is NOT sequential. Assume the same symbol locations as above. If an offset matches a label, you MUST use the label in the assembly code. If no label matches, please express the offset in Hex. 1011 010 0 0110 1001 STI R2, LAGUNA x069 0011 011 0 0110 0011 ST R3, BARBER x063 1110 000 0 1101 1101 LEA R0, WATKINS x0DD 0001 011 001 1 0 1000 ADD R3, R1, x8 ECE 109 Fall 2019 Final Exam w/ Solutions Page 9 of 16
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: __________________________ [6] [25 points] Code Segments [a] [3 pts] Put x247 into R5 AND R5, R5, #0 ; clear R5 LD R5, NUM247 ; Load x247, too big for immediate mode BRnzp NEXT ; must jump around .Fill NUM21 .FILL x247 NEXT [b] [ 5 pts] Add x845 to R2, then subtract the result from R5, leaving the answer in R0 LD R4, MY8 ; Load x845 ADD R2, R2, R4 ; add to R3 NOT R2, R2 ; Make 2sC ADD R2, R2, #1 ADD R0, R2, R5 ; subtract R0=R5 – (R2+x845) BRnzp NEXT2 MY8 .FILL x845 NEXT2 [c] [3 pts] Clear R4 AND R4, R4, #0 ECE 109 Fall 2019 Final Exam w/ Solutions Page 10 of 16
Name: __________________________ [d] [8 pts] There is a string stored using .STRINGZ somewhere in the program, and the label LETRS is associated with that line of code. You know that the string contains only letters (no digits, spaces, punctuation, etc.). Count the number of upper-case letters (‘A’-‘Z’) that appear in the string, and put the result in R0. Remember: Only letters are in the string. Assume that LETRS is “nearby” to your code (i.e., within 200 instructions or so). LEA R1, LETRS AND R0, R0, #0 LD R3, NEG_a LOOP1 LDR R2, R1, #0 BRz NEXT2 ; 0 is end of string ADD R5, R2, R3 ;compare to Neg Z BRn NEXT1 ADD R0, R0, #1 NEXT1 ADD R1, R1, #1 BRnzp LOOP1 NEG_a .FILL x61 ; “a” NEXT2 [e] [6 pts] Add every fifth (5 th ) number between #3 and #69, starting with #3, and put the answer into R0. AND R0, R0, #0 ; clear counter for sum AND R3, R3, #0 ; clear counter for 5s AND R1, R1, #0 ADD R1, R1, #3 ; set R1 to 3 LD R2, NEG69 ADD R3, R3, #5 ; set to 5 LOOP1 ADD R3, R3, #-1 ; dec R3 BRp GO1 ; not 5 th value, skip ADD R0, R0, R1 ; 5 th value, add to sum ADD R3, R3, #5 ; reset 5 counter GO1 ADD R1, R1, #1 ; increment number 3 to 69 ADD R5, R1, R2 ; Test for -69 BRnp LOOP1 BRz HOME NEG69 .FILL #-69 HOME ECE 109 Fall 2019 Final Exam w/ Solutions Page 11 of 16
Name: __________________________ [7] [10 pts total] Binary Conversions Complete the following table. You must show your work to get full credit. If a number cannot be represented using a particular scheme, write “none” and explain why no representation is possible. Decimal 8-bit 2’s Complement 8-bit Sign Magnitude Hexadecimal (of 8-bit 2C Column) -37 1101 1011 10100101 xDB -9 1111 0111 1000 1001 xF7 28 0001 1100 0001 1100 x1C 75 01001011 01001011 x4B ECE 109 Fall 2019 Final Exam w/ Solutions Page 12 of 16
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: __________________________ [8] [20 pts] Code Counting 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: xEEEE R4: x1234 R5: x00FF R6: xC000 R7: x3150 ECE 109 Fall 2019 Final Exam w/ Solutions Page 13 of 16 After execution... R0 = ___x3209____________ R1 = ____xFFFF__________ R2 = ____x1010__________ R3 = ____x0020__________ R4 = ____x1234___________ R5 = ___x00FF___________ R6 = ___xC000__________ R7 = ____x3205_________
Name: __________________________ [9] [14] points Interrupts [a] [2 pts] When an internal interrupt occurs, due to events such as an illegal opcode, privileged operation, etc., this is called: Exception [b] [3 pts] When an interrupt occurs, where is the information on the currently executing code stored? Supervisor Stack [c] [3 pts] When an OS routine is called, where is the return information on the currently executing code stored? Register R7 [d] [3 pts] Which of the following are true about an interrupt service routine? Circle all that are true. A. It must always save and restore any register that it uses. X B. It can never be interrupted. C. It cannot call any other subroutine or service routine. D. It may push an output value onto the supervisor stack before returning. E. It must use the RTI instruction to return. X [e][3 pts] When an interrupt service routine returns, which of the following happen? Circle all that happen. A. The processor’s priority level is set to 0. B. The N, Z, and P bits are restored to their pre-interrupt state. X C. The address in R7 is copied to the PC. D. The interrupted code is notified that an interrupt has occurred. E. R6 is restored to its pre-interrupt value. X ECE 109 Fall 2019 Final Exam w/ Solutions Page 14 of 16
Name: __________________________ ECE 109 Fall 2019 Final Exam w/ Solutions Page 15 of 16
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 Fall 2019 Final Exam w/ Solutions Page 16 of 16 TRAP TABLE 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 512 1 0 1024 1 1 2048