|
| 1 | + |
| 2 | +// BSD 3-Clause License |
| 3 | +// |
| 4 | +// Copyright (c) 2020, MICL, DD-Lab, University of Michigan |
| 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 | +#include <tcl.h> |
| 34 | +#include <map> |
| 35 | +#include "opendb/db.h" |
| 36 | +#include "opendb/dbWireGraph.h" |
| 37 | + |
| 38 | + |
| 39 | +struct PARinfo |
| 40 | +{ |
| 41 | + std::pair<odb::dbWireGraph::Node*, std::vector<odb::dbWireGraph::Node*>> WirerootNode; |
| 42 | + long unsigned int num_iterms; |
| 43 | + double wire_area; |
| 44 | + double side_wire_area; |
| 45 | + double iterm_areas[2]; |
| 46 | + double PAR_value; |
| 47 | + double PSR_value; |
| 48 | + double diff_PAR_value; |
| 49 | + double diff_PSR_value; |
| 50 | +}; |
| 51 | + |
| 52 | +struct ARinfo |
| 53 | +{ |
| 54 | + odb::dbWireGraph::Node * WirerootNode; |
| 55 | + odb::dbWireGraph::Node * GateNode; |
| 56 | + bool violated_net; |
| 57 | + double PAR_value; |
| 58 | + double PSR_value; |
| 59 | + double diff_PAR_value; |
| 60 | + double diff_PSR_value; |
| 61 | + double CAR_value; |
| 62 | + double CSR_value; |
| 63 | + double diff_CAR_value; |
| 64 | + double diff_CSR_value; |
| 65 | + double diff_area; |
| 66 | +}; |
| 67 | + |
| 68 | +struct ANTENNAmodel |
| 69 | +{ |
| 70 | + odb::dbTechLayer* layer; |
| 71 | + |
| 72 | + double metal_factor; |
| 73 | + double diff_metal_factor; |
| 74 | + |
| 75 | + double cut_factor; |
| 76 | + double diff_cut_factor; |
| 77 | + |
| 78 | + double side_metal_factor; |
| 79 | + double diff_side_metal_factor; |
| 80 | + |
| 81 | + double minus_diff_factor; |
| 82 | + double plus_diff_factor; |
| 83 | + double diff_metal_reduce_factor; |
| 84 | + |
| 85 | + ANTENNAmodel& operator =(const ANTENNAmodel& am) |
| 86 | + { |
| 87 | + metal_factor = am.metal_factor; |
| 88 | + diff_metal_factor = am.diff_metal_factor; |
| 89 | + cut_factor = am.cut_factor; |
| 90 | + diff_cut_factor = am.diff_cut_factor; |
| 91 | + side_metal_factor = am.side_metal_factor; |
| 92 | + diff_side_metal_factor = am.diff_side_metal_factor; |
| 93 | + minus_diff_factor = am.minus_diff_factor; |
| 94 | + plus_diff_factor = am.plus_diff_factor; |
| 95 | + diff_metal_reduce_factor = am.diff_metal_reduce_factor; |
| 96 | + |
| 97 | + return *this; |
| 98 | + } |
| 99 | + |
| 100 | + |
| 101 | +}; |
| 102 | + |
| 103 | +namespace antenna_checker { |
| 104 | + |
| 105 | +using odb::dbNet; |
| 106 | +using odb::dbWire; |
| 107 | +using odb::dbSWire; |
| 108 | +using odb::dbInst; |
| 109 | +using odb::dbWireGraph; |
| 110 | +using odb::dbTechLayer; |
| 111 | +using odb::dbITerm; |
| 112 | + |
| 113 | +typedef std::pair<dbWireGraph::Node*, std::vector<dbWireGraph::Node*>> wireroots_info_vec; |
| 114 | + |
| 115 | +class AntennaChecker |
| 116 | +{ |
| 117 | + |
| 118 | +public: |
| 119 | + AntennaChecker(); |
| 120 | + ~AntennaChecker(); |
| 121 | + |
| 122 | + void setDb( odb::dbDatabase *db ) { db_ = db; } |
| 123 | + void set_verbose( bool verbose ) { verbose_ = verbose; } |
| 124 | + void set_net_name( std::string net_name ) { net_name_ = net_name; } |
| 125 | + void set_route_level( int route_level ) { route_level_ = route_level; } |
| 126 | + |
| 127 | + dbNet* get_net( std::string net_name ); |
| 128 | + |
| 129 | + template <class valueType> |
| 130 | + double defdist( valueType value ); |
| 131 | + |
| 132 | + wireroots_info_vec find_segment_root(std::pair<dbWireGraph::Node*, std::vector<dbWireGraph::Node*>> node_info, int wire_level ); |
| 133 | + dbWireGraph::Node * find_segment_start( dbWireGraph::Node * node ); |
| 134 | + bool if_segment_root( dbWireGraph::Node * node, int wire_level ); |
| 135 | + |
| 136 | + void find_wire_below_iterms( dbWireGraph::Node * node, double iterm_areas[2], int wire_level, std::set<dbITerm*>& iv, std::set<dbWireGraph::Node*>& nv); |
| 137 | + std::pair<double, double> calculate_wire_area( dbWireGraph::Node * node, int wire_level, std::set<dbWireGraph::Node*>& nv, std::set<dbWireGraph::Node*>& level_nodes ); |
| 138 | + |
| 139 | + double get_via_area( dbWireGraph::Edge * edge ); |
| 140 | + dbTechLayer * get_via_layer( dbWireGraph::Edge * edge ); |
| 141 | + std::string get_via_name( dbWireGraph::Edge * edge ); |
| 142 | + double calculate_via_area( dbWireGraph::Node * node, int wire_level ); |
| 143 | + dbWireGraph::Edge * find_via( dbWireGraph::Node * node, int wire_level ); |
| 144 | + |
| 145 | + void find_car_path( dbWireGraph::Node * node, int wire_level, dbWireGraph::Node * goal, std::vector<dbWireGraph::Node *> ¤t_path, std::vector<dbWireGraph::Node *> &path_found ); |
| 146 | + |
| 147 | + void print_graph_info( dbWireGraph graph ); |
| 148 | + void calculate_PAR_table( std::vector<PARinfo>& PARtable ); |
| 149 | + bool check_iterm( dbWireGraph::Node* node, double iterm_areas[2] ); |
| 150 | + double get_pwl_factor(odb::dbTechLayerAntennaRule::pwl_pair pwl_info, double ref_val, double def); |
| 151 | + |
| 152 | + void build_wire_PAR_table( std::vector<PARinfo> &PARtable, std::vector<std::pair<dbWireGraph::Node *, std::vector<dbWireGraph::Node*>>> wireroots_info ); |
| 153 | + void build_wire_CAR_table( std::vector<ARinfo> &CARtable, std::vector<PARinfo> PARtable, std::vector<PARinfo> VIA_PARtable, std::vector<dbWireGraph::Node *> gate_iterms ); |
| 154 | + void build_VIA_PAR_table( std::vector<PARinfo> &VIA_PARtable, std::vector<std::pair<dbWireGraph::Node *,std::vector<dbWireGraph::Node*>>> wireroots_info ); |
| 155 | + void build_VIA_CAR_table( std::vector<ARinfo> &VIA_CARtable, std::vector<PARinfo> PARtable, std::vector<PARinfo> VIA_PARtable, std::vector<dbWireGraph::Node *> gate_iterms ); |
| 156 | + |
| 157 | + std::vector<wireroots_info_vec> get_wireroots(dbWireGraph graph); |
| 158 | + |
| 159 | + bool check_wire_PAR( ARinfo AntennaRatio ); |
| 160 | + bool check_wire_CAR( ARinfo AntennaRatio ); |
| 161 | + bool check_VIA_PAR( ARinfo AntennaRatio ); |
| 162 | + bool check_VIA_CAR( ARinfo AntennaRatio ); |
| 163 | + |
| 164 | + std::vector<int> GetAntennaRatio(); |
| 165 | + |
| 166 | + void load_antenna_rules(); |
| 167 | + void check_antennas(); |
| 168 | + |
| 169 | + void find_wireroot_iterms( dbWireGraph::Node * node, int wire_level, std::vector<dbITerm *>& gates ); |
| 170 | + std::vector<std::pair<double, std::vector<dbITerm *>>> PAR_max_wire_length( dbNet * net, int route_level ); |
| 171 | + void check_par_max_length(); |
| 172 | + std::vector<std::pair<int, std::vector<dbITerm *>>> get_net_antenna_violations( dbNet * net ); |
| 173 | + std::vector<std::pair<double, std::vector<dbITerm *>>> get_violated_wire_length( dbNet * net, int routing_level ); |
| 174 | + |
| 175 | +private: |
| 176 | + odb::dbDatabase *db_; |
| 177 | + FILE* _out; |
| 178 | + bool verbose_; |
| 179 | + std::string net_name_; |
| 180 | + int route_level_; |
| 181 | + std::map<odb::dbTechLayer*, ANTENNAmodel> layer_info; |
| 182 | + |
| 183 | + |
| 184 | +}; |
| 185 | + |
| 186 | +} |
0 commit comments