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.

Five questions this page answers
Question
1What does a timing tool assume about two clocks?
2How is a divided clock declared?
3What does a clock group do to the paths between two groups?
4What does a clock group not do?
5Which 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

New words on this page
WordMeaning
Timing toolA program that checks, without simulating, that every signal arrives in time. Our lab uses one called OpenSTA.
Timing pathThe way of a signal from the clock input of one flip-flop to the data input of the next.
Deadline of a pathThe time by which the signal must be at the receiving flip-flop: its clock edge, less a small setup time.
SlackDeadline minus arrival time. Positive: the path is in time. Negative: it is late.
Timing constraintsThe text file that tells a timing tool about the clocks. The usual format is SDC, short for Synopsys Design Constraints.
Generated clockA clock declared as made from another clock, for example by a divider. It stays related to its parent.
Clock groupA set of clocks that the tool is told to treat as unrelated to the clocks of another group.
Unconstrained pathA path that the tool no longer checks. It has no deadline and no slack.
SKY130An open library of real gates and flip-flops with their delays. The lab netlist is made of its cells.
The four kinds of line on this page
LineWhat it tells the tool
create_clockA clock enters here, with this period. One line for each oscillator.
create_generated_clockThis pin carries a clock made from that other clock: here, divided by two.
set_clock_groups -asynchronousThe clocks of these groups are unrelated. Do not check paths between the groups.
set_clock_transitionHow steep the clock edges are. It only makes the numbers of this small lab realistic.

One Picture: The Paths of the Timing Lab

Eight Flip-Flops, Three ClocksStep through the picture. Each box is one flip-flop of the timing lab, named with its clock.
  • Power
  • Clock / reset
  • Processor
  • Peripheral
Eight Flip-Flops, Three ClocksStep through the picture. Each box is one flip-flop of the timing lab, named with its clock. component alarm_latch RTC clock: it sendsthe alarm component s1 core clock: firstflip-flop of thesynchronizer component s2 core clock: secondflip-flop of thesynchronizer component irq_receiver core clock: theprocessor side component div core clock: its outputis the peripheralclock component launch core clock: sends aregister write component capture peripheral clock: aregister of a slowblock component receive core clock: takes theanswer back the crossingone period to settlesafe to usecore to peripheralperipheral to coreperipheral clock
  1. component alarm_latchRTC clock: it sends the alarm
    • the crossing → s1
  2. component s1core clock: first flip-flop of the synchronizer
    • one period to settle → s2
  3. component s2core clock: second flip-flop of the synchronizer
    • safe to use → irq_receiver
  4. component irq_receivercore clock: the processor side
  5. component launchcore clock: sends a register write
    • core to peripheral → capture
  6. component captureperipheral clock: a register of a slow block
    • peripheral to core → receive
  7. component receivecore clock: takes the answer back
  8. component divcore clock: its output is the peripheral clock
    • peripheral clock → capture
  1. 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.

  2. 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.

  3. 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.

  4. 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.

  5. 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.

  6. 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.

The next core edge after each RTC edge, by hand
RTC edge, sendingNext core edge, receivingGap
14 ns20 ns6 ns
28 ns30 ns2 ns
42 ns50 ns8 ns
56 ns60 ns4 ns
70 ns80 ns10 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

  1. 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.

  2. Rule 2: Each oscillator gets one clock with a period.

    Nothing else gets a clock line of that kind.

  3. 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.

  4. 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.

  5. 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.

  6. 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.

Three clocks. hclk is the port where the core clock enters. rtc is the port of the RTC clock. div/Q is the output of the dividing flip-flop.
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]
The report without a group line
PathSending clockReceiving clockEdges the tool pairedSlack in ns
alarm_latch to s1rtccore28 and 30 ns1.6067
capture to receiveperipheralcore0 and 10 ns9.5696
s2 to irq_receivercorecore0 and 10 ns9.6067
s1 to s2corecore0 and 10 ns9.6067
div/Q to divperipheralcore0 and 10 ns9.8808
launch to capturecoreperipheral10 and 20 ns9.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.

The RTC clock in one group. The core clock and its child in the other.
set_clock_groups -asynchronous -group [get_clocks rtc] -group [get_clocks {core peripheral}]
The report with the group line
PathSending clockReceiving clockEdges the tool pairedSlack in ns
capture to receiveperipheralcore0 and 10 ns9.5696
s2 to irq_receivercorecore0 and 10 ns9.6067
s1 to s2corecore0 and 10 ns9.6067
div/Q to divperipheralcore0 and 10 ns9.8808
launch to capturecoreperipheral10 and 20 ns9.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 choiceThe alternativeWhat the choice buys, and costs
Tell the tool that two clocks are unrelatedLeave the crossing checkedNo false verdicts on a path that has no deadline. The path is now unchecked, so a slow crossing goes unseen.
Group whole clocksName each crossing path, one by oneOne line covers every crossing, also those added later. It also covers a crossing nobody planned.
A generated clock for the dividerA second create_clock on the divider outputThe 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.

The mistake: the peripheral clock is cut off from its parent.
set_clock_groups -asynchronous -group [get_clocks rtc] -group [get_clocks core] -group [get_clocks peripheral]
The report after the mistake
PathSending clockReceiving clockEdges the tool pairedSlack in ns
s2 to irq_receivercorecore0 and 10 ns9.6067
s1 to s2corecore0 and 10 ns9.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 page3 clocks, 6 paths
A phone chiphundreds of clocks, millions of paths

This section looks ahead. Four lines become a constraint file of thousands, and the same two questions decide whether it can be trusted.

  1. 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.

  2. 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.

  3. 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.

  4. 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.

STAOpenSTA in OpenROAD 26Q2 · sky130hd tt_025C_1v80 Liberty · simulator service
Edit the constraints, then run them

          
Expected: WNS 9.5696 ns path 1 slack 9.5696 ns
Read 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

Predict the outputThe same netlist. The RTC clock is now declared with a period of 15 ns, and there is no group line. The alarm path still needs 0.3055 ns to arrive and 0.0879 ns of setup time. What worst setup slack (WNS) does the tool report, in ns?
create_clock -name core -period 10 [get_ports hclk]
create_clock -name rtc -period 15 [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]
Read the netlist: design.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
ConceptWhat does a timing tool assume about two clocks it was told nothing more about?
ConceptHow is the output of a divider declared?
ConceptWhat does a clock group line do to the paths between its groups?
ConceptWhat does a clock group line not do?
ConceptThe RTC clock is grouped apart from the core clock. Which path must still be in the report?

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.

Practice

Report a problem with this page