CIT593 Online: Introduction to Computer Systems Spring 2021 Midterm Exam Dr.
Instructions: Complete all problems in the space provided, if you need more space you may add it in this word document. This exam will be uploaded into Gradescope by you; if your work isn’t clear, you are less likely to receive partial credit.
Specifics on what can be used during the exam are available in the instructions tab of the exam.
Part I – Short Answer Questions {20 points} (Provide brief answers to the following questions)
Copyright By PowCoder代写 加微信 powcoder
1. Convert the following #s from binary to unsigned HEX, unsigned decimal and then 2’s complement decimal:
c) 10000000
2. The following are 2’s complement binary numbers. Perform the following operations & indicate if any of the operations generate overflow. Leave answers in decimal form.
a) xBB + xD
b) 11 – 111
c) 01110100 + 00111011
3. There exists a 64-bit format for floating point numbers (IEEE 754 – double-precision). It works very similarly to the 32-bit format, except with the following format change:
1 00000000111 1010000000000000000000000000000000000000000000000000
Use these hints on bias determination to answer the questions below:
The 32-bit IEEE 754 format has an 8-bit exponent field, which has a bias of 127 The 16-bit IEEE 754 format has a 5-bit exponent field, which has a bias of 15
a) Accounting for the bias, what is the exponent for the number shown above? Click or tap here to enter text.
b) What is the final number? Click or tap here to enter text.
c) E.C. (1 point): What is the most positive (non-infinite) # that we can represent in this 64-bit IEEE 754
format? Click or tap here to enter text.
# to convert
Unsigned decimal
2C decimal
Answer (in decimal)
Overflow? (Yes or No)
Exponent (11-bits)
Fraction (52-bits)
4. Number the following types of memory in order of speed (1 for fastest, 4 for slowest):
Main Memory Register File Disk
5. (True / False) The register file only contains data (Select one by putting an “X” between the brackets) [ ]True [ ]False
6. State the difference between the assembler and the loader.
7. What reason do you think the LC4 ISA designers made the JSR instruction jump to addresses that are multiples of 16?
8. Why doesn’t the LC4 ISA have more than 1 immediate arithmetic instruction?
9. How does the propagation delay of logic gates influence the clock speed of a CPU?
10. Why does the architecture require multiport memory? (NOTE: multiport refers to how many locations we can read/write to)
Part II – Long Form Questions
1. {10 points TOTAL} Answer the questions below using the sequential logic circuit shown here (note: the
devices in this circuit are D-Flip-Flops):
CLK Q0 Q1 Q2
a) {5 points} Complete the timing diagram for outputs Q0, Q1, and Q2: CLK
Q0 0 Q1 0 Q2 0
b) {2 points} Explain what would happen if the DFFs were replaced with D-Latches (where the CLK would be attached to the first D-Latch’s WE input)
c) {2 points} If a DFF has a delay of 4ns, how fast could the CLK be set and still have the above circuit function?
d) {1 point} What do you think the purpose of this circuit is?
2. {10 points TOTAL} To answer parts (a)-(d) use the following logic function: Y = (A AND Y) NAND (B’ OR Y)
a) {3 points} Implement the Boolean function using logic gates only
b) {3 points} Create a truth table for the Boolean function above:
c) {4 points} Implement the Boolean function using transistors. Implementations with the fewest number of transistors will receive the highest number of points.
3. {15 points} The table below shows the contents of a region of User Program Memory in PennSim. First convert the machine instructions you see here to an equivalent sequence of assembly instructions so you can read them. Write your answers directly in the tables below. After you have done this, show what would happen when the program is executed by filling in the second table which shows the state of all of the registers at the start of each instruction cycle. For the register values R0-R7 you only need to fill in the value of the register that has changed from the previous cycle, if any. Keep the PSR in HEX. For R0-R7 you may use either decimal or HEX (but indicate which is which with a leading # or x). Hint: start by looking at the four bit opcode – be careful how you break up the 16 bit fields, one bit can make a big difference.
Machine Instruction
0100011000101001
0000100000000010
1010000111001111
1100010111011010
0000000110110110
Assembly Instruction
PC PSR R0 R1 R2 R3 R4 R5 R6 R7
Instruction0 1 2 3 4 5 Cycle
NOTE: this column is state of the machine when your program begins. Refer to this column when you execute your first assembly instruction.
4. {15 points} Write an LC4 assembly subroutine that initializes a range of user data memory to either 0 or –1, depending on its existing contents and return # of non-empty locations that were encountered.
Here is a pseudocode version of the subroutine:
SUB_INIT_MEMORY (start_addr, range) {
count = 0 ;
curr_addr = start_addr ;
while (curr_addr < start_addr + range )
if ( dmem[curr_addr] equals 0) {
dmem[curr_addr] = -1 ;
dmem[curr_addr] = 0 ;
count = count + 1;
curr_addr = curr_addr + 1 ;
return count ;
As an example of its use, if the subroutine was called as follows:
start_addr = x2000 ;
range = x0004 ;
SUB_INIT_MEMORY (start_addr, range) ;
Data memory before subroutine was run:
Address Contents x2000 x1234 x2001 x5432 x2002 x0000 x2003 xFFFF
In this example, count would be equal to decimal “3” Requirements:
• Inside your subroutine you must check if the memory starting address is valid
• Inside your subroutine you must check if the end memory address is valid
• If either of the two above conditions are not valid, return count = -1.
• You must write assembly instructions to initialize registers and “call” your subroutine
• You must use labels, your last label must be “END”
• You must comment your code, so we can grade it more easily!
Data memory after subroutine was run:
Address Contents x2000 X0000 x2001 X0000 x2002 xFFFF x2003 X0000
a) {1 point} List and explain (in the context of the pseudocode) your register assignments first:
b) {14 points} Write your LC4 assembly program here. Your code must also be commented to explain significant components of your program (points deducted without them).
c) Extra Credit {5 points}:
Enhance your subroutine by giving it the following functionality. Have the subroutine take in a third argument: flip. If flip =0, the program works the same way it did before, but if flip =1, the subroutine should then initialize the memory locations to the opposite initial value. Example: if your subroutine set locations in memory that were non-zero (prior to the run) to be 0 after the subroutine runs, then by setting flip =1, it would set them to -1 instead (and vice-versa for memory locations that were zero initially). Update your subroutine as follows:
SUB_INIT_MEMORY_EC (start_addr, range, flip)
{EC: 5 points} This device can store 1 bit of data. The data can be read from this device and it can be written to it as well. Generate a timing diagram for this device to show how data can be read from it and how data can be written to it.
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com