Skip to content

[ENG-2108] FEATURE - check_setup has json dump option#61

Closed
stanminlee wants to merge 7 commits into
mainfrom
check-timing
Closed

[ENG-2108] FEATURE - check_setup has json dump option#61
stanminlee wants to merge 7 commits into
mainfrom
check-timing

Conversation

@stanminlee

Copy link
Copy Markdown

Added a "-json [filepath]" option to the check_setup command to dump a comprehensive JSON summary that would normally go to a report

Implementation consists of these main parts:

  1. data structure stores pins for each category (unconstrained, unclocked, no_input_delay, etc) as we collect these warnings
  2. if -json is specified we will call the C++ json dumper
  3. tcl frontend checks that there is a filename arg and warns that -loop will not be dumped in json output

Test case provided for validation purposes

NOTE - loops are not dumped for now because of more overhead in implementation + we don't use it right now

@linear-code

linear-code Bot commented Jun 4, 2026

Copy link
Copy Markdown

ENG-2108

@greptile-apps

greptile-apps Bot commented Jun 4, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds a -json [filepath] flag to check_setup that dumps all check-timing violations to a structured JSON file. The implementation introduces a json_results_ accumulator inside CheckTiming that is populated alongside the existing errors_ list on each check() call, and a new reportJson method serialises it after the run completes.

  • CheckTiming now accumulates (json_key, StringSeq) pairs via the extended pushPinErrors/pushClkErrors helpers; clear() properly resets both errors_ and json_results_, so repeated calls are safe.
  • checkLoops bypasses pushPinErrors/pushClkErrors entirely (its loop-separator format is ill-suited for JSON), so loop violations are intentionally absent from the JSON output; a Tcl-layer warning (518) notifies the user whenever loop checking is active with -json.
  • Tcl validates a non-empty filename, enforces ordering (check before report), and the test covers the warning and the JSON output format end-to-end.

Confidence Score: 5/5

Safe to merge. The new JSON path is additive, the accumulator is always cleared at the start of each check run, and the Tcl layer enforces the correct call ordering.

The change is well-scoped: it adds a side-accumulator to an existing check routine without touching any existing data paths. The clear() guard prevents stale data, loop omission is deliberate and warned, error handling on file open is present, and a regression test validates the output format end-to-end.

No files require special attention. The only open item is a stale/missing comment on pushPinErrors and pushClkErrors in search/CheckTiming.cc.

Important Files Changed

Filename Overview
search/CheckTiming.cc Core change: adds json_results_ accumulation in pushPinErrors/pushClkErrors, plus jsonEscape and reportJson serializer. Logic is sound; checkLoops intentionally bypasses json_results_ via its own direct error path.
search/CheckTiming.hh Adds json_results_ member and reportJson declaration; updated parameter lists for pushPinErrors/pushClkErrors. Clean header changes.
search/Search.tcl Adds -json key-arg parsing with empty-value guard and loop warning. Ordering of check_timing_cmd before report_check_timing_json is correct.
search/Search.i Exposes report_check_timing_json as a SWIG-wrapped C function delegating to Sta::reportCheckTimingJson.
search/Sta.cc Adds thin reportCheckTimingJson delegation to check_timing_->reportJson; straightforward and correct.
include/sta/Sta.hh Adds public reportCheckTimingJson declaration to Sta class. No concerns.
test/check_setup_json.tcl New test covering the -json path with explicit flags and loop warning. Uses -loop prefix-matching for -loops, consistent with Tcl EDA conventions.
test/check_setup_json.ok Expected output correctly captures warnings, loop warning 518, and valid JSON with correct keys and sorted pin names.
test/regression_vars.tcl Adds check_setup_json to the public test suite. No issues.

Sequence Diagram

sequenceDiagram
    participant User as Tcl User
    participant Tcl as Search.tcl
    participant SWIG as Search.i
    participant Sta as Sta.cc
    participant CT as CheckTiming.cc

    User->>Tcl: check_setup -json out.json [flags]
    Tcl->>Tcl: parse_key_args extracts -json
    Tcl->>SWIG: check_timing_cmd(flags...)
    SWIG->>Sta: Sta::checkTiming(...)
    Sta->>CT: "check_timing_->check(...)"
    CT->>CT: clear() resets errors_ and json_results_
    CT->>CT: checkNoInputDelay() pushPinErrors(no_input_delay)
    CT->>CT: checkRegClks() pushPinErrors(unclocked/multiple_clock)
    CT->>CT: checkUnconstrainedEndpoints() pushPinErrors(unconstrained)
    CT->>CT: checkLoops() writes errors_ only
    CT->>CT: checkGeneratedClocks() pushClkErrors(generated_clock)
    CT-->>Sta: return errors_
    Sta-->>SWIG: return errors_
    SWIG-->>Tcl: return errors list
    Tcl->>Tcl: if loops then sta_warn 518
    Tcl->>SWIG: report_check_timing_json(filename)
    SWIG->>Sta: Sta::reportCheckTimingJson(filename)
    Sta->>CT: "check_timing_->reportJson(filename)"
    CT->>CT: open ofstream, serialize json_results_
    CT-->>Sta: file written
Loading

Reviews (2): Last reviewed commit: "fix typo!" | Re-trigger Greptile

Comment thread search/Search.tcl
Comment thread search/Search.tcl Outdated
Comment thread search/CheckTiming.cc
Comment thread search/CheckTiming.cc
@stanminlee

Copy link
Copy Markdown
Author

@greptile please look at my resolutions/comments and review again

@stanminlee stanminlee closed this Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant