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.
| Question | |
|---|---|
| 1 | Why does a large chip have several PLLs and not one? |
| 2 | Who may change the rate of a PLL, and what happens to its users first? |
| 3 | The camera sends a clock with its data. Where is the crossing? |
| 4 | Three blocks take their clock from one PLL. When may that PLL stop? |
| 5 | The 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
| Word | Meaning |
|---|---|
| Clock controller of a chip | The block that owns every PLL, every clock mux and every clock gate. Clock controller for short. |
| Request for a clock | A wire from a block to the clock controller. 1 means: I need my clock. |
| Retune | To change the output rate of a PLL. The PLL has no lock while it retunes. |
| Safe clock | A clock that keeps running while a PLL retunes. Here it is the crystal. |
| Stop request | A question from the clock controller to a block: may your clock stop? The block accepts or denies. |
| Signal channel | A group of signals that go together from one block to another. Channel for short. |
| Forwarded clock | A clock that travels beside its data, from the sender to the receiver, on a wire of its own. |
| Two-clock queue | A small memory that is written on one clock and read on another. Engineers call it an asynchronous FIFO. |
| Activity wire | A wire that goes to 1 when something arrives at a block whose clock is stopped. It needs no clock. |
One Picture: The Clock Plan
- Clock / reset
- Pads
- Processor
- Bus
- One source
A PLL makes a fast clock from the crystal. With one PLL, every block of the chip would run from it.
- 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.
- Six PLLs
The same reason holds for the memory pins, the engines, the display and the fast ports. That makes six.
- One owner
No block touches a PLL. The cluster asks the clock controller, and the controller makes the change in a safe order.
- 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.
| Channel | Clock at the start | Clock at the end | Crossing? |
|---|---|---|---|
| Camera to PHY | camera | camera | no: the clock came with the data |
| PHY to controller | camera | pll_sys | yes |
| Controller to memory port | pll_sys | pll_sys | no |
| Memory port to DRAM pins | pll_sys | pll_mem | yes |
| Interrupt to a core | pll_sys | pll_cpu | yes |
| Core to the registers of the controller | pll_cpu | pll_sys | yes |
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.
| Step | Takes | Done at | The cluster runs on |
|---|---|---|---|
| Hand the cluster over to the crystal | 2 ticks | 2 | the crystal, 25 MHz |
| Retune pll_cpu and wait for lock | 5 ticks | 7 | the crystal, 25 MHz |
| Hand the cluster back to pll_cpu | 2 ticks | 9 | pll_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
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.
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.
Rule 3: Before a PLL retunes, each of its users moves to a safe clock.
They move back only after lock.
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.
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.
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.
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.
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=0Rule 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
| Choice | The alternative | Its cost |
|---|---|---|
| Six PLLs | One PLL and dividers | Every block would change rate together. A divider gives only whole fractions of one rate. |
| One owner of all PLLs | Each block sets its own clock | Two blocks on one PLL would give two orders. Nobody would move the other users to a safe clock. |
| Unrelated clocks and counted crossings | Keep all six clocks related | The edges of six trees would have to be lined up across the whole chip, at every rate. |
| Request and answer before a stop | Stop a clock when its block looks idle | A 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
This section looks ahead, to what nine clock groups ask of the tools and of the reviews.
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.
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.
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.
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.
- Processor
- Memory
- Bus
- Peripheral
- Clock / reset
- submit
Compare the clock letters at the two highlighted endpoints.
- read
Compare the clock letters at the two highlighted endpoints.
- send
Compare the clock letters at the two highlighted endpoints.
- status
Compare the clock letters at the two highlighted endpoints.
- 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
| Name | Meaning |
|---|---|
| camera, sys, mem, cpu | Four clock groups: the clock that the camera sends, and the clocks of the system PLL, the memory PLL and the cluster PLL. |
| a -> b | A channel: its signals leave flip-flops on clock a and enter flip-flops on clock b. |
| crossings so far | The number of channels so far whose two ends are in different clock groups. |
| t | The time in ticks. A tick is a lab unit. |
| lock | The lock signal of the PLL: 1 when its output has settled at the new rate. |
| accepted, denied | The answer of a block to a stop request for its clock. |
| users | The blocks whose clock from that PLL still runs. |
| bytes stored | The 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.
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=0Check Yourself
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.