Clocking at Scale: Many PLLs, Counted Crossings and Shared Clocks

A large chip has several PLLs and one block that owns them all. The price is a crossing wherever two of their clocks meet. The saving is every clock that can be stopped.

You Will Be Able To

  • Say why a large chip has several PLLs, and who is allowed to change one.
  • Count the clock groups and the crossings on the way of one piece of data.
  • Say when a shared clock may stop, and what must keep running to hear the outside world.
Lesson
S10.10
Time
26 min
Runs on
Your browser
Check
5 questions

A phone films a video. Between two recordings the chip stops every clock it can.

The next recording starts with a black first frame. The camera sent it, and no part of the chip was awake to take it.

Before You Start

You need Clock Sources and the Chip-Level Clock Tree: the crystal, the PLL, its reference clock and its lock.

You need Dividers and Clock Gates and The Glitch-Free Clock Mux: the clock gate, and the handover from one source to another.

You need Planning Clock Domains: related and unrelated clocks, and the crossing between them.

You need Clock Domains in the Timing Constraints: the clock group.

Five questions this page answers
Question
1Why does a large chip have several PLLs and not one?
2Who may change the rate of a PLL, and what happens to its users first?
3The camera sends a clock with its data. Where is the crossing?
4Three blocks take their clock from one PLL. When may that PLL stop?
5The cluster is moved onto the clock of the system. What does the count of the lab print?

The Idea: Many Sources, One Owner

The small chip had one PLL. One fast clock went to everything, and a divider made a slower copy for the peripherals. Every clock was related to every other, and only the real-time clock stood apart.

A phone cannot work like that. Its cores change their rate many times a second, as the last lesson showed. The memory pins need one exact rate, and the display needs another. If one PLL fed them all, a faster core would mean a faster display.

So each rate that must change alone gets a PLL of its own. The exercise chip has six. That answers one question and raises three.

First: who may touch a PLL? If each block set its own, two blocks on one PLL would fight. So one block owns all of them, the clock controller. Every other block asks, and the controller makes the change in a safe order.

Second: what do six PLLs cost? Their clocks are unrelated, so every signal between two of them is a crossing. On a large chip nobody knows the crossings by heart. They are counted, on the way of the data.

Third: what do they save? A clock that toggles uses power even when its block does nothing. So clocks are stopped, and shared clocks are stopped with care: only when every user has said yes.

New Words

New words on this page
WordMeaning
Clock controller of a chipThe block that owns every PLL, every clock mux and every clock gate. Clock controller for short.
Request for a clockA wire from a block to the clock controller. 1 means: I need my clock.
RetuneTo change the output rate of a PLL. The PLL has no lock while it retunes.
Safe clockA clock that keeps running while a PLL retunes. Here it is the crystal.
Stop requestA question from the clock controller to a block: may your clock stop? The block accepts or denies.
Signal channelA group of signals that go together from one block to another. Channel for short.
Forwarded clockA clock that travels beside its data, from the sender to the receiver, on a wire of its own.
Two-clock queueA small memory that is written on one clock and read on another. Engineers call it an asynchronous FIFO.
Activity wireA wire that goes to 1 when something arrives at a block whose clock is stopped. It needs no clock.

One Picture: The Clock Plan

The Clock Plan of ap_phoneStep through the picture. It starts with one crystal and one PLL and ends with a clock that the chip does not make.
  • Clock / reset
  • Pads
  • Processor
  • Bus
The Clock Plan of ap_phoneStep through the picture. It starts with one crystal and one PLL and ends with a clock that the chip does not make. component Clock controller owns every PLL, muxand gate component Crystal 25 MHz, thereference of all PLLs component pll_cpu 100, 200 or 400MHz component pll_sys 200 MHz, neverretuned component pll_mem memory pins; threemore PLLs like it component Cluster changes its rate withthe work component Network andcontrollers must keep one steadyrate component PHY of thecamera port uses the clock thatthe camera sends referencereferencereferenceclockclocksets the rateaskscrossing
  1. component Crystal25 MHz, the reference of all PLLs
    • reference → pll_cpu
    • reference → pll_sys
    • reference → pll_mem
  2. component pll_sys200 MHz, never retuned
    • clock → Network and controllers
  3. component Network and controllersmust keep one steady rate
  4. component pll_cpu100, 200 or 400 MHz
    • clock → Cluster
  5. component Clusterchanges its rate with the work
    • asks → Clock controller
  6. component pll_memmemory pins; three more PLLs like it
  7. component Clock controllerowns every PLL, mux and gate
    • sets the rate → pll_cpu
  8. component PHY of the camera portuses the clock that the camera sends
    • crossing → Network and controllers
  1. One source

    A PLL makes a fast clock from the crystal. With one PLL, every block of the chip would run from it.

  2. A rate that must change alone

    The cluster speeds up and slows down with its work. The network must not follow. So the cluster gets a PLL of its own.

  3. Six PLLs

    The same reason holds for the memory pins, the engines, the display and the fast ports. That makes six.

  4. One owner

    No block touches a PLL. The cluster asks the clock controller, and the controller makes the change in a safe order.

  5. A clock from outside

    The camera sends a clock beside its data. The PHY uses that clock. The crossing is behind the PHY, inside the chip.

Read the diagram as text
  • Clock controller: owns every PLL, mux and gate
  • Crystal: 25 MHz, the reference of all PLLs
  • pll_cpu: 100, 200 or 400 MHz
  • pll_sys: 200 MHz, never retuned
  • pll_mem: memory pins; three more PLLs like it
  • Cluster: changes its rate with the work
  • Network and controllers: must keep one steady rate
  • PHY of the camera port: uses the clock that the camera sends
  • Crystal → pll_cpu: reference
  • Crystal → pll_sys: reference
  • Crystal → pll_mem: reference
  • pll_cpu → Cluster: clock
  • pll_sys → Network and controllers: clock
  • Clock controller → pll_cpu: sets the rate
  • Cluster → Clock controller: asks
  • PHY of the camera port → Network and controllers: crossing

The clock plan of the exercise chip ap_phone. The lab of this page is a sheet of test code: it has no PLL as a circuit.

The Smallest Example, Worked by Hand

No simulator yet. Follow one camera frame from the pins to memory, and then the news of it to a core. At each channel write down the clock at both ends. Clocks from different PLLs are in different clock groups.

The way of one frame, by hand
ChannelClock at the startClock at the endCrossing?
Camera to PHYcameracamerano: the clock came with the data
PHY to controllercamerapll_sysyes
Controller to memory portpll_syspll_sysno
Memory port to DRAM pinspll_syspll_memyes
Interrupt to a corepll_syspll_cpuyes
Core to the registers of the controllerpll_cpupll_sysyes

Six channels, four clock groups, four crossings. The first row is the one that people get wrong. A wire that enters the chip is not a crossing by itself. The camera sent its clock along, so the PHY takes the bytes in on that clock.

Now a change of rate. The cluster runs at 200 MHz and wants 400. A PLL that retunes gives a clock that nobody may use. So the controller parks the cluster on the crystal first.

One retune, by hand
StepTakesDone atThe cluster runs on
Hand the cluster over to the crystal2 ticks2the crystal, 25 MHz
Retune pll_cpu and wait for lock5 ticks7the crystal, 25 MHz
Hand the cluster back to pll_cpu2 ticks9pll_cpu, 400 MHz

For 7 of the 9 ticks the cluster crawls at 25 MHz. A change of rate is not free, and it is not instant.

The Rules

  1. Rule 1: A block whose rate must change alone gets a PLL of its own.

    Blocks that always run at one rate can share one.

  2. Rule 2: The clock controller owns every PLL, every clock mux and every clock gate.

    A block asks for a rate or for its clock. It never switches one itself.

  3. Rule 3: Before a PLL retunes, each of its users moves to a safe clock.

    They move back only after lock.

  4. Rule 4: Clocks from two PLLs are unrelated, also when both PLLs follow one crystal.

    So every channel between two clock groups is a crossing, and each is counted.

  5. Rule 5: A forwarded clock makes no crossing at the pins.

    The crossing is inside the chip, where the data first meets a clock of the chip.

  6. Rule 6: A shared clock stops only when every user has accepted.

    A user that still owes an answer denies. A PLL stops after its last user.

  7. Rule 7: What must hear the outside world keeps a clock, or an activity wire that asks for one.

    A stopped block cannot ask with logic that needs its own clock.

Sources for These Rules

Rule 3 rests on two earlier lessons: a PLL output counts only after lock, and a clock mux hands over between whole pulses. The PLL itself: Weste and Harris, CMOS VLSI Design, fourth edition, sections 13.4.3.3 and 13.5.1.

Rule 4, crossings between unrelated clocks, a word of several bits and a stream through a two-clock memory: Mehta, ASIC/SoC Functional Design Verification, chapter 8, sections 8.3.1, 8.3.4 and 8.3.5. That two PLLs on one crystal are treated as unrelated is common practice, not checked against a source.

Rule 5, a clock that the sender makes together with its data: the RGMII specification, version 2.0, section 3.0, is one example. No camera link standard is in the library of this site. That a camera sends a clock beside its data is given as common usage.

Rules 6 and 7: Arm AMBA Low Power Interface Specification, IHI 0068 issue D. Section 2.1.2 has the request with its two answers, accept and deny. Section 2.1.1 has an activity signal that can be built from the inputs of a block. Section 2.5.2 has several blocks under one clock controller, each with its own request.

Rules 1 and 2 are how a clock plan is written. They are design practice, not rules of a standard.

Now Run It

The lab at the end of this page has three parts. First the count of the first hand table, then the retune of the second, then a row of stop requests.

Printed by the lab on Icarus. Test code with no circuit.
camera to PHY | camera -> camera | crossings so far=0
PHY to controller | camera -> sys | crossings so far=1
controller to memory port | sys -> sys | crossings so far=1
memory port to DRAM pins | sys -> mem | crossings so far=2
interrupt to core | sys -> cpu | crossings so far=3
core to controller registers | cpu -> sys | crossings so far=4
groups=4 channels=6 crossings=4
t=0 cluster asks for 400 MHz
t=2 cluster runs on the crystal at 25 MHz
t=2 pll_cpu retunes 200 -> 400 lock=0
t=7 pll_cpu lock=1
t=9 cluster runs on pll_cpu at 400 MHz
stop camera controller: accepted, users of pll_sys=2
stop pll_sys: refused, users=2
stop mesh: denied, owes 1 answer
stop mesh: accepted, users of pll_sys=1
stop peripherals: accepted, users of pll_sys=0
stop pll_sys: stopped
frame arrives: camera clock=1 controller clock=0 bytes stored=0

Rule 5 at work, in the first row. The channel from the camera to the PHY leaves the count at 0. Rule 4, in the rows after it: the count ends at crossings=4 for six channels in four groups.

Rules 2 and 3, in the five rows that start with t. The cluster only asks. At t=2 it runs on the crystal, and only then does pll_cpu retune. The cluster comes back at t=9, two ticks after lock=1.

Rule 6, in the stop rows. The camera controller accepts, and the PLL is still refused: users=2. The mesh denies while it owes one answer, and accepts once the answer is out. The PLL stops after the third user.

Rule 7, in the last row, is the black frame of the opening. The camera clock runs, so the PHY has the bytes. The controller clock is 0, and bytes stored=0.

This lab leaves things out. Nothing is sampled, so no value is ever taken at a bad moment. And the frame of the last row has no activity wire to call for a clock.

Why It Is Built This Way

ChoiceThe alternativeIts cost
Six PLLsOne PLL and dividersEvery block would change rate together. A divider gives only whole fractions of one rate.
One owner of all PLLsEach block sets its own clockTwo blocks on one PLL would give two orders. Nobody would move the other users to a safe clock.
Unrelated clocks and counted crossingsKeep all six clocks relatedThe edges of six trees would have to be lined up across the whole chip, at every rate.
Request and answer before a stopStop a clock when its block looks idleA block can look idle and still owe an answer. That answer would never leave.

So who should own the choice of a rate? Rule 2 gives the answer: the clock controller. A block knows what it needs. Only the controller knows who else hangs on the same source.

The Trap: The Frame Nobody Caught

Back to the black frame. The power team had done careful work. Between two recordings the camera controller was idle, so its clock was stopped. Then the mesh, then the peripherals, then pll_sys itself. Every stop was asked for and accepted.

Then the user pressed record. The camera started to send, with its own clock, as always. The PHY took the bytes. Behind it stood a controller without a clock. By the time software had asked for the clock, the first frame was over.

Which clock did the frame need while nobody was looking? Not the clock of the cores. It needed the clock of the first block of the chip that must store it. The cure is rule 7. Activity at the PHY raises a wire, and that wire asks the clock controller. It needs no clock of its own.

The second trap is the label. Two clocks both say 200 MHz, one from pll_sys and one from pll_cpu at its middle rate. Someone removes the crossing between them to save a tick. The rates match. The edges drift, and once a day a wrong word arrives.

At Scale

ap_soc1 PLL, 2 unrelated clocks
ap_phone6 PLLs, 9 clock groups

This section looks ahead, to what nine clock groups ask of the tools and of the reviews.

  1. Nine groups

    Six PLLs, the slow oscillator, the camera clock and the clock of the debug probe: nine clock groups. The timing constraints name each, and a tool lists every channel between two of them.

  2. A crossing for each mode

    A clock mux can change which group a block is in. The count of the lab must be made for each setting of each mux, not once.

  3. The right circuit for each channel

    A stream of frame bytes crosses through a two-clock queue. A single interrupt wire crosses through a synchronizer. The RTL Design track builds both.

  4. Gates below the PLLs

    Each PLL feeds a tree of clock gates. How much a gate saves, and where it sits, is taught in the Low Power track: Clock Gating That Pays.

The Clock Map of the First Practice Problem

The first practice problem uses a small map of its own. A MAC is the controller of a network port. Each letter is one clock group.

Inspect the Worksheet Clock MapSelect a channel to see its endpoints. Letters identify clocks in the baseline mode.
  • Processor
  • Memory
  • Bus
  • Peripheral
  • Clock / reset
Inspect the Worksheet Clock MapSelect a channel to see its endpoints. Letters identify clocks in the baseline mode. component CPU Clock A component Queue Clock B component DMA Clock B component MAC Clock C component Wake Clock D submitreadsendstatuswake
  1. component CPUClock A
    • submit → Queue
  2. component QueueClock B
    • read → DMA
  3. component DMAClock B
    • send → MAC
  4. component MACClock C
    • status → Queue
  5. component WakeClock D
    • wake → CPU
  1. submit

    Compare the clock letters at the two highlighted endpoints.

  2. read

    Compare the clock letters at the two highlighted endpoints.

  3. send

    Compare the clock letters at the two highlighted endpoints.

  4. status

    Compare the clock letters at the two highlighted endpoints.

  5. wake

    Compare the clock letters at the two highlighted endpoints.

Read the diagram as text
  • CPU: Clock A
  • Queue: Clock B
  • DMA: Clock B
  • MAC: Clock C
  • Wake: Clock D
  • CPU → Queue: submit
  • Queue → DMA: read
  • DMA → MAC: send
  • MAC → Queue: status
  • Wake → CPU: wake

Worksheet drawing. Only the five baseline channels appear. The ticket specifies which extra channels to include.

Try It

Run the lab. It has three parts: a count of crossings, one change of rate, and a row of stop requests.

In the first part, give the cluster the clock of the system: set CPU to 1 and its name to "sys". Predict the count.

In the third part, delete the line that says the answer has been delivered. Predict the last four rows.

Names Printed by the Lab
NameMeaning
camera, sys, mem, cpuFour clock groups: the clock that the camera sends, and the clocks of the system PLL, the memory PLL and the cluster PLL.
a -> bA channel: its signals leave flip-flops on clock a and enter flip-flops on clock b.
crossings so farThe number of channels so far whose two ends are in different clock groups.
tThe time in ticks. A tick is a lab unit.
lockThe lock signal of the PLL: 1 when its output has settled at the new rate.
accepted, deniedThe answer of a block to a stop request for its clock.
usersThe blocks whose clock from that PLL still runs.
bytes storedThe bytes of the frame that reached memory.
Sources and What the Lab Leaves Out

The lab is test code with no circuit. A clock group is a number, a PLL is a rate, and a block answers a stop request by one comparison.

It samples nothing, so it cannot show a value that is taken in at a bad moment. The earlier lessons on clock domains have that in a circuit.

The times of the change of rate are lab values: 2 ticks for a handover, 5 ticks until lock.

RUNIcarus Verilog · in your browser
Edit the code, then run it
Expected: camera to PHY | camera -> camera | crossings so far=0 PHY to controller | camera -> sys | crossings so far=1 controller to memory port | sys -> sys | crossings so far=1 memory port to DRAM pins | sys -> mem | crossings so far=2 interrupt to core | sys -> cpu | crossings so far=3 core to controller registers | cpu -> sys | crossings so far=4 groups=4 channels=6 crossings=4 t=0 cluster asks for 400 MHz t=2 cluster runs on the crystal at 25 MHz t=2 pll_cpu retunes 200 -> 400 lock=0 t=7 pll_cpu lock=1 t=9 cluster runs on pll_cpu at 400 MHz stop camera controller: accepted, users of pll_sys=2 stop pll_sys: refused, users=2 stop mesh: denied, owes 1 answer stop mesh: accepted, users of pll_sys=1 stop peripherals: accepted, users of pll_sys=0 stop pll_sys: stopped frame arrives: camera clock=1 controller clock=0 bytes stored=0

Check Yourself

Predict the outputIn this run the cluster takes its clock from pll_sys, like the network. The run ends after the count. What is the last line? Its form is: groups=.. channels=.. crossings=..
module tb;
  // Four clock groups on the way of one camera frame. Clocks of different groups are unrelated.
  localparam int CAMERA = 0, SYS = 1, MEM = 2, CPU = 1;
  string group [4];
  bit seen [4];
  int channels = 0, crossings = 0, groups = 0;

  // One channel: a signal that leaves a flip-flop on one clock and enters a flip-flop on another, or on the same.
  task automatic channel(input string label, input int launch, capture);
    seen[launch] = 1;
    seen[capture] = 1;
    channels++;
    if (launch != capture) crossings++;
    $display("%s | %s -> %s | crossings so far=%0d", label, group[launch], group[capture], crossings);
  endtask

  // The clock controller. It owns every PLL, every clock mux and every clock gate.
  int t = 0;
  int cpu_mhz = 200;
  // A new rate for the cluster: move it to the crystal, retune, wait for lock, move it back.
  task automatic retune(input int mhz);
    $display("t=%0d cluster asks for %0d MHz", t, mhz);
    t += 2;                                  // one handover of the glitch-free mux
    $display("t=%0d cluster runs on the crystal at 25 MHz", t);
    $display("t=%0d pll_cpu retunes %0d -> %0d lock=0", t, cpu_mhz, mhz);
    t += 5;                                  // the time this PLL needs to reach lock
    cpu_mhz = mhz;
    $display("t=%0d pll_cpu lock=1", t);
    t += 2;
    $display("t=%0d cluster runs on pll_cpu at %0d MHz", t, cpu_mhz);
  endtask

  // Three users of pll_sys. Each has a clock gate of its own.
  string user [3];
  bit runs [3];
  int owes [3];          // answers that this user still owes on the bus
  bit pll_sys_runs = 1;
  function automatic int users_running;
    int n = 0;
    for (int u = 0; u < 3; u++) n += runs[u];
    return n;
  endfunction
  task automatic stop_user(input int u);
    if (owes[u] != 0) $display("stop %s: denied, owes %0d answer", user[u], owes[u]);
    else begin
      runs[u] = 0;
      $display("stop %s: accepted, users of pll_sys=%0d", user[u], users_running());
    end
  endtask
  task automatic stop_pll;
    if (users_running() != 0) $display("stop pll_sys: refused, users=%0d", users_running());
    else begin
      pll_sys_runs = 0;
      $display("stop pll_sys: stopped");
    end
  endtask

  initial begin
    group[0] = "camera"; group[SYS] = "sys"; group[MEM] = "mem"; group[CPU] = "sys";
    channel("camera to PHY", CAMERA, CAMERA);
    channel("PHY to controller", CAMERA, SYS);
    channel("controller to memory port", SYS, SYS);
    channel("memory port to DRAM pins", SYS, MEM);
    channel("interrupt to core", SYS, CPU);
    channel("core to controller registers", CPU, SYS);
    for (int g = 0; g < 4; g++) groups += seen[g];
    $display("groups=%0d channels=%0d crossings=%0d", groups, channels, crossings);
    $finish;
    retune(400);

    user[0] = "camera controller"; user[1] = "mesh"; user[2] = "peripherals";
    runs[0] = 1; runs[1] = 1; runs[2] = 1;
    owes[1] = 1;                             // the mesh still carries one answer
    stop_user(0);
    stop_pll;
    stop_user(1);
    owes[1] = 0;                             // the answer has been delivered
    stop_user(1);
    stop_user(2);
    stop_pll;
    // A frame arrives now. The camera sends its own clock, so the PHY takes the bytes in.
    // The controller behind the PHY has no clock.
    $display("frame arrives: camera clock=1 controller clock=%0d bytes stored=%0d", runs[0], runs[0] ? 8 : 0);
  end
endmodule
ConceptWhy does a large chip have several PLLs and not one?
ConceptWho may change the rate of a PLL?
ConceptThe camera sends a clock with its data. Where is the crossing?
ConceptThree blocks take their clock from one PLL. When may it stop?

Common Mistakes

Wrong Count every wire that enters the chip as a crossing.

A sender can forward its clock with the data.

Fix Name the clock at both ends of each channel, and count the pairs that differ.

Wrong Treat two clocks of the same rate as one clock group.

Two PLLs give edges that drift against each other.

Fix Put them in one group only if one PLL makes both.

Wrong Stop a shared clock when its largest user is idle.

Another user may still owe an answer.

Fix Ask every user, and stop after the last one has accepted.

Remember

  • One PLL for each rate that must change alone. One clock controller owns them all.
  • Before a retune every user of the PLL moves to a safe clock, and back after lock.
  • Count a crossing for every channel between two clock groups. A forwarded clock moves the crossing inside the chip.
  • A shared clock stops by request and answer. What must hear the outside keeps a way to call for a clock.

Practice

Report a problem with this page