Conversation
Greptile SummaryThis PR replaces the previous on-the-fly fanout-traversal approach to clock-gated register detection with a BFS-propagated
Confidence Score: 4/5Safe to merge after addressing the One P1 finding: search/Search.cc — specifically Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["findClkArrivals() / findArrivalsSeed()"] -->|"init clk_gated_ vector (size = vertexCount+1, all 0)"| B["BFS: ArrivalVisitor::visit(vertex)"]
B -->|"isClock(vertex)?"| C{Clock vertex?}
C -->|No| B
C -->|Yes| D["updateClkGates(vertex)"]
D --> E["isClkGateInstance(vertex)?"]
E -->|"cell->isClockGate() && enable not tied to constant"| F["gated = true"]
E -->|No| G["Iterate VertexInEdgeIterator"]
G --> H{"isClock(from)?"}
H -->|No - skip| G
H -->|Yes| I{"clk_gated_[id(from)] != 0?"}
I -->|Yes| F
I -->|No| G
F --> J["clk_gated_[id] = 1"]
G -->|exhausted| K["clk_gated_[id] = 0"]
J --> B
K --> B
B -->|BFS complete| L["clockGatedRegisters()"]
L --> M["leafInstanceIterator - skip non-registers and clock gates"]
M --> N["isClkGatedRegister(inst)"]
N --> O["pinLoadVertex for each reg clk pin"]
O --> P{"isClkGated(vertex)?"}
P -->|Yes| Q["Add inst to result"]
P -->|No| M
Reviews (3): Last reviewed commit: "check if the port is tied to a constant" | Re-trigger Greptile |
|
@greptile please review again |
|
@stanminlee can you look at the greptile comments? |
|
Marking as draft since we are not sure this actually solves the issue... |
|
@greptile take another look |
Previous implementation would accidentally flag flops that weren't actually gated
Now, on every vertex visit that is a clock edge (BFS)
Afterwards, we know if the flops are gated based on this attribute in a O(1) lookup.
I also changed how clock gates are identified because the liberty standard isn't always enforced. To be qualified as a clock gating cell, the cell must follow the following conditions:
Additionally, when determining if the ICG is logically gating something, we check if it is tied to a constant on the functional enable pin as a final check.
This prevents false flags from popping up in the case that a cell doesn't follow liberty standards