1 /////////////////////////////////////////////////////////////////////////////// 2 // BSD 3-Clause License 3 // 4 // Copyright (c) 2019, Nefelus Inc 5 // All rights reserved. 6 // 7 // Redistribution and use in source and binary forms, with or without 8 // modification, are permitted provided that the following conditions are met: 9 // 10 // * Redistributions of source code must retain the above copyright notice, this 11 // list of conditions and the following disclaimer. 12 // 13 // * Redistributions in binary form must reproduce the above copyright notice, 14 // this list of conditions and the following disclaimer in the documentation 15 // and/or other materials provided with the distribution. 16 // 17 // * Neither the name of the copyright holder nor the names of its 18 // contributors may be used to endorse or promote products derived from 19 // this software without specific prior written permission. 20 // 21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 25 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 // POSSIBILITY OF SUCH DAMAGE. 32 33 #pragma once 34 35 #include <map> 36 37 #include "dbFlatten.h" 38 #include "dbTransform.h" 39 #include "dbTypes.h" 40 #include "dbVector.h" 41 #include "odb.h" 42 43 namespace odb { 44 45 class dbBlock; 46 class dbNet; 47 class dbInst; 48 class dbVia; 49 class dbWire; 50 class dbSWire; 51 class dbObstruction; 52 class dbBlockage; 53 class dbRegion; 54 class dbTechLayerRule; 55 class dbTechNonDefaultRule; 56 class dbProperty; 57 class dbCapNode; 58 59 class dbFlatten 60 { 61 bool _do_not_copy_power_wires; 62 bool _copy_shields; 63 bool _create_boundary_regions; 64 bool _create_bterm_map; 65 bool _copy_parasitics; 66 std::map<dbNet*, dbNet*> _net_map; 67 std::map<dbVia*, dbVia*> _via_map; 68 std::map<dbInst*, dbInst*> _inst_map; 69 std::map<int, int> _node_map; 70 std::map<int, int> _shape_rc_map; 71 std::map<dbTechLayerRule*, dbTechLayerRule*> _layer_rule_map; 72 std::map<dbRegion*, dbRegion*> _reg_map; 73 dbTransform _transform; 74 char _hier_d; 75 int _next_bterm_map_id; 76 77 bool canCopyWire(dbWire* wire, dbSigType::Value sig_type); 78 bool canCopySWire(dbSWire* wire, dbSigType::Value sig_type); 79 void copySWire(dbNet* dst, dbNet* src, dbSWire* src_swire); 80 void copyNetWires(dbNet* dst_, dbNet* src_, int level, dbProperty* bterm_map); 81 void copyWires(dbNet* dst_, 82 dbNet* src_, 83 int level, 84 dbProperty* bterm_map, 85 bool copyParasitics); 86 void copySWires(dbNet* dst_, dbNet* src_); 87 void copyAttrs(dbNet* dst, dbNet* src); 88 void copyAttrs(dbInst* dst, dbInst* src); 89 dbNet* getParentNet(dbBlock* parent_block, dbNet* child_net); 90 bool copyInst(dbBlock* parent, dbInst* child, dbInst* grandchild); 91 bool flatten(dbBlock* parent, 92 dbBlock* child, 93 int level, 94 dbProperty* bterm_map); 95 dbNet* copyNet(dbBlock* parent_block, dbNet* child_net); 96 dbTechNonDefaultRule* copyNonDefaultRule(dbBlock* parent, 97 dbInst* child, 98 dbTechNonDefaultRule* child_rule); 99 void fixWire(dbVector<unsigned char>& opcodes, 100 dbVector<int>& data, 101 dbBlock* src, 102 int level, 103 dbProperty* bterm_map); 104 void appendWire(dbVector<unsigned char>& opcodes, 105 dbVector<int>& data, 106 dbWire* dst_); 107 void copyObstruction(dbBlock* dst_block, dbObstruction* src); 108 void copyBlockage(dbBlock* dst_block, dbBlockage* src); 109 void copyRegion(dbBlock* parent_block, 110 dbInst* child_inst, 111 dbRegion* parent_region, 112 dbRegion* src); 113 void setShapeProperties(dbWire* wire); 114 void setOldShapeIds(dbWire* wire); 115 void mapOld2newIds(dbWire* wire, FILE* fp); 116 bool createParentCapNode(dbCapNode* node, dbNet* dstNet); 117 void createTop1stRseg(dbNet* src, dbNet* dst); 118 dbCapNode* checkNode(dbCapNode* src, uint srcTermId); 119 uint adjustParentNode(dbNet* dstNet, uint srcTermId); 120 uint adjustParentNode2(dbNet* dstNet, uint srcTermId); 121 uint createCapNodes(dbNet* src, dbNet* dst, bool noDstWires); 122 uint createRSegs(dbNet* src, dbNet* dst); 123 uint printRSegs(FILE* fp, dbNet* net); 124 uint setCorrectRsegIds(dbNet* dst); 125 FILE* debugNetWires(FILE* fp, dbNet* dst, dbNet* src, const char* msg); 126 127 public: 128 dbFlatten(); 129 ~dbFlatten(); 130 setCreateBoundaryRegions(bool value)131 void setCreateBoundaryRegions(bool value) 132 { 133 _create_boundary_regions = value; 134 } setCreateBTermMap(bool value)135 void setCreateBTermMap(bool value) { _create_bterm_map = value; } setCopyParasitics(bool value)136 void setCopyParasitics(bool value) { _copy_parasitics = value; } 137 bool flatten(dbBlock* block, int level); 138 void printShapes(FILE* fp, dbWire* wire, bool skipRCs = false); 139 }; 140 141 } // namespace odb 142