CEG 2136 - Fall 2005 - Final
CEG 2136 - Fall 2005 - Final
Computer Architecture I
Section A: Prof. A. AlDaher
Section B: Prof. Misbah Islam
Signature: ______________________
Instructions:
For use of grader
1. Please write down your SECTION Number. A 20
2. No notes or texts are permitted. You have to abide by the B 30
University’s regulations regarding the conduct of exams. C 30
3. You may use the back of the pages for any side work that D 20
will not be marked. Total 100
4. Calculators are not allowed.
5. You can refer to the Appendix, ARC Reference
page for Assembly language instruction,
instruction and ALU codes and Microinstruction
word formats.
6. Write down any assumptions that you may make.
page 1 of 12
Part A: Arithmetic (20)
Assuming a system with a 6-bit biased exponent (i.e. excess 32) and a 10-bit two’s complement
mantissa. Perform the following operation.
157.3
- 12.6
By completing the following steps (give your answer for each step, each step has 2 marks)
(ii) Normalize the fixed-point binary number (place the radix point immediately to the left of the
leftmost, nonzero digit in the fraction)
(v) Convert 12.6 to normalized floating point number and rounded to 10 bits.
(vi) Form the two’s complement of the mantissa for the 12.6
(x) Convert your result into decimal and compare to exact answer.
page 2 of 12
Part B: ARC Instruction Set Architecture and Assembly Language (30)
Q2. (20) Subroutine and Linkages
The code in ARC assembler language of a main program Myprg is given below. It loads
two numbers num1 and num2 and passes these as arguments to a subroutine Mysub
that subtracts these numbers, stores the result onto the stack and returns to Myprog.
.begin
.org 0x1000 ! Start loading program at 4096
%sp equ %r14 ! Let %sp represent %r14
Myprg: ld [num1], %r1 ! %r1 0xDEF
ld [num2], %r2 ! %r2 0xABC
addcc %sp, - 4, %sp ! create space on the stack
st %r1, %sp ! push 0xDEF onto the stack
addcc %sp, - 4, %sp ! create space on the stack
st %r2, %sp ! push 0xABC onto the stack
call MySub ! Jump to Mysub
ld %sp, %r3 ! Store in r3 contents pointed to by sp
num1: 0xDEF
num2: 0xABC
.end
.begin
.org 0x1100 ! Start loading subroutine at 4096+100
Mysub: ld %r14, %r8 ! Pop 0xABC from stack
addcc %r14, 4, %r14 ! Go to down the stack
ld %r14, %r7 ! Pop 0xDEF from stack
subcc %r8, %r7, %r9 ! %r9 %r8 - %r7 0xABC – 0xDEF = -0x222
st %r9, %r14 ! store -0x222 in %r14
jmpl %r15+4, %r0 ! Return to main at ld %sp, %r3 instruction
.end
page 3 of 12
b. (8) Assuming that at the start of Myprog the stack pointer register (%r14 ) is
pointing to location 0x4000 and the stack base is 0x5000, show the contents of
the stack
i. Before the call is made from Myprog to Mysub.
0
Free Area
%r15
0xABC
0xDEF
%sp
Stack
stack base
232 – 4
0
Free Area
-0x222
%sp
Stack
stack base
232 – 4
c. (4) What is the contents of register %r3 upon return from Mysub? - 0x222
page 4 of 12
Q3: (10) Multi Address Instructions
The following table gives the instructions available for Three-Address, Two-Address and
the One-Address architecture machine:
Available Instructions
Three-Address Two-Address One-Address
SUB a, b, c ! c a - b MOV a, b ! b a LD a ! Acc a
DIV a, b, c ! c a/b SUB a, b ! b b –a ST a ! a Acc
DIV a, b ! b b/a SUB a ! Acc Acc - a
DIV a ! Acc Acc / a
a. Using the above instructions write down three programs to compute the function
X = (Z / (Y-W)) - Z.
b. Compute the size of your program in bytes. Assume 16-bit opcodes, 32-bit operands
and addresses, and that data is moved to and from memory in 32-bit chunks.
page 5 of 12
PART C: Data Path and Control (30)
Q4: (10) Micro-programmed Control Unit
1600:
1601:
1602:
1603
page 6 of 12
Q5. (20) Hard-wired implementation of Control Signals
The following is the HDL description of the control unit of a small-scale ARC computer.
It has four 32-bit general purpose registers and one 32-bit instruction register.
Module: Small_ARC_Control_Unit
INPUTS:
OUTPUTS:
MEMORY: Rs1 [32], Rs2 [32], Rd[32], ir[32], temp0[32].
END SEQUENCE.
END Small_ARC_Control_Unit.
a. (2) How many flip flops will be needed for the state machine for this control unit,
if ONE-HOT encoding approach is employed.
______7_______
page 7 of 12
b. (10) Draw the control unit flip flops and the interconnectivity between them
D Q D Q D Q D Q D Q
D Q D Q
FF4 FF5
c. (8) How will you generate the hardwired control signal for the
= CS0 + CS5
= CS1. IR[13:]’
= CS3 + CS5
page 8 of 12
PART D: Memory Systems (20)
Q6: Memory System Design
Given that RAM chips of type (4 word x 4-bit) shown above are available.
Using these chips draw the diagrams for
Identical to 7.4
page 9 of 12
c. (6) A Read Only Memory ROM should contain the following words.
Location Value
00 1001
01 1110
10 1010
11 0101
Using OR gates and one 2-to-4 Decoder design the circuit for this ROM.
OR OR OR OR
00
01
10
11
MUX
page 10 of 12
Appendix: ARC Reference Page:
a. ARC Instruction Formats:
page 11 of 12
e: ALU Function Codes:
page 12 of 12