Skip to content
DenseChip
Learn
PracticeCode labInterview

DenseChip

Navigate

Menu

LearnPracticeCode labInterview

Tools

All toolsSV editorCode repoResume
DenseChip

Practice, courses, and chip-design tools in one focused workspace.

LearnPracticeCode labInterviewToolsLearning paths

© 2026 DenseChip

AboutRoadmapCareersInternshipsFAQContactPrivacyTerms
Skip to lesson

Course contents

  • How to Use This Course
  • The NanoSoC Tour
  • Reading Path
  • SoC Glossary10
  • SoC Metrics Reference
  • SoC Cheatsheet
  • What SoC Integration Is12
  • Architecture and Budgets21
  • Memory Maps and Address Decode26
  • Interconnect and Bus Fabrics26
  • Clock and Reset Architecture24
    • Clock Sources and PLLs
      • Crystal, PLL and Dividers
      • PLL Wrapper and the Lock Handshake
      • PLL Settings Calculator
    • Dividers, Muxes and Glitch-Free Switching
    • Clock Gating Architecture
    • Clock Domain Planning
    • Top-Level Crossings
    • Always-On Domain, Wake Policy and a Timer Extension
    • Reset Sources and Reset Tree
    • Reset Sequencing and Release
  • Power Architecture21
  • Interrupts, DMA and Peripherals15
  • Memories, Boot and Security21
  • IP Integration and Handoff21
  • Top-Level Verification and Bring-up21
  • Package, Pads and I/O18
  • Chip Signoff and Tapeout18
  • SoC Interview Prep16
  • Capstone: Integrate NanoSoC14
Loading lesson

←Clock Sources and PLLs
  1. Topics
  2. SoC Design
  3. Clock and Reset Architecture
  4. Clock Sources and PLLs
  5. PLL Settings Calculator
On this page

    Part 5 of 14, lesson 3 of 24Part 5 of 14/Clock and Reset Architecture/Lesson 3 of 24All levels

    PLL Settings Calculator

    Recompute the NanoSoC PLL settings from scratch: sweep N and R, check the VCO range, and reject bad settings.

    Why it matters

    PLL settings arrive as three numbers in a header, and a typo in any one of them overclocks the chip or stalls it. The integrator's defence is a calculator that derives the settings from the wanted frequencies and refuses anything outside the VCO range. This lesson builds that calculator for NanoSoC and uses it to prove the chosen R equal to 1 and N equal to 32 are the natural settings, not just familiar ones. Its one job is the settings search; lock behaviour belongs to the previous lesson.

    The core idea

    The search space is small: reference divide R from 1 to 8, feedback multiply N from 1 to 64, and the fixed post-dividers 4 and 8. A setting is accepted only if the VCO sits inside 600 to 1200 MHz and both post-divided clocks land exactly on 192 and 96 MHz. Exactness matters: a VCO of 772 MHz would give 193 and 96.5 MHz, and every cycle-counted budget in the course would silently drift.

    example.py
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    XTAL = 24e6
    WANT_CPU, WANT_SYS = 192e6, 96e6
    VCO_LO, VCO_HI = 600e6, 1200e6
    
    good = []
    for r in range(1, 9):
        for n in range(1, 65):
            vco = XTAL * n / r
            if not (VCO_LO <= vco <= VCO_HI):
                continue
            if vco / 4 == WANT_CPU and vco / 8 == WANT_SYS:
                good.append((r, n, vco))
    
    assert (1, 32, 768e6) in good, good
    assert len(good) >= 1, good
    # Every accepted setting is the same VCO: the dividers fix it at 768 MHz.
    assert {v for _, _, v in good} == {768e6}, good
    # Near misses the calculator must reject: N=31 and N=33 miss both targets.
    for n in (31, 33):
        assert (XTAL * n) / 4 != WANT_CPU and (XTAL * n) / 8 != WANT_SYS
        assert (1, n, XTAL * n) not in good
    # The N = 31 typo in numbers: VCO 744 MHz, clocks 186 and 93 MHz, 3.125 % slow.
    vco31 = XTAL * 31
    assert vco31 == 744e6 and vco31 / 4 == 186e6 and vco31 / 8 == 93e6
    assert abs((1 - 186e6 / WANT_CPU) * 100 - 3.125) < 1e-9
    print(f"PASS: {len(good)} valid (R,N) settings, all at 768 MHz VCO; N=31 gives 186/93 MHz and is rejected")

    What the review looks for

    • The taped-out settings appear in the calculator output with the VCO range check beside them.

    • No accepted setting is approximate: both derived clocks match exactly, or the setting is rejected.

    • The lock time quoted for the chosen setting matches the wrapper lesson: the counter runs on clk_per either way.

    Verify and debug

    Rerun the sweep after any crystal or frequency change and confirm the taped-out pair is still in the accepted list. If the list is empty, the wanted frequencies are unreachable with integer divides and the architecture must move, either the VCO target or a divider, before any RTL changes. A VCO near the range edge deserves a second look at margin even when the calculator accepts it.

    A one-digit typo in the settings header: N = 31 instead of 32 gives a 744 MHz VCO, which is inside the range, so no range check objects, but clk_cpu runs at 186 MHz and clk_sys at 93 MHz, 3.125 percent slow, and the 8:4:1 ratio is no longer exact. The crystal-clocked UART and SPI still run at their correct rates while every fabric-timed number shifts, so the bug looks like a software timing problem. The calculator above rejects it because the divided clocks must land exactly on 192 and 96 MHz.

    If asked to pick PLL settings, narrate the search, not the answer: fix the VCO from the dividers first, then find R and N that land it in range, then check neighbours fail. Calculators beat memory.

    Check yourself The sweep finds exactly one more valid pair, R equal to 2 with N equal to 64. Why is the smaller pair preferred?

    Small R and N keep the loop dynamics simple and the reference spur far out, and R = 1 feeds the phase detector the full 24 MHz reference. R = 2, N = 64 gives a 12 MHz phase-detector frequency and a 64-way feedback divide: the same VCO with a higher divide ratio, and as a general guideline about 6 dB more in-band phase noise per doubling of N, for no benefit here.

    Related topics

    • PLL Wrapper and the Lock Handshake

    • Integer Dividers and Clock Muxes

    Previous

    87 / 289

    Next: Firewalls and Protection

    Up next

    Up nextFirewalls and Protection

    Sign in to save progress

    Practice this lessonPrevious lessonReport an error

    See also

    • Crystal, PLL and Dividers