Skip to content

[CUS-498] - dumpIcgJson function#56

Merged
akashlevy merged 5 commits intomainfrom
icg
Apr 22, 2026
Merged

[CUS-498] - dumpIcgJson function#56
akashlevy merged 5 commits intomainfrom
icg

Conversation

@stanminlee
Copy link
Copy Markdown
Contributor

Dumps an ICG json in specified path to store all relevant information about ICGs.

Stores flip-flops connected to an ICG and ICG instances (mapped to their liberty names)

@linear
Copy link
Copy Markdown

linear Bot commented Apr 22, 2026

CUS-498

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 22, 2026

Greptile Summary

This PR adds dumpIcgJson, which serializes clock-gating registers and ICG instances (with their liberty cell names) to a JSON file, exposed via a new SWIG/Tcl command dump_icg_json.

  • P1 – malformed JSON output: jsonEscape skips all control characters (\ , \ , \ , U+0000–U+001F). Any such character in a path name or liberty name will produce structurally invalid JSON that will fail to parse downstream.
  • P2 – missing null guard: network->cell(inst) is passed directly into network->libertyCell() without being checked for null first; the later !lc guard does not protect against a null cell argument.

Confidence Score: 4/5

Hold for the incomplete JSON escaping fix — the current jsonEscape will produce structurally invalid JSON if any path name or liberty cell name contains a control character.

One P1 finding (incomplete jsonEscape producing potentially invalid JSON) warrants a 4/5. The rest of the change is a clean, self-contained addition following the existing patterns in the codebase.

src/Silisizer.cpp — jsonEscape function needs control-character handling; network->cell(inst) should be null-checked before use.

Important Files Changed

Filename Overview
src/Silisizer.cpp Adds jsonEscape helper and dumpIcgJson function; jsonEscape is incomplete (missing control-char escaping) and the cell pointer from network->cell(inst) is not null-checked before use.
src/Silisizer.h Adds free-function declaration dumpIcgJson inside the silisizer namespace; straightforward.
src/Silisizer.i Adds SWIG extern declaration for dump_icg_json; matches the wrapper in main.cpp.
src/main.cpp Adds thin dump_icg_json wrapper that delegates to silisizer::dumpIcgJson; correct and consistent with existing silisize pattern.

Sequence Diagram

sequenceDiagram
    participant TCL as Tcl Script
    participant SWIG as Silisizer.i (SWIG)
    participant Main as main.cpp (dump_icg_json)
    participant Impl as Silisizer.cpp (dumpIcgJson)
    participant STA as sta::Sta / sta::Network
    participant FS as JSON File

    TCL->>SWIG: dump_icg_json(path)
    SWIG->>Main: dump_icg_json(path)
    Main->>Impl: silisizer::dumpIcgJson(path)
    Impl->>STA: sta::Sta::sta()
    Impl->>STA: sta->clockGatedRegisters()
    STA-->>Impl: list of gated flip-flops
    Impl->>FS: write gated_flops array
    Impl->>STA: network->leafInstanceIterator()
    loop each leaf instance
        Impl->>STA: network->cell(inst)
        Impl->>STA: network->libertyCell(cell)
        STA-->>Impl: LibertyCell*
        Impl->>Impl: lc->isClockGate() ?
        Impl->>FS: write ICG entry (pathName to libertyCell name)
    end
    Impl->>FS: close JSON object
Loading

Reviews (1): Last reviewed commit: "fix" | Re-trigger Greptile

Comment thread src/Silisizer.cpp Outdated
Comment thread src/Silisizer.cpp Outdated
Comment thread src/Silisizer.cpp Outdated
Comment thread src/Silisizer.cpp Outdated
Comment thread src/Silisizer.cpp Outdated
@akashlevy akashlevy merged commit cfe5d33 into main Apr 22, 2026
4 checks passed
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.

2 participants