File size: 3,010 Bytes
f61bac1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 2025, The OpenROAD Authors

#pragma once

#include <string>

#include "odb/db.h"
#include "odb/geom.h"

namespace utl {
class Logger;
}  // namespace utl

namespace sta {

// IP Checker: Currently validates LEF macro definitions
// Checks performed:
// LEF-CHK-001: Macro dimensions aligned to manufacturing grid
// LEF-CHK-002: Pin coordinates aligned to manufacturing grid
// LEF-CHK-003: Pin routing grid alignment
// LEF-CHK-004-005: Pin accessibility (signal and power)
// LEF-CHK-006: Polygon count
// LEF-CHK-007: Antenna information present
// LEF-CHK-008: FinFET technology detection (info only)
// LEF-CHK-009: Pin geometry presence
// LEF-CHK-010a: Pin minimum width (perpendicular to routing direction)
// LEF-CHK-010b: Pin minimum area

class IpChecker
{
 public:
  IpChecker(odb::dbDatabase* db, utl::Logger* logger);

  // Configuration
  void setMaxPolygons(int max) { max_polygons_ = max; }
  void setVerbose(bool verbose) { verbose_ = verbose; }

  // Check a specific macro by name
  // Returns true if no warnings found
  bool checkMaster(const std::string& master_name);

  // Check all macros in loaded libraries
  // Returns true if no warnings found
  bool checkAll();

  // Get warning count from last check
  int getWarningCount() const { return warning_count_; }

 private:
  // Reset warning counter before a new check
  void reset();

  // LEF checks - run on a single dbMaster
  void checkLefMaster(odb::dbMaster* master);

  // LEF-CHK-001: Macro dimensions aligned to manufacturing grid
  void checkManufacturingGridAlignment(odb::dbMaster* master);

  // LEF-CHK-002: Pin coordinates aligned to manufacturing grid
  void checkPinManufacturingGridAlignment(odb::dbMaster* master);

  // LEF-CHK-003: Pin routing grid alignment
  void checkPinRoutingGridAlignment(odb::dbMaster* master);

  // LEF-CHK-004-005: Pin accessibility (signal and power)
  void checkPinAccessibility(odb::dbMaster* master);

  // LEF-CHK-006: Polygon count
  void checkPolygonCount(odb::dbMaster* master);

  // LEF-CHK-007: Antenna information present
  void checkAntennaInfo(odb::dbMaster* master);

  // LEF-CHK-008: FinFET property (info only)
  void checkFinFetProperty(odb::dbMaster* master);

  // LEF-CHK-009: Pin geometry presence
  void checkPinGeometryPresence(odb::dbMaster* master);

  // LEF-CHK-010a: Pin minimum width (perpendicular to routing direction)
  void checkPinMinDimensions(odb::dbMaster* master);

  // LEF-CHK-010b: Pin minimum area
  void checkPinMinArea(odb::dbMaster* master);

  // Helper: Check if a pin shape has at least one accessible edge
  bool hasAccessibleEdge(odb::dbMaster* master,
                         const odb::Rect& pin_rect,
                         odb::dbTechLayer* layer);

  // Member variables
  odb::dbDatabase* db_;
  utl::Logger* logger_;

  // Configuration
  int max_polygons_ = 10000;
  bool verbose_ = false;

  // Warning counter
  int warning_count_ = 0;
};

}  // namespace sta