|
| 1 | +///////////////////////////////////////////////////////////////////////////// |
| 2 | +// |
| 3 | +// Copyright (c) 2023, The Regents of the University of California |
| 4 | +// All rights reserved. |
| 5 | +// |
| 6 | +// BSD 3-Clause License |
| 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 | +%module pdngen |
| 36 | +%{ |
| 37 | + |
| 38 | +// These includes are needed by the SWIG generated CXX files mostly |
| 39 | +// for determining the size of Classes that they define. Since that are |
| 40 | +// not actually wrapped, the classes defined in these files will appear as |
| 41 | +// opaque pointers in Python. |
| 42 | +#include "../src/connect.h" |
| 43 | +#include "../src/domain.h" |
| 44 | +#include "../src/grid.h" |
| 45 | +#include "../src/power_cells.h" |
| 46 | +#include "../src/renderer.h" |
| 47 | + |
| 48 | +#include "pdn/PdnGen.hh" |
| 49 | +#include "odb/db.h" |
| 50 | +#include <array> |
| 51 | +#include <string> |
| 52 | +#include <memory> |
| 53 | +#include <vector> |
| 54 | + |
| 55 | +using pdn::ExtensionMode; |
| 56 | +using namespace pdn; |
| 57 | + |
| 58 | +%} |
| 59 | + |
| 60 | +%include <std_vector.i> |
| 61 | +%include <std_array.i> |
| 62 | +%include <std_map.i> |
| 63 | + |
| 64 | +// this maps unsigned long to the enum ExtensionMode |
| 65 | +%include typemaps.i |
| 66 | +%apply unsigned long { ExtensionMode }; |
| 67 | + |
| 68 | +%import "odb.i" |
| 69 | +%import "dbtypes.i" |
| 70 | +%include <std_string.i> |
| 71 | + |
| 72 | +// These are needed to coax swig into sending or returning Python |
| 73 | +// lists, arrays, or sets (as appropriate) of opaque pointers. Note |
| 74 | +// that you must %include (not %import) <std_vector.i> and <std_array.i> |
| 75 | +// before these definitions |
| 76 | +namespace std { |
| 77 | + %template(split_cuts_stuff) std::vector<int>; |
| 78 | + %template(stuff) std::array<int, 4>; |
| 79 | + %template(split_map) std::map<odb::dbTechLayer *, int>; |
| 80 | + %template(grid_list) std::vector<pdn::Grid *>; |
| 81 | + %template(domain_list) std::vector<pdn::VoltageDomain *>; |
| 82 | + %template(net_list) std::vector<odb::dbNet *>; |
| 83 | + %template(viagen_list) std::vector<odb::dbTechViaGenerateRule *>; |
| 84 | + %template(techvia_list) std::vector<odb::dbTechVia *>; |
| 85 | + %template(layer_list) std::vector<odb::dbTechLayer *>; |
| 86 | +} |
| 87 | + |
| 88 | +%include "../../Exception-py.i" |
| 89 | +%include "pdn/PdnGen.hh" |
| 90 | + |
| 91 | +%inline %{ |
| 92 | + |
| 93 | +namespace pdn { |
| 94 | + |
| 95 | +// difficult to pass a set. repair_pdn_via takes a vector and then |
| 96 | +// rebuilds the set in C++, so we just borrow that here. |
| 97 | +void repair_pdn_vias(const std::vector<odb::dbNet*>& nets); |
| 98 | + |
| 99 | +} // namespace |
| 100 | + |
| 101 | +%} // %inline |
0 commit comments