Cdc audit

From LNC0831/oh-my-fpga · View interactive version

Cdc audit is an AI agent skill from the GitHub repository LNC0831/oh-my-fpga. Audit and resolve clock-domain-crossing (CDC) risks on a design: enumerate every clock crossing, classify each by structure (synchronizer present/absent, single-bit vs bus, async reset, reconvergence), and apply the smallest safe fix (synchronizer RTL, set_clock_groups / set_max_delay -datapath_only

How to use this skill

Skill file

CDC Audit (Clock-Domain-Crossing Risk Review & Resolution)

A methodology playbook for finding, classifying, and safely resolving clock-domain

crossings using the SynthPilot MCP tools that drive Vivado. CDC bugs do not show up

as timing failures — a metastable crossing can pass STA and still fail silently in

silicon. This skill treats CDC as a structural correctness problem first and a

constraint problem second.

The governing rule for this entire skill: a CDC constraint does not fix a CDC bug.

set_clock_groups, set_false_path, and set_max_delay -datapath_only only tell

the timing engine to stop reporting a crossing — they do nothing to add the

synchronizer hardware that actually prevents metastability propagation. Constraints

are applied only after the crossing is confirmed to be structurally safe, or

explicitly waived with a stated assumption.


When to use

review", or "reset domain crossing (RDC) check".

every crossing is either synchronized or safely a quasi-static/false path.

items and the user wants them triaged and resolved.

wants it verified.

a suspect.

When NOT to use

known phase relationship). There are no async crossings to audit — confirm this

with get_all_clocks / report_clock_interaction and stop.

skill. CDC is about unrelated clocks; intra-domain WNS violations are a different

problem.

(sim_run); do not blame CDC without evidence of a real domain crossing.

analysis needs an elaborated or synthesized netlist. Set the project up first.


Prerequisites (verify first)

Run these before any analysis. Do not proceed on assumption.

  1. MCP/Vivado link is live — test_connection. If it fails, the Tcl server

inside Vivado is not running; stop and tell the user to start it. Optionally

vivado_version to record the tool version in the report.

  1. A project is open with the design loaded — get_project_info and

list_source_files. If nothing is open, open_project (or create_project +

add_source_file + set_top_module).

  1. Clocks are actually defined — get_all_clocks. CDC analysis is meaningless

without clock constraints; if clocks are missing (everything shows as one

inferred clock, or report_cdc later says "no inter-clock paths"), the timing

environment is incomplete. Note this and, before drawing conclusions, ensure

primary clocks are constrained via create_clock_constraint /

create_generated_clock. **A missing clock definition silently hides real

crossings — treat an incomplete clock set as a blocker, not a pass.**

  1. A design exists to report on. report_cdc needs an elaborated or synthesized

design open. The cheapest entry point is structural lint (check_cdc_lint), which

works on RTL. For the authoritative crossing-by-crossing report you need a

synthesized design — if none exists, run run_synthesis_async and poll

get_run_status (see Methodology step 2). Then open_synthesized_design.

State explicitly which of these are satisfied before continuing.


Methodology (measure → classify → smallest-safe-fix → re-measure)

Work the crossings in severity order (Critical → Warning). Change **one

crossing-class per iteration** so cause and effect stay attributable.

1. Inventory the clock topology (understand the battlefield)

them and whether each pair is timed, partial-false-path, or asynchronous. This is

your ground truth for "which crossings exist." Note every pair flagged

asynchronous or with inter-clock paths.

From this, build the set of clock-pair crossings you must account for. A crossing

not on this list does not exist; a crossing on this list must be classified before

you may close the audit.

2. Get an authoritative CDC report

run_full_lint_check → get_lint_violations. This catches missing synchronizers

and obvious structural issues early and cheaply.

do not block; use the async + poll pattern). On completion check

check_synthesis_issues / get_synthesis_warnings.

(Critical / Warning / Info) and endpoint detail.

severity) and drill into specific endpoints with report_cdc_details.

Record the raw counts (Critical / Warning / Info) as the audit baseline. Do not

editorialize them yet.

3. Classify every Critical/Warning crossing (classification table below)

For each flagged crossing, identify: source clock, destination clock, signal

width (single-bit vs bus), whether a synchronizer is present, whether it is a

control vs data path, and whether reconvergence or reset-domain-crossing

is involved. Use report_cdc_details and, where you need to see the RTL,

read_file / read_file_lines on the relevant source. Map each to a structure type

using the table below.

4. Apply the smallest safe fix for that crossing class

Follow the fix-precedence ladder strictly:

  1. Already-safe → constrain only. If a correct synchronizer already exists, the

crossing is structurally fine; the only action is to make the timing tool treat it

correctly (set_clock_groups -asynchronous, or set_max_delay -datapath_only /

set_bus_skew for buses — see table). This is a constraint, not a design change.

  1. Missing/incorrect synchronizer → recommend RTL. Do not silence it. Propose

the specific RTL fix (2-FF synchronizer for single-bit control; async FIFO or

gray-code + handshake for buses; reset synchronizer for RDC) and present it to the

user. Recommend the edit; do not silently apply RTL. If the user approves, use

read_file → replace_in_file / update_file (or create_source_file for a new

synchronizer module), then add it to the project and re-elaborate.

  1. **Genuinely a non-crossing (quasi-static, same effective domain, tied constant) →

waive with a stated assumption.** Only here may you use set_false_path /

set_clock_groups / waive_lint_violation, and only after explicitly stating the

assumption (e.g., "config register is written once at reset, never while the

destination clock is active"). **If the path could be real and you are unsure, ask

the user before waiving.**

Apply exactly one crossing-class of change, then save_constraints (for constraint

changes).

5. Re-measure on the same evidence source

Re-run the same tool you measured with: report_cdc (and report_clock_interaction

to confirm the pair is now correctly treated) for netlist changes;

check_cdc_lint / get_lint_violations for RTL changes. Confirm the targeted

crossing's severity dropped and that no new Critical/Warning appeared elsewhere.

RTL changes require re-synthesis (step 2) before the netlist CDC report is valid

again — synthesis warnings alone are necessary-not-sufficient.

6. (Signoff) Prove it on the implemented design

For a signoff claim that "CDC is clean," constraints must hold through place &

route. Run run_implementation_async, poll get_run_status, then

open_implemented_design and:

verdict.

(e.g., CDC-*, TIMING-* rule hits) that the CDC report alone may not surface.

passed in report_timing_summary (a skew constraint that fails routing is not

a fix).

A success claim requires fresh post-implementation tool output, never inference

from RTL or synthesis.


Classification table (symptom → structure → safe fix)

| # | Symptom from report_cdc / report_cdc_details | Structural cause | Smallest safe fix (in precedence order) |

|---|---|---|---|

| C1 | 1-bit control crossing, no synchronizer (direct reg→reg between async clocks) | Missing 2-FF synchronizer — true metastability risk | RTL: recommend a 2-flop synchronizer on the destination clock. Do NOT false-path. After fix + re-synth, optionally set_max_delay -datapath_only src→sync-FF1. |

| C2 | 1-bit crossing WITH a recognized 2-FF synchronizer | Already safe; tool just needs to be told it's async | Constraint only: set_clock_groups -asynchronous between the two clocks (or set_max_delay -datapath_only on the input to FF1). No RTL change. |

| C3 | Multi-bit bus crossing, all bits sampled by a synchronizer | Bus bits can skew → recombine to a wrong value (data coherency hazard) | RTL: recommend gray-code (counters), or async FIFO, or a handshake-gated MUX-capture (req/ack). A per-bit 2-FF synchronizer on a bus is a BUG, not a fix — call it out. |

| C4 | Bus crossing via async FIFO / handshake-qualified capture | Already coherent by construction | Constraint: set_bus_skew on the bus (bound inter-bit skew) and/or set_max_delay -datapath_only; set_clock_groups -asynchronous for the clock pair. No RTL change. |

| C5 | Reset asserted in one domain, deasserted into another (RDC) | Reset deassertion not synchronized → metastable release, partial reset | RTL: recommend an async-assert / sync-deassert reset synchronizer per destination domain. Verify with check_async_reset. |

| C6 | Reconvergence: two synchronized signals from the same source recombine downstream | Independent 2-FF synchronizers resolve on different cycles → glitch/illegal combo | RTL: recommend re-architecting to cross a single encoded bus (gray/handshake) once, then decode in the destination domain. Constraints cannot fix this. |

| C7 | "Quasi-static" / config-register crossing (written once, static thereafter) | Not a dynamic crossing — but only if the "written once" assumption holds | Waive with stated assumption: set_false_path (or waive_lint_violation). State the assumption explicitly; ask the user to confirm the register is truly static during destination-clock operation. |

| C8 | Clocks reported as crossing but actually synchronous/related (common divider, known phase) | Not an async crossing at all | Constraint: define the relationship (create_generated_clock) so STA times it normally; do NOT set_clock_groups -asynchronous (that would hide a real timed path). |

| C9 | Crossing into/out of an IP (clk-wiz, async FIFO IP, AXI clock converter) | IP handles CDC internally if configured correctly | Verify IP config (get_fifo_config / get_clocking_wizard_config / report_ip_status); apply the IP's recommended set_* constraints. Don't hand-synchronize an IP boundary that's already safe. |

Rule of thumb: single-bit control → 2-FF synchronizer; multi-bit data → FIFO /

gray-code / handshake; reset → async-assert+sync-deassert. **A bank of independent

2-FF synchronizers on a bus is itself a defect (C3), not a remedy.**


Resolution loop & STOP conditions

for each crossing in (Critical first, then Warning), one class at a time:
    measure   → report_cdc / report_cdc_details (or check_cdc_lint for RTL)
    classify  → map to C1..C9 above
    fix       → smallest safe change in the precedence ladder
                (constraint-only > recommend-RTL > waive-with-assumption)
    re-measure→ same tool; confirm THIS crossing dropped AND nothing new appeared
    (RTL change ⇒ re-synthesize before the netlist CDC report is valid again)

STOP and hand back to the human when ANY of:

unexplained Warning**, every remaining waiver has a written assumption, and

report_methodology shows no open CDC-* violations. Report the fresh evidence.

Present the exact recommended RTL and wait for user approval before editing.

Never silently rewrite RTL to make a number go green.

it is static from the design alone — present it and ask the user before waiving.

constrained. Stop, report the gap, and ask for / propose the clock constraints

first — do not declare "clean" on an under-constrained design.

correct (C4): present the options (tighter floorplan, deeper FIFO, slower crossing

clock) with their costs and stop. Do not relax/remove the set_bus_skew just to

pass.

Warning: stop thrashing; summarize remaining items with options and trade-offs.

Do not loop forever and do not "resolve" by deletion of evidence (removing waivers'

assumptions, false-pathing real crossings, disabling lint rules).


Safety rails (do not violate)

set_max_delay, disable_lint_rule, or waive_lint_violation to a crossing that

could be a real, unsynchronized metastability path just to clear the report. A

constraint silences STA; it adds no hardware. Waivers/false-paths are allowed ONLY

for confirmed non-crossings (C7/C8) with a written assumption, and if there's

any doubt the path is real, ask the user first.

a real synchronizer already protects the crossing (C2/C4). Applying it to an

unsynchronized crossing (C1/C3) hides a live bug. Confirm the synchronizer exists

(report_cdc_details / read_file) before grouping.

RTL when no safe constraint exists, and then recommend, do not silently apply.

re-architecture change design behavior. Present the diff and get approval.

after each.

resolved" each REQUIRE fresh tool output — and for signoff, fresh

post-implementation report_cdc + report_methodology. Synthesis-level or

lint-level results are necessary-not-sufficient. Never infer cleanliness from a

source edit.

multi-bit data bus (C3) — that is a coherency bug. Use FIFO / gray-code / handshake.

are actually related (C8); define the generated-clock relationship instead so the

timed path stays timed.

with trade-offs and hand back. Do not thrash.


Output (report format)

Produce a CDC audit report with:

  1. Environment — Vivado version, project, top module, clock list (from

get_all_clocks), and which design stage the verdict is based on (RTL-lint /

synthesized / implemented). State it plainly if no post-implementation

evidence was collected — then the verdict is "preliminary," not "signoff."

  1. Crossing inventory — table of clock-pair crossings from

report_clock_interaction, each marked async / synchronous / handled-by-IP.

  1. Baseline counts — Critical / Warning / Info from the first report_cdc

(or check_cdc_lint), quoted from tool output.

  1. Per-crossing findings — for each Critical/Warning: source→dest clock, width,

classification (C1–C9), structural diagnosis, and the action taken or recommended.

  1. Changes applied — constraints added (with the exact set_* rationale) and any

RTL edits the user approved, each tied to its crossing.

  1. Waivers — every set_false_path / set_clock_groups / waive_lint_violation

with its explicit stated assumption and whether the user confirmed it.

  1. Final verdict with fresh evidence — post-implementation report_cdc counts +

report_methodology CDC-rule status (and report_timing_summary for any

set_bus_skew). Quote the numbers. **If post-implementation evidence is absent,

say "NOT signed off"** and list exactly what remains.

  1. Open items / trade-offs — anything requiring a human decision (RTL approval,

ambiguous waiver, structural re-architecture), with options and costs.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.