S349 of 55
0 XP
  1. Hook
  2. Predict
  3. Name it
  4. Check
  5. Explain

S3 · Lesson 49 · Timing lab

Arrival times, required times, slack and the critical path of a gate netlist

Lesson 16 computed slack for one path at a time. A real design has billions of paths, far too many to list, yet a static timing analyzer finds the worst one in time proportional to the number of gates. The trick is that the latest arrival at a net depends only on the latest arrivals at its gate's inputs, so one forward pass in topological order gives every net's arrival time, and one backward pass gives every net's required time. In this lab you'll write that analyzer for a gate netlist: arrival times, required times and slack, and the critical path a timing report prints.

Predict

A netlist has 18 gates, and between its inputs and outputs there are 84 distinct paths. How many gate-delay additions does a static timing analyzer need to find every net's latest arrival time?

Name it

The netlist

A netlist is a dictionary from each gate's output net to its delay and its input nets:

FA = {'x1': (3, ['a', 'b']), 'a1': (2, ['a', 'b']),
      'x2': (3, ['x1', 'c']), 'a2': (2, ['x1', 'c']),
      'o1': (2, ['a1', 'a2'])}

This is a full adder: x2 is the sum and o1 the carry. Nets that no gate drives (a, b, c) are primary inputs, arriving at time 0 unless given.

Forward: arrival times

AT(g)=maxn∈inputs(g)⁡AT(n)+dg

Visit gates in topological order, or compute each net's arrival by recursion with memoization, so each is computed once.

Backward: required times and slack

Each output must arrive by the clock period T. A net that feeds several gates must arrive early enough for the most demanding one:

RT(n)=min⁡(T if n is an output,ming∈fanout(n)⁡RT(g)−dg)

Slack = RT − AT. A negative slack anywhere means some path through that net is too slow. The slack of a net equals T minus the longest complete path through it.

The critical path

From an output, step back each time to the input that arrives last (the first one listed, on a tie), until reaching a primary input. The delays along that path add up to the output's arrival time.

What you'll write

  1. arrival_times(gates, inputs_at=None): a dict of every net's arrival time.
  2. required_and_slack(gates, arrivals, outputs, T): a dict of slack for every net that reaches an output.
  3. critical_path(gates, arrivals, out): the list of nets from a primary input to out.

The tests check your answers on the full adder and against brute-force enumeration of every path in randomly generated netlists.

Worked example

Find the arrival times and slacks in the full adder with T = 8.

Show the solution
  1. Forward pass: arrival times. The inputs arrive at 0, so x1 = 3 and a1 = 2, and then x2=max⁡(3,0)+3=6a2=max⁡(3,0)+2=5o1=max⁡(2,5)+2=7
  2. Backward pass: required times. From 8 at both outputs, a1 and a2 must be ready by 8−2=6, and rx1=min⁡(8−3,6−2)=4rc=min⁡(5,4)=4ra,b=min⁡(4−3,6−2)=1
  3. Slacks. Required minus arrival: o1 1, x2 2, a2 1, a1 4, x1 1, a 1, b 1, c 4.
  4. Critical path. The nets with the least slack, a (or b), x1, a2 and o1, form the critical path.

Answer arrivals x1 3, a1 2, x2 6, a2 5, o1 7; slacks o1 1, x2 2, a2 1, a1 4, x1 1, a 1, b 1 and c 4, with the critical path through a, x1, a2 and o1.

Worked example

The clock tightens to T = 6. Which nets fail, and what would fix them?

Show the solution
  1. New slacks. Every slack drops by 2: o1, a2, x1, a and b go to −1, x2 to 0, and a1 and c stay positive at 2.
  2. The failing path. It is a → x1 → a2 → o1, the carry.
  3. Fixes. A faster AND for a2 (1 instead of 2), or a carry computed from a, b and c directly (the carry-lookahead idea of lesson 8), would recover the cycle.
  4. What wouldn't help. Speeding up a1, since it already has slack.

Answer o1, a2, x1, a and b fail at −1 along the carry path; a faster a2 or a lookahead carry fixes it.

Check

Step 1. Write arrival_times(gates, inputs_at): the latest arrival time of every net.

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Check

Step 2. Write required_and_slack(gates, arrivals, outputs, T): required times backward from the outputs, and each net's slack.

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Check

Step 3. Write critical_path(gates, arrivals, out): the path that sets an output's arrival time.

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Explain why

Why can a static timing analyzer find the worst path without listing all the paths?

Practice

Keep practicing

3 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.