EE1D2 — Lecture 1 Study Guide

Power, Timing & Digital Logic Fundamentals


Part 1: Core Concepts

1.1 Power Consumption in Digital Circuits

Every digital circuit consumes power in two main ways:

Static Power (Leakage)

Even when a circuit is idle, current leaks through transistors. This gives a constant background power draw:

Pstatic=VDDIstatic

Dynamic Power (Switching)

When transistors switch states, they charge and discharge capacitances. This power depends on how often switching occurs:

Pdynamic=αCVDD2f

Broadcast / Radio Power

Some devices (e.g. phones) also transmit power wirelessly. This is given directly and only applies for the fraction of time data is broadcast.

Energy and Battery Life

Total energy consumed over time:

E=Pstaticttotal+Pdynamictactive+Pbroadcasttbroadcast

Remaining battery energy → time remaining:

Tremaining=EleftPoperating mode

1.2 Flip-Flop Timing Constraints

A flip-flop is a memory element clocked by a clock signal. Its timing is characterised by three parameters:

Parameter Symbol Meaning
Clock-to-Q delay tcQ Time from clock edge until output is valid
Setup time tsu Data must be stable before clock edge
Hold time thold Data must remain stable after clock edge

Setup Time Constraint (Maximum Frequency)

For a signal to travel safely from one flip-flop to the next within one clock period:

TtcQ+tcomb+tsu

So the maximum clock frequency is:

fmax=1tcQ+tcomb,max+tsu

where t_comb,max is the delay along the longest combinational path between flip-flops.

Hold Time Constraint (Minimum Path)

Data must not arrive at the next flip-flop's input too quickly after the clock edge:

tcQ+tcomb>thold

If this is violated on any path, a buffer/delay element must be inserted on that path with a minimum additional delay of:

tdelay,min=tholdtcQtcomb

Clock Skew

When different flip-flops receive the clock at different times (due to routing), there is clock skew (tskew). Define tskew as the delay of the source flip-flop's clock relative to the target flip-flop's clock.

Updated constraints with skew:

Setup: Ttskew+tcQ+tcomb+tsu

Hold: tcQ+tcomb>tskew+thold

Sign convention: If the source clock is delayed relative to the target clock, tskew>0 (makes setup harder, hold easier). If the source clock is ahead, tskew<0.


1.3 SystemVerilog Literals

The format for a literal is: <size>'<sign><base><value>

Field Options Notes
size integer Number of bits
sign s or omit s means signed (two's complement)
base b, h, d, o Binary, hex, decimal, octal
value digits In the chosen base

Examples:

Two's complement reminder: Invert all bits, then add 1.


1.4 Common SystemVerilog Module Errors

When writing structural SystemVerilog, watch out for:

  1. Missing data types on ports — always declare logic (or wire/reg)
  2. Duplicate instance names — every gate instantiation needs a unique label
  3. Missing semicolons — every statement ends with ;
  4. Wrong port order — when using positional port mapping, order matters (inputs first, then outputs)
  5. Missing endmodule — every module declaration must close with endmodule

Part 2: Exercises


Exercise 1 — Phone Battery Life

Given:

How to solve:

Step 1 — Calculate static power: $$P_{\text{static}} = 0.8 \text{ V} \times 100 \text{ mA} = 80 \text{ mW}$$

Step 2 — Calculate clock frequency: $$f = \frac{1}{250 \text{ ps}} = 4 \text{ GHz}$$

Step 3 — Calculate dynamic power: $$P_{\text{dynamic}} = 0.06 \times 12 \text{ nF} \times (0.8)^2 \times 4 \text{ GHz} = 1.8432 \text{ W}$$

Step 4 — Calculate energy consumed so far: $$E_{\text{used}} = P_{\text{static}} \times 9 \text{ hr} + P_{\text{dynamic}} \times 3 \text{ hr} + 3 \text{ W} \times 3 \text{ hr} \times 0.2$$ $$= 0.72 + 5.5296 + 1.8 = 8.0496 \text{ W-hr}$$

Step 5 — Calculate remaining energy: $$E_{\text{left}} = 20 - 8.0496 = 11.9504 \text{ W-hr}$$

Step 6 — Find remaining time: $$T_{\text{not used}} = \frac{11.9504}{0.080} \approx \boxed{149 \text{ hr}}$$ $$T_{\text{used}} = \frac{11.9504}{0.080 + 1.8432 + 0.6} \approx \boxed{4.74 \text{ hr}}$$

Answer: c


Exercise 2 — Calculator Battery Requirement

Given:

How to solve:

Step 1 — Static power: $$P_{\text{static}} = 2 \text{ V} \times 60 \text{ mA} = 120 \text{ mW}$$

Step 2 — Dynamic power: $$P_{\text{dynamic}} = 0.05 \times 5 \text{ nF} \times (2)^2 \times 1 \text{ GHz} = 1 \text{ W}$$

Step 3 — Total energy needed: $$E = 0.120 \times 50 + 1 \times 5 = 6 + 5 = \boxed{11 \text{ W-hr}}$$

Answer: d


Exercise 3 — Clock Frequency and Hold Time (Circuit 1)

Given:

How to solve (max frequency):

Identify the longest combinational path between any two flip-flops: → 1 inverter + 1 NAND gate = 3 + 6 = 9 ns

Tmin=tcQ+tcomb,max+tsu=8+9+6=23 ns$$$$fmax=123 ns=43.5 MHz

Hold time check:

Identify the shortest combinational path: 1 NOR gate = 4 ns

tcQ+tcomb,min=8+4=12 ns>thold=5 ns

Hold time constraint satisfied. No delay needed.

Answer: b


Exercise 4 — Clock Frequency and Hold Time (Circuit 2)

Given:

How to solve (max frequency):

Longest path: NOR + NAND + XOR + inverter = 3 + 5 + 10 + 2 = 20 ns

Tmin=4+20+7=31 ns$$$$fmax=131 ns=32.3 MHz

Hold time check:

Minimum required combinational delay: $$t_{\text{comb}} > t_{hold} - t_{cQ} = 8 - 4 = 4 \text{ ns}$$

Check short paths:

Answer: a


Exercise 5 — Clock Skew (Circuit 3)

Given:

How to solve (max frequency):

With skew, check all paths using: Ttskew+tcQ+tcomb+tsu

Critical path: output of FF3 → input of FF1 (FF3's clock is ahead, so tskew=+5 ns from FF3's perspective as source):

T=5+5+(6+2)+8=26 ns$$$$fmax=126 ns=38.5 MHz

Hold time check:

For FF1/FF2 (no skew): 5+tcomb>3 → always satisfied.

For FF2 → FF3 path (FF3 clock delayed, so tskew=+5 ns for hold check): $$t_{cQ} + t_{\text{comb}} > t_{\text{skew}} + t_{hold}$$ $$5 + 6 > 5 + 3 \Rightarrow 11 > 8 \checkmark$$

For FF3 → FF1 (tskew=5 ns): 5+8>5+313>2

Hold time constraint satisfied.

Answer: a


Exercise 6 — Clock Skew (Circuit 4)

Given:

How to solve (max frequency):

FF3 (delayed) → FF1 (not delayed): tskew=+4 ns

Critical path: FF3 → FF1 with NOR + NAND + inverter: $$T = 4 + 5 + (6 + 5 + 2) + 6 = 28 \text{ ns}$$ $$f_{\max} = \frac{1}{28 \text{ ns}} = \boxed{35.7 \text{ MHz}}$$

Hold time check:

For signals from FF1 → FF2 or FF3: tskew=+4 ns (target clock is delayed). Requirement: tcomb>thold+tskewtcQ=4+45=3 ns

Path FF1 → FF2 through inverter: tcomb=2 ns < 3 ns ❌

Fix: Replace inverter between FF1 and FF2 with a NOR gate (both inputs tied together), giving 5 ns > 3 ns ✓

Answer: a


Exercise 7 — SystemVerilog Literals

Part A: Convert literals to binary

Literal Reasoning Binary
8'b10010 8-bit binary, zero-extend 0001 0010
16'h4F2 Hex 4F2 → 12-bit binary, zero-extend to 16 0000 0100 1111 0010
-6'sd7 6-bit signed, 7 = 000111, two's complement → invert+1 11 1001
'd38 No size, decimal 38 10 0110

Part B: Express binary values as SystemVerilog literals

Value Type Reasoning Literal
0000 1001 binary 8 bits 8'b1001
01 1011 hexadecimal 6 bits, hex = 1B 6'h1B
11 0010 1110 decimal 10 bits, value = 814 10'd814
1111 0010 1001 signed binary 12 bits, two's complement of 0000 1101 0111 -12'sb11010111

Exercise 8 — SystemVerilog Debugging

Original (buggy) code:

module full_adder
    (input A, B, C_in,
     output S, C_out);
    logic X1, X2, X3;
    XOR g1 (A, B, X1)
    XOR g1 (X1, C_in, S)
    AND g2 (X1, C_in, X2)
    AND g3 (A, B, X3)
    OR  g4 (C_out, X2, X3)

The 5 errors:

# Error Fix
1 Ports have no data type Add logic to input and output ports
2 Two instances both named g1 Rename second XOR to g2 (and renumber others)
3 No semicolons after instantiations Add ; to every statement
4 OR g4 has output first (C_out, X2, X3) Reorder to inputs first: (X2, X3, C_out)
5 Missing endmodule Add endmodule at the end

Corrected code:

module full_adder
    (input  logic A, B, C_in,
     output logic S, C_out);

    logic X1, X2, X3;

    XOR g1 (A,   B,    X1);
    XOR g2 (X1,  C_in, S);
    AND g3 (X1,  C_in, X2);
    AND g4 (A,   B,    X3);
    OR  g5 (X2,  X3,   C_out);

endmodule

Quick Reference

Power Formulas

Formula When to use
Ps=VDDIstatic Always (leakage)
Pd=αCVDD2f During active operation
E=Piti Total energy over time

Timing Formulas

Constraint Formula Purpose
Setup (no skew) TtcQ+tcomb,max+tsu Find max frequency
Setup (with skew) Ttskew+tcQ+tcomb,max+tsu Find max frequency
Hold (no skew) tcQ+tcomb,min>thold Check hold violation
Hold (with skew) tcQ+tcomb,min>tskew+thold Check hold violation