Skip to content
GATEiit

GATE EC · Digital Circuits

ALU, data-path and control unit

Building bit-sliced ALUs and 2's-complement condition flags (Z, N, C, V), tracing micro-operation control signals across single-bus and multi-bus datapaths, and designing hardwired versus horizontal/vertical microprogrammed control memories.

Before you start

  • Arithmetic circuits →

    Full-adder chains and subtractor 2's-complement control lines form the arithmetic core of the ALU.

  • Multiplexers →

    ALU input modifiers (B, B', 0), operation selectors, and bus/register source selectors are implemented directly via multiplexers.

  • Finite state machines →

    Sequencing fetch, decode, and execute steps across clock cycles is an FSM driven by opcode, step counter, and status flags.

  • Machine instructions and addressing modes →

    Instruction opcodes and addressing modes define the exact micro-operation sequences the datapath and control unit must orchestrate.

This topic comes before: Instruction pipelining

Concept notes

1. Bit-Sliced ALU Design and Signed 2's-Complement Flags (C, V, N, Z)

An n-bit Arithmetic Logic Unit (ALU) combines parallel logic gates (AND, OR, XOR, NOT) with a binary ripple/CLA adder controlled by input modifiers (Binv muxing B,Bˉ,0,1) and C0, allowing a single adder to execute ADD, SUB (A+Bˉ+1), INC (A+0+1), DEC (A+0ˉ+0), and comparisons without duplicating adders.

After an n-bit operation producing result Fn−1…F0, four status flags update the Program Status Word (PSW):

  • Zero (Z): Z=Fn−1+Fn−2+⋯+F0‾ (1 iff result is all zeros).
  • Negative / Sign (N): N=Fn−1 (MSB).
  • Unsigned Carry (C): C=Cn (carry out of MSB; note in subtraction A−B implemented via A+Bˉ+1, Cn=1 means A≥B with no borrow!).
  • Signed Overflow (V): V=Cn−1⊕Cn (occurs exclusively when two same-sign inputs produce an opposite-sign MSB: V=Aˉn−1Bˉn−1∗Fn−1+An−1Bn−1∗Fˉn−1!).
1-Bit Modular ALU Slice & Signed Flag Generation (C_out, V = C_{n-1} ⊕ C_n, N, Z) A_i B_i B / B' B_inv AND / OR / XOR Full Adder A_i + B* + C_in C_in C_out Op MUX F_i ALU Status Flags V = C_{n−1} ⊕ C_n (Signed ovf) C = C_n (Unsigned carry) N = F_{n−1} (MSB sign bit) Z = NOR(F_{n−1}..F₀) SUB uses B_inv=1, C_0=1
Modular 1-bit ALU slice combining input inversion MUX, Full Adder, bitwise logic, and signed/unsigned status flag generation.

2. Single-Bus vs Multi-Bus CPU Datapaths and Register Transfer Timing

The Datapath interconnects General-Purpose Registers (R0–Rk), PC, IR, MAR/MDR, and the ALU via tri-state/MUX buses. Bus count directly dictates cycles per instruction:

  • Single-Bus Datapath: Only one value can travel on the bus per clock cycle! Therefore a two-operand ALU instruction (ADD R1, R2, R3 →R3←R1+R2) needs temp latches Y and Z and 3 execute cycles:
    1. R1_out, Y_in (latch operand 1 in Y),
    2. R2_out, SelectY, Add, Z_in (drive operand 2 on bus, compute ALU, capture in Z),
    3. Z_out, R3_in (write result back).
  • Three-Bus Datapath (Bus A, Bus B feeding ALU inputs; Bus C feeding register writeback): eliminates Y and Z completely, completing R3 <- R1 + R2 in 1 execute clock cycle!

3. Hardwired vs Microprogrammed Control Units

Feature Hardwired Control Unit Microprogrammed Control Unit
Implementation Combinational gates / PLA driven by IR, step counter T, & Flags Control Store ROM holding microinstructions indexed by μPC
Execution speed Fastest (combinational delay only) Slower (Control ROM access overhead per micro-cycle)
Modification / Bug Fix Requires silicon hardware redesign Easy firmware/microcode update
Best architecture fit Simple regular RISC ISAs & pipelined cores Complex variable-length CISC instructions
Hardwired Combinational Control vs Microprogrammed Control Store Architecture Hardwired Control (Fast / RISC) IR Opcode T₀..T_k + Flags Decoder & PLA Logic Signals 1 gate propagation delay; hard to patch Microprogrammed Control (Flexible / CISC) μPC Control Memory ROM Ctrl Word Horizontal (no decoder) vs Vertical (encoded)
Hardwired PLAs compute control signals directly in combinational logic, whereas Microprogrammed units fetch pre-stored control words from ROM.

4. Horizontal vs Vertical Microprogramming & Control Memory Sizing

Every microinstruction word in Control Memory contains (1) Control Signal Fields, (2) Condition/Branch Select, and (3) Next-Address (μPC) Field:

  • Horizontal Microprogramming: devotes 1 dedicated bit per control signal (k control signals   ⟹  k bits!). Zero external decoders, fast, maximum parallelism (can activate any independent signals simultaneously!).
  • Vertical Microprogramming: encodes mutually exclusive signals into ⌈log⁡2m⌉-bit fields routed through m-to-2m external decoders! Produces much narrower ROM width, at the cost of extra decoder delay and lost parallelism across signals sharing a field!
  • Total Control Store Capacity: ROM Size (bits)=(Number of microinstructions)×(Control bits+⌈log⁡2(Words)⌉+Condition bits).

Formulas to remember

Signed 2's-complement overflow flag VHere Bn−1∗=Bn−1 for ADD and Bn−1‾ for SUB (A−B).
V=Cn−1⊕Cn=An−1Bn−1∗Fn−1‾+An−1‾ Bn−1∗‾Fn−1
ALU arithmetic function modes via B-modifier
F=A+Y+Cin,Y∈{B,  B‾,  0,  1n}  ⟹  ADD, SUB, TRANS, INC, DEC
Horizontal vs vertical encoded field widthRemember the +1 idle ('none active') state inside a mutually exclusive vertical decoder group!
Whoriz=∑iNi bits,Wvert=∑i⌈log⁡2(Ni+1)⌉ bits
Zero & negative status flag Boolean expressions
Z=Fn−1+Fn−2+⋯+F0‾,N=Fn−1
Microprogrammed control store bit capacity
Size=M×(Wctrl+Wcond+⌈log⁡2M⌉)  bits

Common mistakes

  • Equating carry-out Cn=1 with signed overflow: Adding −1+2=+1 sets Cn=1 even though the signed result +1 is completely valid (V=Cn−1⊕Cn=0!).
  • Forgetting the idle ('no-op') state in vertical micro-encoding: N mutually exclusive control signals require ⌈log⁡2(N+1)⌉ bits, NOT ⌈log⁡2N⌉, whenever all signals can be off simultaneously (catching power-of-2 boundary traps like N=64  ⟹  7 bits!).
  • Thinking single-bus ALUs run in 1 clock cycle: Feeding two operands and writing back across one shared bus consumes 3 separate cycles via Y and Z latches.
  • Confusing borrow vs carry-out in A+Bˉ+1 subtraction: When subtracting via 2's complement addition, Cn=1 indicates NO borrow (A≥B unsigned), whereas Cn=0 indicates A<B!
  • Assuming microprogrammed control cannot handle conditional branches: Selecting next μPC via status flags inside the condition-select MUX enables looping and conditional jumps cleanly inside microcode.

Worked examples

Try each step yourself, then reveal the working.

Example 1: Evaluating Condition Flags C, V, N, Z on 8-Bit 2's-Complement Operations

numerical

An 8-bit ALU computes A−B via A+Bˉ+1, with A=1000 01012 (−12310 signed) and B=0001 00102 (+1810). Compute the 8-bit result F, carry C8, and signed overflow flag V.

  1. Step 1: Compute A + B_bar + 1 bit by bit

    Try it on paper first.

Example 2: Comparing Horizontal vs Vertical Microinstruction Word Widths

numerical

A processor has 120 control signals partitioned into 5 mutually exclusive functional groups of sizes 15,25,31,14, and 35 (each group also needs a 'none active' state), plus 1024 words of Control Memory and 8 branch conditions (1 unconditional + 7 flags). Compute the microinstruction width (in bits) under (a) Horizontal vs (b) Vertical control.

  1. Step 1: Compute Horizontal word width

    Try it on paper first.

Example 3: Tracing Fetch + Execute Cycles on a Single-Bus Datapath

conceptual

Count the minimum clock cycles required to execute SUB R1, R2 (R1←R1−R2, already fetched into IR) on (a) a single-bus datapath using latches Y, Z and (b) a 3-bus datapath.

  1. Step 1: Trace single-bus micro-steps

    Try it on paper first.

Example 4: Single Control Store Size Calculation with Horizontal Encoding

numerical

A microprogrammed CPU supports 64 machine instructions, each requiring at most 8 sequential microinstructions, using 48 unencoded horizontal control signals, 16 condition-code MUX inputs, and explicit next-address branching. Compute the exact Control Memory capacity in bytes.

  1. Step 1: Determine number of Control Memory words and field widths

    Try it on paper first.

Previous year questions

No official GATE EC question is tagged with this topic yet. The topic test below uses practice questions.

Topic test

8 questions: original practice questions, with GATE marking (MCQ wrong answers lose marks). Score 60% or more to pass. A new set is drawn each time.

Mark as mastered

Loading your progress…

My revision notes

Notes written by the GATEiit team against the official GATE EC syllabus; being checked by a reviewer. Updated 2026-11-29. Spotted a mistake? Use Report an issue on any question, or contact us.