Esp32 Clock Tree
A clock tree is the circuit that takes one reference oscillator and fans it out to every flip-flop on the die at the same instant, and on an ESP32-class chip that job is harder than on a pure digital chip because several independent clock domains — CPU, RF baseband, peripherals, RTC — all have to stay correctly related to each other while running at completely different frequencies and, during sleep modes, turning on and off independently. A single global clock distributed everywhere would waste power keeping unused blocks toggling and would force the RF baseband to run at whatever frequency suits the CPU instead of the frequency its own 802.11 timing actually needs — so the real clock architecture is a small tree of independent domains fed from one or two reference sources, not one wire fanned out to the whole die.
Clock skew — the tiny difference in arrival time of the same clock edge at different flip-flops — is the thing the whole tree's buffer sizing and routing exists to control, because even a few tens of picoseconds of skew can eat directly into a 240 MHz CPU's timing margin. As a clock signal fans out from one source to thousands of flip-flops across the die, wire length and buffer delay differences mean the edge doesn't arrive everywhere simultaneously; clock-tree synthesis tools deliberately insert matched buffers and balance wire lengths (an "H-tree" or similar balanced structure) specifically to minimize that arrival-time spread, because unmanaged skew is indistinguishable from a timing violation to the flip-flops actually affected by it.
Clock-domain crossing has to be handled explicitly at every boundary between independent clocks, because a signal that changes in one domain and gets sampled by a flip-flop running on a completely unrelated clock can land during that flip-flop's setup/hold window and produce metastability — an output that briefly sits at neither a valid 0 nor a valid 1. The CPU's 240 MHz domain, the RF baseband's own clock, and the RTC's always-on low-power clock all run independently of each other, so every signal that needs to cross from one domain to another passes through a dedicated multi-stage synchronizer specifically designed to let any metastable state resolve before the signal is used, rather than trusting that a signal sampled across unrelated clocks will simply behave.
Clock gating is the mechanism that actually delivers the power savings the PMU's domain-level shutdown can't reach on its own, because gating works at the granularity of individual peripherals rather than whole power domains. Shutting off an entire power domain (as the PMU does for deep sleep) is a coarse, infrequent action; clock gating is the fine-grained version that runs continuously during normal operation, disabling the clock to an idle SPI controller or an unused timer block while the rest of the chip stays fully powered and running — the two mechanisms are complementary, not redundant, and a design that only has one or the other leaves real power savings on the table.
The clock tree is the infrastructure that makes "several independent subsystems on one die" actually workable rather than a collection of race conditions waiting to happen: one or two reference sources, dedicated PLLs sized to what each domain actually needs, balanced distribution to control skew within each domain, and explicit synchronizers at every point those domains have to talk to each other.