1 /* Authors: Lutong Wang and Bangqi Xu */ 2 /* 3 * Copyright (c) 2019, The Regents of the University of California 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are met: 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * * Neither the name of the University nor the 14 * names of its contributors may be used to endorse or promote products 15 * derived from this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS BE LIABLE FOR ANY DIRECT, 21 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 #ifndef _FR_BASE_TYPES_H_ 30 #define _FR_BASE_TYPES_H_ 31 32 #include <boost/geometry/geometries/box.hpp> 33 #include <boost/geometry/geometries/point_xy.hpp> 34 #include <cstdint> 35 #include <list> 36 #include <map> 37 #include <string> 38 #include <utility> 39 #include <vector> 40 41 #include "utl/Logger.h" 42 43 namespace fr { 44 using Logger = utl::Logger; 45 const utl::ToolId DRT = utl::DRT; 46 using frLayerNum = int; 47 using frCoord = int; 48 using frArea = uint64_t; 49 using frSquaredDistance = uint64_t; 50 using frUInt4 = unsigned int; 51 using frDist = double; 52 using frString = std::string; 53 using frCost = unsigned int; 54 using frMIdx = int; // negative value expected 55 template <typename T> 56 using frCollection = std::vector<T>; 57 template <typename T> 58 using frVector = std::vector<T>; 59 template <typename T> 60 using frList = std::list<T>; 61 template <typename T> 62 using frListIter = typename std::list<T>::iterator; 63 64 enum frOrientEnum 65 { 66 frcR0 = 0, // N 67 frcR90 = 1, // W 68 frcR180 = 2, // S 69 frcR270 = 3, // E 70 frcMY = 4, // FN 71 frcMXR90 = 5, // FW 72 frcMX = 6, // FS 73 frcMYR90 = 7 // FE 74 }; 75 enum frEndStyleEnum 76 { 77 frcTruncateEndStyle = 0, // ext = 0 78 frcExtendEndStyle = 1, // ext = half width 79 frcVariableEndStyle = 2 // ext = variable 80 }; 81 enum frPrefRoutingDirEnum 82 { 83 frcNotApplicablePrefRoutingDir = 0, 84 frcNonePrefRoutingDir = 1, 85 frcHorzPrefRoutingDir = 2, 86 frcVertPrefRoutingDir = 3 87 }; 88 enum frBlockObjectEnum 89 { 90 frcNet, 91 frcTerm, 92 frcInst, 93 frcVia, 94 frcPin, 95 frcInstTerm, 96 frcRect, 97 frcPolygon, 98 frcSteiner, 99 frcRoute, 100 frcPathSeg, 101 frcGuide, 102 frcBlockage, 103 frcLayerBlockage, 104 frcBlock, 105 frcBoundary, 106 frcInstBlockage, 107 frcAccessPattern, 108 frcMarker, 109 frcNode, 110 frcPatchWire, 111 frcRPin, 112 frcAccessPoint, 113 frcAccessPoints, 114 frcPinAccess, 115 frcCMap, 116 frcGCellPattern, 117 frcTrackPattern, 118 grcNode, 119 grcNet, 120 grcPin, 121 grcAccessPattern, 122 grcPathSeg, 123 grcRef, 124 grcVia, 125 drcNet, 126 drcPin, 127 drcAccessPattern, 128 drcPathSeg, 129 drcVia, 130 drcMazeMarker, 131 drcPatchWire, 132 tacTrack, 133 tacPin, 134 tacPathSeg, 135 tacVia, 136 gccNet, 137 gccPin, 138 gccEdge, 139 gccRect, 140 gccPolygon 141 }; 142 enum class frGuideEnum 143 { 144 frcGuideX, 145 frcGuideGlobal, 146 frcGuideTrunk, 147 frcGuideShortConn 148 }; 149 enum class frTermEnum 150 { 151 frcNormalTerm, 152 frcClockTerm, 153 frcPowerTerm, 154 frcGroundTerm 155 }; 156 enum class frNetEnum 157 { 158 frcNormalNet, 159 frcClockNet, 160 frcPowerNet, 161 frcGroundNet 162 }; 163 enum class frTermDirectionEnum 164 { 165 UNKNOWN, 166 INPUT, 167 OUTPUT, 168 INOUT, 169 FEEDTHRU, 170 }; 171 enum class frNodeTypeEnum 172 { 173 frcSteiner, 174 frcBoundaryPin, 175 frcPin 176 }; 177 178 enum class frConstraintTypeEnum 179 { // check FlexDR.h fixMode 180 frcShortConstraint = 0, 181 frcAreaConstraint = 1, 182 frcMinWidthConstraint = 2, 183 frcSpacingConstraint = 3, 184 frcSpacingEndOfLineConstraint = 4, 185 frcSpacingEndOfLineParallelEdgeConstraint = 5, // not supported 186 frcSpacingTableConstraint = 6, // not supported 187 frcSpacingTablePrlConstraint = 7, 188 frcSpacingTableTwConstraint = 8, 189 frcLef58SpacingTableConstraint = 9, // not supported 190 frcLef58CutSpacingTableConstraint = 10, // not supported 191 frcLef58CutSpacingTablePrlConstraint = 11, // not supported 192 frcLef58CutSpacingTableLayerConstraint = 12, // not supported 193 frcLef58CutSpacingConstraint = 13, // not supported 194 frcLef58CutSpacingParallelWithinConstraint = 14, // not supported 195 frcLef58CutSpacingAdjacentCutsConstraint = 15, // not supported 196 frcLef58CutSpacingLayerConstraint = 16, // not supported 197 frcCutSpacingConstraint = 17, 198 frcMinStepConstraint, 199 frcLef58MinStepConstraint, 200 frcMinimumcutConstraint, 201 frcOffGridConstraint, 202 frcMinEnclosedAreaConstraint, 203 frcLef58CornerSpacingConstraint, // not supported 204 frcLef58CornerSpacingConcaveCornerConstraint, // not supported 205 frcLef58CornerSpacingConvexCornerConstraint, // not supported 206 frcLef58CornerSpacingSpacingConstraint, // not supported 207 frcLef58CornerSpacingSpacing1DConstraint, // not supported 208 frcLef58CornerSpacingSpacing2DConstraint, // not supported 209 frcLef58SpacingEndOfLineConstraint, 210 frcLef58SpacingEndOfLineWithinConstraint, 211 frcLef58SpacingEndOfLineWithinEndToEndConstraint, // not supported 212 frcLef58SpacingEndOfLineWithinEncloseCutConstraint, 213 frcLef58SpacingEndOfLineWithinParallelEdgeConstraint, 214 frcLef58SpacingEndOfLineWithinMaxMinLengthConstraint, 215 frcLef58CutClassConstraint, // not supported 216 frcNonSufficientMetalConstraint, 217 frcSpacingSamenetConstraint, 218 frcLef58RightWayOnGridOnlyConstraint, 219 frcLef58RectOnlyConstraint, 220 frcRecheckConstraint, 221 frcSpacingTableInfluenceConstraint, 222 frcLef58EolExtensionConstraint, 223 frcLef58EolKeepOutConstraint 224 }; 225 226 enum class frCornerTypeEnum 227 { 228 UNKNOWN, 229 CONCAVE, 230 CONVEX 231 }; 232 233 enum class frCornerDirEnum 234 { 235 UNKNOWN, 236 NE, 237 SE, 238 SW, 239 NW 240 }; 241 242 enum class frMinimumcutConnectionEnum 243 { 244 UNKNOWN = -1, 245 FROMABOVE = 0, 246 FROMBELOW = 1 247 }; 248 249 enum class frMinstepTypeEnum 250 { 251 UNKNOWN = -1, 252 INSIDECORNER = 0, 253 OUTSIDECORNER = 1, 254 STEP = 2 255 }; 256 257 #define OPPOSITEDIR 7 // used in FlexGC_main.cpp 258 enum class frDirEnum 259 { 260 UNKNOWN = 0, 261 D = 1, 262 S = 2, 263 W = 3, 264 E = 4, 265 N = 5, 266 U = 6 267 }; 268 269 enum class frLayerTypeEnum 270 { 271 CUT, 272 ROUTING, 273 IMPLANT, 274 MASTERSLICE 275 }; 276 277 enum class AccessPointTypeEnum 278 { 279 Ideal, 280 Good, 281 Offgrid, 282 None 283 }; 284 285 enum class MacroClassEnum 286 { 287 UNKNOWN, 288 CORE, 289 CORE_TIEHIGH, 290 CORE_TIELOW, 291 CORE_WELLTAP, 292 CORE_SPACER, 293 CORE_ANTENNACELL, 294 COVER, 295 BLOCK, 296 RING, 297 PAD, 298 PAD_INPUT, 299 PAD_OUTPUT, 300 PAD_INOUT, 301 PAD_POWER, 302 PAD_SPACER, 303 PAD_AREAIO, 304 ENDCAP, 305 ENDCAP_PRE, 306 ENDCAP_POST, 307 ENDCAP_TOPLEFT, 308 ENDCAP_TOPRIGHT, 309 ENDCAP_BOTTOMLEFT, 310 ENDCAP_BOTTOMRIGHT 311 }; 312 313 // This will go away when we move to OpenDB's types 314 bool isPad(MacroClassEnum e); 315 bool isEndcap(MacroClassEnum e); 316 317 // note: In ascending cost order for FlexPA 318 enum class frAccessPointEnum 319 { 320 OnGrid = 0, 321 HalfGrid = 1, 322 Center = 2, 323 EncOpt = 3, 324 NearbyGrid = 4 // nearby grid or 1/2 grid 325 }; 326 327 namespace bg = boost::geometry; 328 329 typedef bg::model::d2::point_xy<frCoord, bg::cs::cartesian> point_t; 330 typedef bg::model::box<point_t> box_t; 331 typedef bg::model::segment<point_t> segment_t; 332 333 class frBox; 334 335 template <typename T> 336 using rq_box_value_t = std::pair<frBox, T>; 337 338 struct frDebugSettings 339 { frDebugSettingsfrDebugSettings340 frDebugSettings() 341 : debugDR(false), 342 debugMaze(false), 343 debugPA(false), 344 draw(true), 345 allowPause(true), 346 gcellX(-1), 347 gcellY(-1), 348 iter(0), 349 paMarkers(false) 350 { 351 } 352 is_onfrDebugSettings353 bool is_on() const { return debugDR || debugPA; } 354 355 bool debugDR; 356 bool debugMaze; 357 bool debugPA; 358 bool draw; 359 bool allowPause; 360 std::string netName; 361 std::string pinName; 362 int gcellX; 363 int gcellY; 364 int iter; 365 bool paMarkers; 366 }; 367 } // namespace fr 368 369 #endif 370