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?
One per gate input. Each gate's arrival is the maximum over its inputs' arrivals, plus its delay, and those input arrivals are already known when the gates are visited in topological order. The number of paths can grow exponentially with the depth of the logic (here 84 paths, in large designs astronomically many), but the work stays proportional to the size of the netlist. That's what makes static timing analysis practical for whole chips.
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
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:
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
arrival_times(gates, inputs_at=None): a dict of every net's arrival time.required_and_slack(gates, arrivals, outputs, T): a dict of slack for every net that reaches an output.critical_path(gates, arrivals, out): the list of nets from a primary input toout.
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
- Forward pass: arrival times. The inputs arrive at 0, so x1 = 3 and a1 = 2, and then
- Backward pass: required times. From 8 at both outputs, a1 and a2 must be ready by , and
- Slacks. Required minus arrival: o1 1, x2 2, a2 1, a1 4, x1 1, a 1, b 1, c 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
- 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.
- The failing path. It is a → x1 → a2 → o1, the carry.
- 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.
- 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?
The latest time a signal can arrive at a net depends only on the latest arrival times at the inputs of the gate that drives it, not on which paths led there. So if every gate is visited after all the gates that feed it, each net's arrival time is computed once, from numbers already known, and the work is one step per gate input. The same holds backward for required times. The longest path is still found, because the maximum at each gate carries the longest of the incoming paths forward, and tracing back through the latest-arriving inputs recovers it at the end. Listing paths would grow exponentially with logic depth; this grows only with the size of the netlist.
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.