The final exam will be broken into two components:
Part of the lab-based portion will require you to write assembly code on your laptops or lab machines, which is to be turned in via Canvas by the end of the class. The remainder of the lab-based portion will require you to draw circuits. You may NOT reference your previous submissions, and you may NOT access the Internet for any reason other than to submit your solution via Canvas. Violations of these rules will result in a 0 on the exam.
The written portion will consist of short-answer questions, and will require you to solve various problems.
You may bring the following materials into the exam:
Both the lab and the lecture-based exams are intended to be comprehensive. However, since there has not been an exam since after Lab 6, at least 65% of the exam will concern material from labs 7 through 11.
Overall, the exam may include material from the following sources:
I will not ask any questions which were not somehow covered by one of the above three sources.
It is also recommended to study your midterm exam, particularly any questions which you had difficulty with. I will occasionally repeat questions from the midterm exam on the final, especially if the class overall did poorly on a question (I want to make sure the concept is understood!).
Convert the following Java/C-like code into ARM assembly. The names of the variables reflect which registers must be used for the ARM assembly. Non-register variable names indicate a value that should be stored in memory.
int[] first = new int[]{0, 5, 27, 98}; int[] second = new int[]{1, 2, 8, 29, 42}; int[] result = new int[9]; int r0 = 0; int r1 = 0; while (r0 < 4) { result[r0] = first[r0]; r0++; } while (r1 < 5) { result[r0] = second[r1]; r0++; r1++; } for (r2 = 0; r2 < 9; r2++) { print_int(result[r2]); print_newline(); }
.equ SWI_Print_Int, 0x6B .equ SWI_Exit, 0x11 .equ SWI_Print_Char, 0x00 .data first: .word 0, 5, 27, 98 first_length: .word 4 second: .word 1, 2, 8, 29, 42 second_length: .word 5 result: .word -1, -1, -1, -1, -1, -1, -1, -1, -1 result_length: .word 9 .text .global _start _start: ;; r0: from psuedocode ;; r1: from pseudocode ;; r2: length of first ;; r3: length of second ;; r4: first base address ;; r5: second base address ;; r6: result base address mov r0, #0 mov r1, #0 ldr r2, =first_length ldr r2, [r2] ldr r3, =second_length ldr r3, [r3] ldr r4, =first ldr r5, =second ldr r6, =result begin_first_while: cmp r0, r2 bpl end_first_while ;; r7: first[r0] ldr r7, [r4, r0, LSL #2] str r7, [r6, r0, LSL #2] add r0, r0, #1 b begin_first_while end_first_while: begin_second_while: cmp r1, r3 bpl end_second_while ;; r7: second[r1] ldr r7, [r5, r1, LSL #2] str r7, [r6, r0, LSL #2] add r0, r0, #1 add r1, r1, #1 b begin_second_while end_second_while: ;; r7: length of result mov r2, #0 ldr r7, =result_length ldr r7, [r7] begin_for: cmp r2, r7 bpl end_for mov r0, #1 ldr r1, [r6, r2, LSL #2] swi SWI_Print_Int mov r0, #'\n swi SWI_Print_Char add r2, r2, #1 b begin_for end_for: swi SWI_Exit .end
An OR
gate.
An AND
gate.
A NOT
gate.
!A
refers to the negation of variable A
, and so on:
R = !A!B + AB
R = !ABC + ABC + A!B!C
Using the above equation, do the following:
R = A!B!C + BC
A | B | C | D | U |
---|---|---|---|---|
0 | 0 | 0 | 0 | |
0 | 0 | 0 | 1 | |
0 | 0 | 1 | 0 | |
0 | 0 | 1 | 1 | |
0 | 1 | 0 | 0 | |
0 | 1 | 0 | 1 | |
0 | 1 | 1 | 0 | |
0 | 1 | 1 | 1 | |
1 | 0 | 0 | 0 | |
1 | 0 | 0 | 1 | |
1 | 0 | 1 | 0 | |
1 | 0 | 1 | 1 | |
1 | 1 | 0 | 0 | |
1 | 1 | 0 | 1 | |
1 | 1 | 1 | 0 | |
1 | 1 | 1 | 1 |
Using the above truth table, write out the following:
U = !A!B!C!D + !A!BCD + !AB!CD + A!B!C!D + AB!C!D
U = !C!D + !AD
Design a two-bit arithmetic logic unit (ALU) that has the following operations:
AND
the two operands togetherOR
the two operands togetherNAND
the two operands together (that is, AND them and NOT the result)NOR
the two operands together (that is, OR them and NOT the result)Specifically, your ALU will have the following inputs:
Input Name | Input Description |
---|---|
A0 |
Bit 0 of the first operand |
A1 |
Bit 1 of the first operand |
B0 |
Bit 0 of the second operand |
B1 |
Bit 1 of the second operand |
S0 |
Select bit 0, used for specifying the operation to perform (see table below) |
S1 |
Select bit 1, used for specifying the operation to perform (see table below) |
Given the above inputs, your ALU will produce the following outputs:
Output Name | Output Description |
---|---|
U0 |
Bit 0 of the output |
U1 |
Bit 1 of the output |
As for which operation should be performed, this is based on the values of inputs S0
and S1
.
The table below described the values that correspond to the different operations:
Value for S1 |
Value for S0 |
Operation |
---|---|---|
0 |
0 |
AND |
0 |
1 |
OR |
1 |
0 |
NAND |
1 |
1 |
NOR |
For this task, you may use the following provided components, in unlimited supply:
S1
and S0
A
, B
, C
, and D
Z
.
They should be drawn using the symbol below:
Design a finite state machine (FSM) which will set a particular output U
to 1
each time 001
is encountered in a stream of inputs.
Inputs are specified one at a time, and are represented by the variable I
.
To illustrate, consider the following example, which shows different values of U
and I
over time, where each cell is separated by a clock tick:
I |
1 |
1 |
0 |
0 |
1 |
0 |
0 |
1 |
1 |
U |
0 |
0 |
0 |
0 |
0 |
1 |
0 |
0 |
1 |
For this task, you should be able to:
2 (two state bits needed)