Question.6
A higher-level controller must issue five instructions to a 4-bit Custom ALU.
Each instruction uses this 10-bit format:
INST[9:0] = COMMAND[9:6] | OPERAND1[5:4] | OPERAND2[3:2] | DESTINATION[1:0]
Register codes:
| Register | Code |
|---|---|
A_reg | 00 |
B_reg | 01 |
C_reg | 10 |
D_reg | 11 |
Required command codes:
| Command | Code | Operation |
|---|---|---|
LOAD | 0001 | R[DESTINATION] β DATA_IN |
MOV | 0010 | R[DESTINATION] β R[OPERAND1] |
ADD | 0110 | R[DESTINATION] β R[OPERAND1] + R[OPERAND2] |
DEC | 1001 | R[DESTINATION] β R[OPERAND1] - 1 |
For LOAD, both operand fields are ignored.
For MOV and DEC, OPERAND2 is ignored.
Encode every ignored field as 00 in this question.
The required register transfers are:
| Step | Register transfer |
|---|---|
| 1 | A_reg β DATA_IN |
| 2 | B_reg β DATA_IN |
| 3 | C_reg β B_reg - 1 |
| 4 | D_reg β A_reg + C_reg |
| 5 | A_reg β D_reg |
Which sequence of 10-bit instruction values executes these transfers in the correct order?
A datapath is the part of a digital system that stores, moves, and processes data.
It performs the operations required by an algorithm.
Functionality:
Stores input and intermediate values, routes selected data, performs operations, and stores results.
Typical datapath resources include:
Example:
A_Reg stores A
B_Reg stores B
MUXes route A_Reg and B_Reg
Adder calculates A + B
Result_Reg stores the sum
A controller sequences datapath operations.
It decides what the hardware does during each clock cycle.
Functionality:
Generates control signals and coordinates datapath activity according to the current processing step.
The controller determines:
Example:
LOAD state:
A_Load = 1
B_Load = 1
ADD state:
ALU_Op = ADD
Result_Load = 1
The controller sends control signals to the datapath. The datapath returns status signals to the controller.

Important: Data, control, status, and state have different roles. Mixing these roles makes a design difficult to verify.
A control signal commands a datapath resource to perform a specific action.
Important examples:
| Control Signal | Typical Action |
|---|---|
Load | Store a selected value in a register |
Src_Sel | Select a datapath source |
ALU_Op | Select an arithmetic or logic operation |
Count_Enable | Allow a counter update |
A status signal reports a condition calculated from datapath values. The controller uses it to choose a future action or state.
Common examples:
| Status Signal | Meaning |
|---|---|
Zero | Result equals zero |
Equal | Two values are equal |
Greater | One value is greater than another |
Negative | Signed result is negative |
Count_Done | Required iteration count is reached |
Architectural partitioning is required to separate data processing from operation sequencing.
It keeps:
Each design requirement is assigned to the datapath or controller.
| Requirement | Typical Location |
|---|---|
| Store data | Datapath |
| Select data | Datapath |
| Add or subtract | Datapath |
| Compare values | Datapath |
| Track algorithm progress | Controller |
| Select an operation | Controller |
| Enable register writes | Controller |
This separation provides:
Required behavior:
Y = A + B
Required datapath resources:
| Resource Group | Components | Functionality |
|---|---|---|
| Storage Registers | A_Reg, B_Reg, Result_Reg | Store operands and the final result |
| Adder | 1 adder | Calculate A_Reg + B_Reg |
Controller flow:

| State | Datapath Action |
|---|---|
LOAD | A_Reg β A, B_Reg β B |
EXECUTE | Result_Reg β A_Reg + B_Reg |
DONE | Hold the result and indicate completion |
The controller selects the actions. The datapath performs them.
Register Transfer Level (RTL) describes a digital system in terms of clocked registers and the operations performed between them.
RTL states:
Examples:
A β B
R β A + B
COUNT β COUNT + 1
Each left-side register updates at the specified active clock edge.
A micro-operation is one small register-level action performed during a clock cycle.
Micro-operations:
A β Input
TEMP β A + B
COUNT β COUNT + 1
RESULT β TEMP
Algorithm:
Y = (A + B) - C
Decomposed micro-operations:
TEMP β A + B
Y β TEMP - C
An algorithm is converted into a sequence of micro-operations.
TEMP preserves the intermediate sum for the later subtraction.
A conditional transfer occurs only when a control or status condition is true.
if Load = 1:
R β Data
if Greater = 1:
MAX β Data
If the condition is false, the destination register normally holds its current value.
Consider two transfers assigned to the same active edge:
Same-edge transfers:
A β B
B β A
Before the edge:
A = 0011
B = 1010
After the edge:
A = 1010
B = 0011
Both registers capture their pre-edge source values. One register does not receive the value just written into the other register on that same edge.
Important: Evaluate every right-hand side using values that exist immediately before the active edge.
A register enable controls whether the register captures a new value.
Enable = 1: Update
Enable = 0: Hold
Registers should update only when explicitly enabled.
| Action | Register Behavior |
|---|---|
| Load | Capture the selected input value |
| Hold | Keep the current stored value |
| Clear | Store 0 |
Example:
Clear = 1: R β 0
Load = 1: R β Data
Else: R β R
Priority defines which action wins when several register controls are active together.
Reset > Clear > Load > Enable > Hold
| Reset | Clear | Load | Enable | Operation |
|---|---|---|---|---|
| 1 | X | X | X | Reset |
| 0 | 1 | X | X | Clear |
| 0 | 0 | 1 | X | Load |
| 0 | 0 | 0 | 1 | Update |
| 0 | 0 | 0 | 0 | Hold |
Caution: If overlapping controls have no defined priority, the register behavior is ambiguous.
Source selection chooses which value drives a shared datapath input. A MUX performs the selection under controller command.
For four 3-bit source registers:
Src_Sel | Selected Source |
|---|---|
00 | Register A |
01 | Register B |
10 | Register C |
11 | Register D |


Destination selection chooses which register stores the value on a shared input path. The controller enables the selected register.
For four 3-bit Destination Register:
Dst_sel | Selected Register |
|---|---|
00 | Register A |
01 | Register B |
10 | Register C |
11 | Register D |

Dst_Sel enables one destination. Only the enabled destination captures the value. All other registers hold.

A shared data path or bus lets several registers reuse one transfer path.

For a transfer such as Register R β Register P, the controller selects Register P as the source and enables only Register R as the destination.
Data width and interpretation must be defined before values move between resources.
| Case | Example | Result |
|---|---|---|
| Zero extension | Unsigned 1010 extended from 4 to 8 bits | 00001010 |
| Sign extension | Signed 1010 extended from 4 to 8 bits | 11111010 |
| Truncation | Keep the low 4 bits of 10110110 | 0110 |
| Unsigned interpretation | 4-bit 1010 | 10 |
| Signed interpretation | 4-bit two's-complement 1010 | -6 |
Warning: The same bit pattern can represent different values. Extension and comparison logic must match the intended signedness.
A shared functional unit is one physical operator reused for several operations. It reduces duplicated hardware.
ALU_Op | Operation |
|---|---|
00 | ADD |
01 | SUB |
10 | AND (&) |
11 | OR (|) |
The controller changes ALU_Op; the same physical unit performs the selected operation.
This example uses 2-bit input registers and a 3-bit result so the ADD output can include the carry bit.

Two operand-selection MUXes choose the values presented to the functional unit.

The MUXes choose operands. ALU_Op chooses the operation. These are separate control decisions.

ALU_Op tells the shared functional unit which operation to perform.

Example:
ALU_Op = 00: Result = A + B
ALU_Op = 01: Result = A - B
ALU_Op = 10: Result = A & B
ALU_Op = 11: Result = A | B
SrcA_Sel = A
SrcB_Sel = B
ALU_Op = 01
ALU_Out = A - B
Changing ALU_Op to 00 changes the operation to A + B.
The functional-unit result may feed several register inputs.

Destination selection and write enable determine which register captures the result.
Important: Data present at a register input does not update the register unless its write enable is active at the clock edge.
An accumulator datapath stores a running value in ACC. The stored value is fed back to an adder so new data can be added over several clock cycles.
Accumulator operation:
1. Clear: ACC β 0
2. Load: ACC β Data
3. Accumulate: ACC β ACC + Data
4. Hold: ACC β ACC
Clear starts a new accumulation from zero.Load initializes ACC with a supplied value.Accumulate adds new data to the stored value.Hold keeps the current value when no update is required.
The controller selects one next value and enables ACC at the active clock edge. A defined priority prevents conflicting actions.
A control word groups several datapath controls into one binary value.
Field layout:
ALU_Op[3:0] | SrcA[1:0] | SrcB[1:0]
Field values:
ADD = 0001
A = 01
B = 10
Combined fields:
0001 01 10
Control word:
00010110
The binary word has meaning only after the field widths and positions are defined.
Control outputs should begin with safe defaults. Register write controls normally default to 0.
A_Load = 0
B_Load = 0
TEMP_Load = 0
RESULT_Load = 0
The active controller state then asserts only the required controls.
Safe defaults prevent:
Caution: Unless a multi-destination update is explicitly required, assert no more than one destination write enable for a shared writeback path.
Status signals are datapath outputs derived from stored values or a functional-unit result.
Zero = (Result == 0)
Equal = (A == B)
Greater = (A > B)
Negative = Result MSB
| Status | Practical Meaning |
|---|---|
Zero | All result bits are 0 |
Equal | Compared values match |
Greater | One value is larger under the selected signedness |
Negative | Most-significant bit of a signed result is 1 |
Carry | Unsigned addition produced a carry beyond the result width |
Overflow | Signed arithmetic result exceeded the representable range |
Carry and Overflow describe different arithmetic conditions and should not be treated as interchangeable.

Controller actions affect datapath values, and datapath values generate conditions that affect future controller decisions.
This feedback relationship forms the basis of an FSMD.
A Finite State Machine with Datapath (FSMD) combines a controller FSM with registers and functional units that process data over one or more clock cycles.
Controller state
+ Datapath registers
+ Datapath operations
+ Status conditions
= FSMD
| FSM View | FSMD View |
|---|---|
| Describes control states and transitions | Describes control states, data operations, and status-driven transitions |
| Outputs mainly represent control behavior | Outputs command register transfers and functional units |
| State stores progress | State stores progress while datapath registers store working values |

The state register stores the current step of the algorithm. Its value identifies the controller state whose actions are active during the present clock cycle.
The datapath registers store:
Example snapshot:
State = ADD
TEMP = 101101
COUNT = 0011
State represents control progress. TEMP and COUNT represent working data.
Each controller state activates a defined set of datapath controls.
State ADD:
SrcA_Sel = A
SrcB_Sel = B
ALU_Op = ADD
TEMP_Load = 1
Active-edge operation:
TEMP β A + B
Required behavior:
Y = (A + B) - C
Design transformation:

Possible datapath resources:
A_Reg, B_Reg, C_Reg
TEMP, Y
Shared ADD/SUB unit
Operand MUXes
Possible controller sequence:

Datapath activity controlled by each state:

| State | Register Transfer | Main Controls |
|---|---|---|
IDLE | Hold | Wait for Start |
LOAD | A_Reg β A, B_Reg β B, C_Reg β C | Operand loads active |
ADD | TEMP β A_Reg + B_Reg | Select A_Reg, B_Reg, and ADD |
SUB | Y β TEMP - C_Reg | Select TEMP, C_Reg, and SUB |
DONE | Hold Y | Pulse Done |
The same physical ADD/SUB unit can perform both arithmetic operations in different clock cycles.
A controller can remain in a processing state until the datapath reports completion.

The datapath calculates Count_Done. The controller uses it as a transition condition.
Assume Count_Done is combinationally generated from the registered counter.
Before Edge N:
COUNT = 2
Count_Done = 0
Edge N:
COUNT β 3
After Edge N:
COUNT = 3
Count_Done = 1
Edge N+1:
Controller uses Count_Done = 1
The status changes after COUNT updates. The controller captures the resulting transition at the following active edge.
Important: Do not reason as if a controller can use a newly registered value before the edge that creates it.
An Algorithmic State Machine (ASM) chart is a structured graphical representation of:
ASM does not replace an FSMD. It presents FSMD behavior in a clearer cycle-oriented form when an ordinary state diagram becomes crowded.
An ASM chart keeps the following information together:
State Actions
Decision Conditions
Conditional Register Updates
Next-State Flow
This makes it easier to derive controller outputs and verify what occurs in each cycle.
A state box names a controller state and lists actions that always occur while that state is active.
ACCUMULATE
SUM β SUM + Data
COUNT β COUNT + 1
These register updates occur at the active edge when their enables are asserted.
A decision box tests a condition, usually supplied by datapath status logic.
Count_Done?
A > B?
Each outcome selects a different control or next-state path.
A conditional output is asserted only on one selected decision path.
if Data > MAX:
MAX β Data
Here, Greater is a datapath status signal and MAX_Load is the controller output enabled on the true path.

| ASM Element | FSMD Implementation |
|---|---|
| State boxes | Controller states and unconditional control outputs |
| Decision boxes | Datapath status inputs to next-state logic |
| Register actions | Register enables, MUX selects, and functional-unit controls |
| Conditional outputs | Control outputs enabled only on a selected decision path |
| Connecting paths | Next-state flow |
ASM State Boxes
β Controller States / Control Outputs
ASM Decision Boxes
β Datapath Status Inputs
ASM Register Actions
β Register Enables / MUX Selects / Functional-Unit Controls
A multi-cycle design divides an operation across several clock cycles. Each clock cycle performs part of the required behavior.
Clock Cycle 1: Capture A, B, and C
Clock Cycle 2: TEMP β A + B
Clock Cycle 3: RESULT β TEMP - C
Clock Cycle 4: Indicate completion
Spreading operations across clock cycles can allow the same hardware to be reused.
An operation is dependent when it needs a result produced by an earlier operation.
TEMP β A + B
RESULT β TEMP - C
The subtraction must wait until TEMP contains the sum.
Independent operations do not require each other's results:
X β A + B
Y β C + D
They can theoretically execute in the same clock cycle if separate hardware and write paths are available.
Scheduling assigns each micro-operation to a clock cycle.
| Clock Cycle | Operation |
|---|---|
| 1 | Capture A, B, and C |
| 2 | TEMP β A + B |
| 3 | RESULT β TEMP - C |
| 4 | Completion |
A valid schedule respects data dependencies and available hardware resources.
Resource sharing reuses one physical functional unit for operations that occur in different clock cycles.
Clock Cycle 2: Shared ADD/SUB performs ADD
Clock Cycle 3: Same ADD/SUB performs SUB
Functional correctness alone does not prove resource sharing. The same physical resource must actually be reused.
Resource binding maps scheduled operations onto specific physical hardware.
| Scheduled Operation | Clock Cycle | Bound Physical Resource |
|---|---|---|
A + B | 2 | Shared ADD/SUB unit |
TEMP - C | 3 | Same shared ADD/SUB unit |
Both operations are bound to the same ADD/SUB unit at different times.
A temporary register stores an intermediate value until a later clock cycle uses it.
TEMP β A + B
RESULT β TEMP - C
TEMP is required because the sum must survive the clock edge and remain available for the later subtraction.
An iterative datapath repeatedly reuses the same resources until a status condition indicates completion.
Example:
SUM β SUM + Sample
COUNT β COUNT + 1
Repeat until:
COUNT == 4
Fixed latency:
Expression: (A + B) - C
Schedule: Capture, add, subtract, and complete
Result: Every transaction uses the same number of clock cycles.
Variable latency:
Operation: Process sensor samples until Data >= Limit
Result: The clock-cycle count depends on when the threshold is reached.
| Architecture | Area | Latency | Throughput |
|---|---|---|---|
| Single-cycle / Parallel | Higher | Low cycle count | Potentially high |
| Shared Multi-cycle | Lower | Higher | Lower |
| Pipelined | More registers and control | Multi-cycle | High steady-state |
Pipeline architecture is preferred in many high-throughput industry designs because, after the pipeline is filled, different processing stages can work on different data at the same time and complete results more frequently.