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_INST_H_ 30 #define _FR_INST_H_ 31 32 #include <memory> 33 34 #include "db/obj/frBlockage.h" 35 #include "db/obj/frInstBlockage.h" 36 #include "db/obj/frInstTerm.h" 37 #include "db/obj/frRef.h" 38 #include "frBaseTypes.h" 39 40 namespace fr { 41 class frBlock; 42 class frInst : public frRef 43 { 44 public: 45 // constructors frInst(const frString & name,frBlock * refBlock)46 frInst(const frString& name, frBlock* refBlock) 47 : name_(name), refBlock_(refBlock), pinAccessIdx_(0) 48 { 49 } 50 // getters getName()51 const frString& getName() const { return name_; } getRefBlock()52 frBlock* getRefBlock() const { return refBlock_; } getInstTerms()53 const std::vector<std::unique_ptr<frInstTerm>>& getInstTerms() const 54 { 55 return instTerms_; 56 } getInstBlockages()57 const std::vector<std::unique_ptr<frInstBlockage>>& getInstBlockages() const 58 { 59 return instBlockages_; 60 } getPinAccessIdx()61 int getPinAccessIdx() const { return pinAccessIdx_; } 62 // setters addInstTerm(std::unique_ptr<frInstTerm> in)63 void addInstTerm(std::unique_ptr<frInstTerm> in) 64 { 65 instTerms_.push_back(std::move(in)); 66 } addInstBlockage(std::unique_ptr<frInstBlockage> in)67 void addInstBlockage(std::unique_ptr<frInstBlockage> in) 68 { 69 instBlockages_.push_back(std::move(in)); 70 } setPinAccessIdx(int in)71 void setPinAccessIdx(int in) { pinAccessIdx_ = in; } 72 // others typeId()73 frBlockObjectEnum typeId() const override { return frcInst; } 74 75 /* from frRef 76 * getOrient 77 * setOrient 78 * getOrigin 79 * setOrigin 80 * getTransform 81 * setTransform 82 */ 83 getOrient()84 frOrient getOrient() const override { return xform_.orient(); } setOrient(const frOrient & tmpOrient)85 void setOrient(const frOrient& tmpOrient) override { xform_.set(tmpOrient); } getOrigin(frPoint & tmpOrigin)86 void getOrigin(frPoint& tmpOrigin) const override 87 { 88 tmpOrigin.set(xform_.xOffset(), xform_.yOffset()); 89 } setOrigin(const frPoint & tmpPoint)90 void setOrigin(const frPoint& tmpPoint) override { xform_.set(tmpPoint); } getTransform(frTransform & xformIn)91 void getTransform(frTransform& xformIn) const override 92 { 93 xformIn.set(xform_.xOffset(), xform_.yOffset(), xform_.orient()); 94 } setTransform(const frTransform & xformIn)95 void setTransform(const frTransform& xformIn) override 96 { 97 xform_.set(xformIn.xOffset(), xformIn.yOffset(), xformIn.orient()); 98 } 99 100 /* from frPinFig 101 * hasPin 102 * getPin 103 * addToPin 104 * removeFromPin 105 */ 106 hasPin()107 bool hasPin() const override { return false; } getPin()108 frPin* getPin() const override { return nullptr; } addToPin(frPin * in)109 void addToPin(frPin* in) override { ; } removeFromPin()110 void removeFromPin() override { ; } 111 112 /* from frConnFig 113 * hasNet 114 * getNet 115 * addToNet 116 * removeFromNet 117 */ 118 hasNet()119 bool hasNet() const override { return false; } getNet()120 frNet* getNet() const override { return nullptr; } addToNet(frNet * in)121 void addToNet(frNet* in) override { ; } removeFromNet()122 void removeFromNet() override { ; } 123 124 /* from frFig 125 * getBBox 126 * move 127 * overlaps 128 */ 129 130 void getBBox(frBox& boxIn) const override; 131 move(const frTransform & xform)132 void move(const frTransform& xform) override { ; } overlaps(const frBox & box)133 bool overlaps(const frBox& box) const override { return false; } 134 // others 135 void getUpdatedXform(frTransform& in, bool noOrient = false) const; 136 void getBoundaryBBox(frBox& in) const; 137 138 protected: 139 frString name_; 140 fr::frBlock* refBlock_; 141 std::vector<std::unique_ptr<frInstTerm>> instTerms_; 142 std::vector<std::unique_ptr<frInstBlockage>> instBlockages_; 143 frTransform xform_; 144 int pinAccessIdx_; 145 }; 146 } // namespace fr 147 148 #endif 149