1 /////////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (c) 2019, 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 %{
36
37 #include "ord/OpenRoad.hh"
38 #include "dpl/Opendp.h"
39 #include "utl/Logger.h"
40
41 namespace dpl {
42
43 using std::vector;
44
45 // Swig vector type in does not seem to work at all.
46 // (see OpenDB/src/swig/common/polgon.i)
47 // Copied from opensta/tcl/StaTcl.i
48 template <class TYPE>
49 vector<TYPE> *
tclListSeq(Tcl_Obj * const source,swig_type_info * swig_type,Tcl_Interp * interp)50 tclListSeq(Tcl_Obj *const source,
51 swig_type_info *swig_type,
52 Tcl_Interp *interp)
53 {
54 int argc;
55 Tcl_Obj **argv;
56
57 if (Tcl_ListObjGetElements(interp, source, &argc, &argv) == TCL_OK
58 && argc > 0) {
59 vector<TYPE> *seq = new vector<TYPE>;
60 for (int i = 0; i < argc; i++) {
61 void *obj;
62 // Ignore returned TCL_ERROR because can't get swig_type_info.
63 SWIG_ConvertPtr(argv[i], &obj, swig_type, false);
64 seq->push_back(reinterpret_cast<TYPE>(obj));
65 }
66 return seq;
67 }
68 else
69 return nullptr;
70 }
71
72 dpl::dbMasterSeq *
tclListSeqdbMaster(Tcl_Obj * const source,Tcl_Interp * interp)73 tclListSeqdbMaster(Tcl_Obj *const source,
74 Tcl_Interp *interp)
75 {
76 return tclListSeq<odb::dbMaster*>(source, SWIGTYPE_p_odb__dbMaster, interp);
77 }
78
79 }
80
81 %}
82
83 %include "../../Exception.i"
84
85 %typemap(in) dpl::dbMasterSeq * {
86 $1 = dpl::tclListSeqdbMaster($input, interp);
87 }
88
89 %inline %{
90
91 namespace dpl {
92
93 void
detailed_placement_cmd(int max_displacment)94 detailed_placement_cmd(int max_displacment)
95 {
96 dpl::Opendp *opendp = ord::OpenRoad::openRoad()->getOpendp();
97 opendp->detailedPlacement(max_displacment);
98 }
99
100 void
report_legalization_stats()101 report_legalization_stats()
102 {
103 dpl::Opendp *opendp = ord::OpenRoad::openRoad()->getOpendp();
104 opendp->reportLegalizationStats();
105 }
106
107 int
check_placement_cmd(bool verbose)108 check_placement_cmd(bool verbose)
109 {
110 dpl::Opendp *opendp = ord::OpenRoad::openRoad()->getOpendp();
111 return opendp->checkPlacement(verbose);
112 }
113
114
115 void
set_padding_global(int left,int right)116 set_padding_global(int left,
117 int right)
118 {
119 dpl::Opendp *opendp = ord::OpenRoad::openRoad()->getOpendp();
120 opendp->setPaddingGlobal(left, right);
121 }
122
123 void
set_padding_master(odb::dbMaster * master,int left,int right)124 set_padding_master(odb::dbMaster *master,
125 int left,
126 int right)
127 {
128 dpl::Opendp *opendp = ord::OpenRoad::openRoad()->getOpendp();
129 opendp->setPadding(master, left, right);
130 }
131
132 void
set_padding_inst(odb::dbInst * inst,int left,int right)133 set_padding_inst(odb::dbInst *inst,
134 int left,
135 int right)
136 {
137 dpl::Opendp *opendp = ord::OpenRoad::openRoad()->getOpendp();
138 opendp->setPadding(inst, left, right);
139 }
140
141 void
filler_placement_cmd(dpl::dbMasterSeq * filler_masters,const char * prefix)142 filler_placement_cmd(dpl::dbMasterSeq *filler_masters,
143 const char* prefix)
144 {
145 dpl::Opendp *opendp = ord::OpenRoad::openRoad()->getOpendp();
146 opendp->fillerPlacement(filler_masters, prefix);
147 }
148
149 void
optimize_mirroring_cmd()150 optimize_mirroring_cmd()
151 {
152 dpl::Opendp *opendp = ord::OpenRoad::openRoad()->getOpendp();
153 opendp->optimizeMirroring();
154 }
155
156 } // namespace
157
158 %} // inline
159