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 #include "grt/MakeGlobalRouter.h"
37 
38 #include "FastRoute.h"
39 #include "grt/GlobalRouter.h"
40 #include "ord/OpenRoad.hh"
41 #include "sta/StaMain.hh"
42 
43 namespace sta {
44 // Tcl files encoded into strings.
45 extern const char* grt_tcl_inits[];
46 }  // namespace sta
47 
48 extern "C" {
49 extern int Grt_Init(Tcl_Interp* interp);
50 }
51 
52 namespace ord {
53 
makeGlobalRouter()54 grt::GlobalRouter* makeGlobalRouter()
55 {
56   return new grt::GlobalRouter();
57 }
58 
deleteGlobalRouter(grt::GlobalRouter * global_router)59 void deleteGlobalRouter(grt::GlobalRouter* global_router)
60 {
61   delete global_router;
62 }
63 
initGlobalRouter(OpenRoad * openroad)64 void initGlobalRouter(OpenRoad* openroad)
65 {
66   Tcl_Interp* tcl_interp = openroad->tclInterp();
67   // Define swig TCL commands.
68   Grt_Init(tcl_interp);
69   sta::evalTclInit(tcl_interp, sta::grt_tcl_inits);
70   openroad->getGlobalRouter()->init(openroad);
71 }
72 
73 }  // namespace ord
74