FinEx CEG2136F2018 Practiceq
FinEx CEG2136F2018 Practiceq
Q1.4 An arithmetic unit performs basic operations on two numbers A and B, under the control
of two bits S and Cin., as shown in the following table:
S Cin = 0 Cin = 1
0 F = A + B (addition) F = A + 1 (increment A)
1 F = A - 1 (decrement A) F = A + B’+ 1 (subtraction)
The following combinational circuit (multiplexor and full adder) is used to implement the
functions described above for bit i. Select from the following combinations of multiplexor inputs
which set of logic values implements correctly the above functions
S C in
Q2.1 At some point, the content of PC of the basic computer is 3AF (all numbers are in
hexadecimal) and the content of AC is 2EC3, as shown in the following table. The content
of memory is partially given below, as well:
b. Show the operands and the binary operation that will be performed in the AC when the
instruction is executed.
c. Fill out the last column (“Content after instruction execution”) of the above table with
the contents of registers PC, AR, DR, AC, and IR in hexadecimal and the values of E,
I and the sequence counter SC in binary, all shown at the end of the instruction cycle.
The machine code of this program is stored in a memory unit of 1 kilo-word of 16 bits
implemented on an Altera FPGA; give the Quartus .mif file that describes this program
Addr +0 +1 +2 +3 +4 +5 +6 +7
100 2107
108
110
Q4.2 You have to expand the instruction list of your textbook basic computer with three more
instructions (ASR, DIV, TAT) as shown in the following table; both circuits of the datapath
and the control unit need to be extended.
The datapath has to be redesigned to allow your DR register to support the following operations:
LDDR = x T4: DR <- (bus) /Transfer value from bus to DR
INRDR = y T3 : DR <- DR+1 /Increment DR
CLRDR = z T3: DR <- 0 /Clear DR
SHRDR = v T3 + w T4: DR <- shr DR /Shift right DR
Design and draw the logic diagram of DRi (bit i of register DR), using any type of combinational
circuits and a JK flip-flop.
Q5.1 RTL notation is used in the following table to describe the FETCH cycle of a memory reference
instruction. Give short explanations of the respective microoperations in the last column
T1 IR M [AR]
PC PC 1
AR IR(11 0)
I IR(15)
I D7' T3 AR M [ AR]
DIV
Q5.2b Derive the equations of the control signals from the above table:
Question 1
A3 A2 A1 A0 B3 B2 B1 B0 S3 S2 S1 S0
M C4
(binary) (binary) (binary)
1101 0110 0
1101 0110 1
b) Given that 2’s complement representation is employed in this circuit, convert to decimal the
binary numbers in the following table:
A3 A2 A1 A0 B3 B2 B1 B0 S3 S2 S1 S0
M C4
(decimal) (decimal) (decimal)
Question 4
Two memory-reference instructions in the Basic Computer are to be changed to the instructions
specified in the following table.
Symbol Opcode Symbolic designation Description in words
ADM 001 Add AC to memory
BNA 011 If ( then Branch if AC is negative
In the following table, write down the necessary micro-operations (in RTL) to perform the
execution phase of each instruction. Note that the execution phase of such type of instructions
starts at T4. See figures 2 and 3 from Annex.
Note that the value in AC should not be changed by the execution of any instruction unless the
instruction specifies a change in its content. To this extent you can use TR to store the content of
AC temporary.
ADM
Column (3) of the following table shows the content of a memory segment of the Basic
Computer that stores a machine language program and its operands.
1. Convert from binary to hexadecimal both the address and the memory contents (columns
(1) and (3)) and write your results in columns (2) and (4), respectively.
2. Use Table 6 from Annex to convert the machine language program (stored in the first six
memory locations) to symbolic operation codes (assembly language). Write the assembly
language instructions in the corresponding cells of column (5) of the above table. Use
hexadecimal representation for the address field of the instructions.
3. Fill out the last column (6) of the table with the content of the accumulator after the
execution of each instruction.
Data register DR
Control Register
(Register bank)
Table 1: Starting micro-operations in the instruction cycle of the 8-bit mini computer
Instant Description Notation (RTL)
This cycle is not used to allow for the new value of the instruction to propagate in the
T2 controller (nothing)
T3 If X1 => it is a register - reference instruction that will be executed now T3 X1 : execute an RRI
(RRI) instruction (Table 4)
T3 If X0 or X2 , read the memory address of the operand and place it in AR, and T3 IR(6)’ : AR ← PC
increment PC. Recall that (X0 + X2 ) = IR(6)’
T3 IR(6)’ S’ : PC ←
T4 Read memory address into AR PC + 1
T4 IR(6)’ : AR ← M
T5 If indirect addressing, read the operand address from memory location pointed to by AR [AR]
T5 X2 : AR ← M [AR]
T5 If direct addressing, don’t do anything, as the operand address is already in AR since T6 T5 X0 : (nothing)
starting Execute the memory-reference instructions (MRI) described in Table 2 (see Table 2)
from T6
T6 Y0 : DR ← M [AR]
ADD Y0 = IR(6)’ IR(1) IR(0)’
T7 Y0 : AC ← AC + DR , SC ← 0
T6 Y1 : DR ← M [AR]
LDA Y1 = IR(6)’ IR(2)
T7 Y1 : AC ← DR , SC ← 0
T6 : (cycle not used to allow for the
STA Y2 = IR(6)’ IR(3) address bus to stabilize)
T7 Y2 : M [AR] ← AC , SC ← 0
BUN Y3 = IR(6)’ IR(4) T6 Y3 : PC ← AR , SC ← 0
ISZ (assuming that the T6 Y4 : DR ← M [AR]
next instruction is a T7 Y4 : DR ← DR + 1
memory-reference T8 Y4 : M [AR] ← DR
instruction, stored at 2 Y4 = IR(6)’ IR(5) T9 Y4 : if (DR = 0)S’ then (PC ← PC + 1)
memory locations T10Y4 : if (DR = 0)S’ then (PC ← PC + 1)
further down) T10 Y4 : SC ← 0
T6 Y5 : DR ← M [AR]
AND Y5 = IR(6)’ IR(1)’ IR(0)
T7 Y5 : AC ← AC ∧ DR , SC ← 0
T6 Y6 : DR ← M [AR]
SUB Y6 = IR(6)’ IR(1)’ IR(0)
T7 Y6 : AC ← AC − DR , SC ← 0
Table 4: Table 5:
Function table of the 8-bit ALU Function table of the 8-bit bus
O2O1O0 ALU operation S2 S1 S0 Register placed on the bus
000 F = AC + DR / addition 0 0 0 Memory
0 01 F = AC – DR / subtraction 0 0 1 AR
01 0 F = ashl AC / arithmetic shift left 0 1 0 PC
011 F = ashr AC / arithmetic shift right 0 1 1 DR
100 F = AC ∧ DR / AND 1 0 0 IR
101 F = AC ∨ DR / OR 1 0 1 AC
110 F = AC’ / 1’s complement 1 1 0 OUTA
111 F = DR / transfer DR to AC 1 1 1 None