24. Shared-ALU Expression Controller

Loading simulator…

Implement the controller using two state flip-flops:

Q1 Q0

with Gray encoding:

IDLE       = 00
OPERATION1 = 01
OPERATION2 = 11
DONE       = 10

The next-state equations are:

D1 = Q1·(Q0 + Start) + Q1'·Q0·res
D0 = Q1'·(Q0 + Start) + Q1·Q0·res'

Generate the controller outputs as:

Init = Q1'·Q0'
Busy = Q0
Done = Q1·Q0'

Generate the six instruction bits from the controller state:

INST[5] = Q1·Q0
INST[4] = Q1·Q0
INST[3] = Q1·Q0

INST[2] = Q1'·Q0
INST[1] = Q1'·Q0

INST[0] = Q0

This produces:

OPERATION1 → 000111
OPERATION2 → 111001

The process counter uses two flip-flops:

QC1 QC0

and produces:

res = QC1·QC0'

Therefore:

00 → res = 0
01 → res = 0
10 → res = 1

Reset the process counter whenever a new processing phase begins:

Init_Count = Q1'·Q0'·Start + Q0·res

The process-counter next-state equations are:

DC0 = Init_Count' ·(Busy·QC0' + Busy'·QC0)
DC1 = Init_Count' ·(Busy·(QC1 XOR QC0) + Busy'·QC1)

The counter therefore advances only while:

Busy = 1

and holds while the controller is in IDLE or DONE.

Control writes to the shared RESULT register using:

Result_Write = Busy·res'
RESULT_D = Result_Write·ALU_Result + Result_Write'·RESULT

Use Result_Write to load RESULT; otherwise, hold its value. RESULT stores both intermediate and final results. When res = 1, block further writes to prevent an extra addition.

During OPERATION1, the provided datapath executes:

RESULT ← A - B

After the process counter produces res = 1, the controller changes to OPERATION2.

During OPERATION2, the datapath executes:

RESULT ← RESULT + C

After the second res = 1, the controller enters DONE.

At that point:

Busy = 0
Done = 1

and RESULT contains:

(A - B) + C