Clock Domains in the Timing Constraints
A clock plan on paper helps nobody until the timing tool has it too. Hand it over in four lines, and learn to read what the report then leaves out.
You Will Be Able To
- Explain what a timing tool does with two clocks it was told nothing about.
- Declare an oscillator clock, a divided clock and a pair of unrelated clocks.
- Say what a clock group removes from a report, and what it does not build.
- Lesson
- S5.11
- Time
- 26 min
- Runs on
- OpenROAD
- Check
- 6 questions
The timing report shows the alarm path in green, with 1.6 ns to spare. That path runs from the real-time clock to the processor: two oscillators that share nothing. So where did the tool find a deadline for it?
Before You Start
You need Planning Clock Domains: a clock domain, related and unrelated clocks, and the two-flop synchronizer. This page uses its three clocks.
You also need the start of the timing track. A timing tool is a program that checks every path between two flip-flops against a deadline. Setup and Hold With Skew and Reading a Timing Report teach that. This page repeats the few words it uses.
The constraints are four kinds of line. The timing track has a full page on each kind: declaring clocks and clocks made from other clocks. The circuits of a crossing are in the RTL track, from The Two-Flop Synchronizer on.
| Question | |
|---|---|
| 1 | What does a timing tool assume about two clocks? |
| 2 | How is a divided clock declared? |
| 3 | What does a clock group do to the paths between two groups? |
| 4 | What does a clock group not do? |
| 5 | Which paths must still be in the report after the group line? |
The Idea: The Tool Believes What It Is Told
A timing tool looks at every path from one flip-flop to the next. It asks one thing: does the signal arrive before the deadline? The deadline comes from two clock edges. One edge sends the signal. A later edge takes it in.
To find those two edges the tool needs the clocks: where each one enters, and its period. That is all it knows. It does not know which oscillator is behind a clock. So it lines every pair of clocks up from time zero and treats them as related.
For a clock and its divided clock that is right. For two oscillators it is fiction. The tool finds some closest pair of edges, calls the gap a deadline and prints a verdict. A pass means nothing, because on the chip those edges drift. A failure means nothing either.
So the clock plan must reach the tool, and it takes three kinds of line. Each oscillator becomes a clock with a period. Each divided clock is declared as a child of its parent, so the pair stays related and stays checked. And each pair of unrelated clocks is put into two clock groups, so the tool stops checking between them.
That last line needs care. It removes checks from the report. It builds nothing: the synchronizer must already be in the design. And a group drawn too wide removes checks that the chip needs.
New Words
| Word | Meaning |
|---|---|
| Timing tool | A program that checks, without simulating, that every signal arrives in time. Our lab uses one called OpenSTA. |
| Timing path | The way of a signal from the clock input of one flip-flop to the data input of the next. |
| Deadline of a path | The time by which the signal must be at the receiving flip-flop: its clock edge, less a small setup time. |
| Slack | Deadline minus arrival time. Positive: the path is in time. Negative: it is late. |
| Timing constraints | The text file that tells a timing tool about the clocks. The usual format is SDC, short for Synopsys Design Constraints. |
| Generated clock | A clock declared as made from another clock, for example by a divider. It stays related to its parent. |
| Clock group | A set of clocks that the tool is told to treat as unrelated to the clocks of another group. |
| Unconstrained path | A path that the tool no longer checks. It has no deadline and no slack. |
| SKY130 | An open library of real gates and flip-flops with their delays. The lab netlist is made of its cells. |
| Line | What it tells the tool |
|---|---|
| create_clock | A clock enters here, with this period. One line for each oscillator. |
| create_generated_clock | This pin carries a clock made from that other clock: here, divided by two. |
| set_clock_groups -asynchronous | The clocks of these groups are unrelated. Do not check paths between the groups. |
| set_clock_transition | How steep the clock edges are. It only makes the numbers of this small lab realistic. |
One Picture: The Paths of the Timing Lab
- Power
- Clock / reset
- Processor
- Peripheral
- The alarm path
The top row is the alarm of the last page. One flip-flop on the RTC clock sends it. Two flip-flops on the core clock take it in. A fourth uses it.
- The register path
The bottom row is a register access. A core flip-flop sends a value to a flip-flop on the peripheral clock, and the answer comes back.
- Two clocks with a period
The constraints name the two oscillators first: the core clock with 10 ns and the RTC clock with 14 ns. The tool now knows every edge of both.
- A clock that is a child
The flip-flop div toggles on every core edge. Its output is the peripheral clock. The constraints declare it as a child of the core clock, divided by two. The tool works out its edges from the edges of the parent.
- What the tool does with the crossing
Told nothing more, the tool treats the RTC clock and the core clock as related. It finds the closest pair of edges and checks the alarm path against that gap.
- After the group line
One more line says that the RTC clock is unrelated to the other two. The tool stops checking the crossing. Every other arrow in the picture is still checked.
Read the diagram as text
- alarm_latch: RTC clock: it sends the alarm
- s1: core clock: first flip-flop of the synchronizer
- s2: core clock: second flip-flop of the synchronizer
- irq_receiver: core clock: the processor side
- div: core clock: its output is the peripheral clock
- launch: core clock: sends a register write
- capture: peripheral clock: a register of a slow block
- receive: core clock: takes the answer back
- alarm_latch → s1: the crossing
- s1 → s2: one period to settle
- s2 → irq_receiver: safe to use
- launch → capture: core to peripheral
- capture → receive: peripheral to core
- div → capture: peripheral clock
The timing lab: a netlist of eight flip-flops and two inverters from the SKY130 library.
The Smallest Example, Worked by Hand
Pair the edges as the tool does. Both clocks start with a rising edge at 0. The RTC clock has a period of 14 ns and the core clock 10 ns. For each RTC edge, find the next core edge.
| RTC edge, sending | Next core edge, receiving | Gap |
|---|---|---|
| 14 ns | 20 ns | 6 ns |
| 28 ns | 30 ns | 2 ns |
| 42 ns | 50 ns | 8 ns |
| 56 ns | 60 ns | 4 ns |
| 70 ns | 80 ns | 10 ns |
At 70 ns both clocks rise together and the pattern starts again. A signal sent on an edge is taken on a later edge, so the edge at 70 pairs with 80.
The tool takes the smallest gap, 2 ns, as the deadline of the alarm path: sent at 28, due at 30. The first flip-flop needs 0.3055 ns to bring the signal out. The second wants it 0.0879 ns before its edge. So the slack is 2 minus 0.3055 minus 0.0879, or 1.6067 ns. That is the green number of the opening.
The number is real arithmetic on a pair of edges that does not exist. On the chip the two oscillators drift. The gap between an RTC edge and the next core edge takes every value, down to zero.
Now the related pair. The peripheral clock rises at 0, 20, 40 ns: every second core edge. A signal sent by the core at 10 ns is due at the peripheral edge at 20 ns. That gap of 10 ns is real, on every chip, because one source makes both clocks.
The Rules
Rule 1: A timing tool treats any two clocks as related until it is told otherwise.
It pairs their closest edges and checks every path between them.
Rule 2: Each oscillator gets one clock with a period.
Nothing else gets a clock line of that kind.
Rule 3: A divided clock is declared as a generated clock of its parent.
Its edges then follow the edges of the parent, and paths between the two stay checked.
Rule 4: Unrelated clocks go into separate clock groups.
Paths between the groups become unconstrained. A generated clock stays in the group of its parent.
Rule 5: A clock group builds nothing.
It removes a check. The synchronizer must be in the design, and another kind of tool checks that it is.
Rule 6: After every such line, read what left the report and what stayed.
The path into the first flip-flop of a synchronizer leaves. The path into the second one stays.
Sources for These Rules
SDC is a format of the tool makers, not a standard of the IEEE. So rules 1 to 4 are stated as measured: OpenSTA 3.1.0 (the build 26Q2-1164-g08f67ee5ec of the pd engine), SKY130 cells at the typical corner, ideal clocks.
The same commands, with more cases: the two pages of the timing track that "Before You Start" names.
Rule 5: crossings are checked by tools of their own. Mehta, ASIC/SoC Functional Design Verification, chapter 8, section 8.5.
Rule 6 is review practice.
Now Run It
The lab at the end of this page gives the netlist of the picture and the constraints to a real timing tool. First the three clocks, with no word about how they relate.
create_clock -name core -period 10 [get_ports hclk]
create_clock -name rtc -period 14 [get_ports rtc]
create_generated_clock -name peripheral -source [get_ports hclk] -divide_by 2 [get_pins div/Q]
set_clock_transition 0.1 [all_clocks]| Path | Sending clock | Receiving clock | Edges the tool paired | Slack in ns |
|---|---|---|---|---|
| alarm_latch to s1 | rtc | core | 28 and 30 ns | 1.6067 |
| capture to receive | peripheral | core | 0 and 10 ns | 9.5696 |
| s2 to irq_receiver | core | core | 0 and 10 ns | 9.6067 |
| s1 to s2 | core | core | 0 and 10 ns | 9.6067 |
| div/Q to div | peripheral | core | 0 and 10 ns | 9.8808 |
| launch to capture | core | peripheral | 10 and 20 ns | 9.6067 |
Measured: OpenSTA 3.1.0 (the build 26Q2-1164-g08f67ee5ec of the pd engine), SKY130 cells at the typical corner, ideal clocks. Six paths, worst slack 1.6067 ns.
Rule 1 at work: the first row is the crossing. The tool paired the RTC edge at 28 ns with the core edge at 30 ns, as in the hand table. Rule 3 at work: the path from launch to capture is paired at 10 and 20 ns.
Now add the line that hands over the plan.
set_clock_groups -asynchronous -group [get_clocks rtc] -group [get_clocks {core peripheral}]| Path | Sending clock | Receiving clock | Edges the tool paired | Slack in ns |
|---|---|---|---|---|
| capture to receive | peripheral | core | 0 and 10 ns | 9.5696 |
| s2 to irq_receiver | core | core | 0 and 10 ns | 9.6067 |
| s1 to s2 | core | core | 0 and 10 ns | 9.6067 |
| div/Q to div | peripheral | core | 0 and 10 ns | 9.8808 |
| launch to capture | core | peripheral | 10 and 20 ns | 9.6067 |
Measured with the same tool. Five paths, worst slack 9.5696 ns.
Rule 4 at work: the row of alarm_latch to s1 is gone. Rule 6 at work: the row of s1 to s2 is still there, with a slack of 9.6067 ns. The second flip-flop of the synchronizer has a real deadline of one core period.
This lab leaves things out. The netlist is eight flip-flops, not a chip. Its clocks are ideal: no tree, no skew. And the tool says nothing about whether a crossing is safe. It only stopped looking at one.
Why It Is Built This Way
| Design choice | The alternative | What the choice buys, and costs |
|---|---|---|
| Tell the tool that two clocks are unrelated | Leave the crossing checked | No false verdicts on a path that has no deadline. The path is now unchecked, so a slow crossing goes unseen. |
| Group whole clocks | Name each crossing path, one by one | One line covers every crossing, also those added later. It also covers a crossing nobody planned. |
| A generated clock for the divider | A second create_clock on the divider output | The child follows its parent, delay included. The line must name the right parent. |
The second row cuts both ways. A group line is short because it is blind: it removes every path between the groups, the planned ones and the mistakes. That is why a clock plan is a list of crossings first, and a constraint file second.
The Trap: A Report That Got Shorter
Someone tidies the constraint file. Three clocks, so three groups: it looks neat, and the report is clean.
set_clock_groups -asynchronous -group [get_clocks rtc] -group [get_clocks core] -group [get_clocks peripheral]| Path | Sending clock | Receiving clock | Edges the tool paired | Slack in ns |
|---|---|---|---|---|
| s2 to irq_receiver | core | core | 0 and 10 ns | 9.6067 |
| s1 to s2 | core | core | 0 and 10 ns | 9.6067 |
Measured with the same tool. Two paths are left.
Count the rows: two, where there were five. The register path from launch to capture is gone, and so is its way back. Those paths have a real deadline of 10 ns on every chip. Nothing checks them now.
No error was printed. A report with fewer rows looks like a better report. The only defence is rule 6. After each such line, name one path that should have left and one that must have stayed. Look for both.
At Scale
This section looks ahead. Four lines become a constraint file of thousands, and the same two questions decide whether it can be trusted.
Modes
A clock mux makes two clocks reach the same flip-flops, never at once. The constraints say so for each mode. The Glitch-Free Clock Mux is where those two clocks come from.
A crossing can still have a limit
A word that crosses with a handshake must not take longer than the handshake allows. A limit on the delay of such a path replaces the removed check.
Two reviews
One tool checks that each crossing has its synchronizer. Another checks the timing of everything else. The clock plan of the last page is what both are compared with.
Real clocks
Here every clock is ideal. After the clock tree is built, each clock gets its measured delays. Generated Clocks in Depth shows what that does to a divided clock.
Try It
Run it. These are the constraints with the group line. Paths lists five paths, and the worst slack is 9.5696 ns.
Delete the last line and run again. The crossing from alarm_latch to s1 comes back, paired at 28 and 30 ns, with a slack of 1.6067 ns.
Now make the mistake of the trap section: put core and peripheral into two groups. Count the paths that are left.
Run to draw the timing paths here.
WNS 9.5696 ns path 1 slack 9.5696 nsRead the netlist: ap_crg_timing.v
// One clock-planning slice using the SKY130 cells of the div2 and cdc probes.
// The RTC request enters the core through s1 and s2. A *related* peripheral
// clock moves a different word from launch through capture and back to core.
module ap_crg_timing (hclk, rtc, alarm, data, pending, returned);
input hclk, rtc, alarm, data;
output pending, returned;
wire source_q, first_q, second_q, divided, feedback, launched, captured, inverted;
sky130_fd_sc_hd__dfxtp_1 alarm_latch (.CLK(rtc), .D(alarm), .Q(source_q));
sky130_fd_sc_hd__dfxtp_1 s1 (.CLK(hclk), .D(source_q), .Q(first_q));
sky130_fd_sc_hd__dfxtp_1 s2 (.CLK(hclk), .D(first_q), .Q(second_q));
sky130_fd_sc_hd__dfxtp_1 irq_receiver (.CLK(hclk), .D(second_q), .Q(pending));
sky130_fd_sc_hd__dfxtp_1 div (.CLK(hclk), .D(feedback), .Q(divided));
sky130_fd_sc_hd__inv_1 toggle (.A(divided), .Y(feedback));
sky130_fd_sc_hd__dfxtp_1 launch (.CLK(hclk), .D(data), .Q(launched));
sky130_fd_sc_hd__dfxtp_1 capture (.CLK(divided), .D(launched), .Q(captured));
sky130_fd_sc_hd__inv_1 invert (.A(captured), .Y(inverted));
sky130_fd_sc_hd__dfxtp_1 receive (.CLK(hclk), .D(inverted), .Q(returned));
endmodule
Check Yourself
Common Mistakes
Wrong Trust a positive slack on a path between two oscillators.
The tool paired two edges that keep no fixed distance on the chip.
Fix Declare the two clocks as unrelated, and build a synchronizer.
Wrong Give a divided clock a clock line of its own, or a group of its own.
It is cut off from its parent, and real paths between them go unchecked.
Fix Declare it as a generated clock and keep it in the group of its parent.
Wrong Read a clock group as a fix for a crossing.
It removes a check and builds no circuit.
Fix Check the synchronizer in the design, and the paths that stayed in the report.
Remember
- A timing tool treats two clocks as related and pairs their closest edges, until it is told otherwise.
- An oscillator gets a clock with a period. A divided clock is a generated clock of its parent.
- A clock group removes the checks between unrelated clocks. It builds no synchronizer.
- After each such line, check what left the report and what stayed.