1 ///////////////////////////////////////////////////////////////////////////// 2 // 3 // BSD 3-Clause License 4 // 5 // Copyright (c) 2019, The Regents of the University of California 6 // All rights reserved. 7 // 8 // Redistribution and use in source and binary forms, with or without 9 // modification, are permitted provided that the following conditions are met: 10 // 11 // * Redistributions of source code must retain the above copyright notice, this 12 // list of conditions and the following disclaimer. 13 // 14 // * Redistributions in binary form must reproduce the above copyright notice, 15 // this list of conditions and the following disclaimer in the documentation 16 // and/or other materials provided with the distribution. 17 // 18 // * Neither the name of the copyright holder nor the names of its 19 // contributors may be used to endorse or promote products derived from 20 // this software without specific prior written permission. 21 // 22 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 26 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 // POSSIBILITY OF SUCH DAMAGE. 33 // 34 /////////////////////////////////////////////////////////////////////////////// 35 36 #pragma once 37 38 #include <algorithm> 39 #include <map> 40 #include <string> 41 #include <vector> 42 43 #include "opendb/db.h" 44 45 namespace grt { 46 47 class Net; 48 49 enum class PinOrientation 50 { 51 north, 52 south, 53 east, 54 west, 55 invalid 56 }; 57 58 class Pin 59 { 60 public: 61 Pin() = default; 62 Pin(odb::dbITerm* iterm, 63 const odb::Point& position, 64 const std::vector<int>& layers, 65 const PinOrientation orientation, 66 const std::map<int, std::vector<odb::Rect>>& boxes_per_layer, 67 bool connected_to_pad); 68 Pin(odb::dbBTerm* bterm, 69 const odb::Point& position, 70 const std::vector<int>& layers, 71 const PinOrientation orientation, 72 const std::map<int, std::vector<odb::Rect>>& boxes_per_layer, 73 bool connected_to_pad); 74 75 odb::dbITerm* getITerm() const; 76 odb::dbBTerm* getBTerm() const; 77 std::string getName() const; getPosition()78 const odb::Point& getPosition() const { return position_; } getLayers()79 const std::vector<int>& getLayers() const { return layers_; } getNumLayers()80 int getNumLayers() const { return layers_.size(); } getTopLayer()81 int getTopLayer() const { return layers_.back(); } getOrientation()82 PinOrientation getOrientation() const { return orientation_; } setOrientation(PinOrientation orientation)83 void setOrientation(PinOrientation orientation) 84 { 85 orientation_ = orientation; 86 } getBoxes()87 const std::map<int, std::vector<odb::Rect>>& getBoxes() const 88 { 89 return boxes_per_layer_; 90 } isPort()91 bool isPort() const { return is_port_; } isConnectedToPad()92 bool isConnectedToPad() const { return connected_to_pad_; } getOnGridPosition()93 const odb::Point& getOnGridPosition() const { return on_grid_position_; } setOnGridPosition(odb::Point on_grid_pos)94 void setOnGridPosition(odb::Point on_grid_pos) { on_grid_position_ = on_grid_pos; } 95 bool isDriver(); 96 97 private: 98 union 99 { 100 odb::dbITerm* iterm_; 101 odb::dbBTerm* bterm_; 102 }; 103 odb::Point position_; 104 odb::Point on_grid_position_; 105 std::vector<int> layers_; 106 PinOrientation orientation_; 107 std::map<int, std::vector<odb::Rect>> boxes_per_layer_; 108 bool is_port_; 109 bool connected_to_pad_; 110 }; 111 112 } // namespace grt 113