Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
6ca65ab
Very preliminary work on the new Python API in #1812
maliberty May 10, 2022
6a7fc4a
Python API: remove lib_name from Tech::readLEF
maliberty May 17, 2022
149b955
Merge branch 'master' into python-api
maliberty May 19, 2022
9b687da
Swig InitFloorplan directly and drop the wrapper Floorplan class.
maliberty May 23, 2022
5ed51c2
add __pycache__ to .gitignore
maliberty May 23, 2022
915fbb8
ifp: add make_tracks1.py with refactoring
maliberty May 23, 2022
c4cd9c0
ifp: make imports pep8 compliant
maliberty May 24, 2022
2e122f1
Merge branch 'master' into python-api
maliberty Jun 18, 2022
2d0532f
ifp: py test, read single LEF
maliberty Jun 20, 2022
eec6255
Merge branch 'master' into python-api
maliberty Jul 27, 2022
137614e
Merge branch 'master' into python-api
maliberty Aug 2, 2022
766adff
get regression scripts to work with python tests
maliberty Aug 11, 2022
f9227d9
Merge branch 'master' into python-api
maliberty Aug 12, 2022
8aeba8f
Add suppress_message and get regression working with python
maliberty Aug 16, 2022
313c5f1
get flow regressions working
maliberty Aug 16, 2022
5f0e5f9
Merge branch 'master' into python-api
maliberty Aug 16, 2022
a899bd1
Merge branch 'master' into python-api
maliberty Aug 23, 2022
8e59f2d
Merge branch 'master' into python-api
maliberty Aug 25, 2022
5e4a1c6
merge master
maliberty Sep 14, 2022
9000d09
pdn/rsz: update tests for python
maliberty Sep 15, 2022
7de1a46
Finished Python tests for ifp
macd Sep 16, 2022
787ec36
Merge pull request #2 from macd/python-api
maliberty Sep 19, 2022
37a35d0
ifp: minor cleanup
maliberty Sep 20, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ TAGS
.~lock.*#
.DS_Store
Makefile
__pycache__

include/ord/Version.hh

Expand Down
74 changes: 74 additions & 0 deletions include/ord/Design.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2022, The Regents of the University of California
// All rights reserved.
//
// BSD 3-Clause License
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////////

#pragma once

#include <string>

namespace odb {
class dbBlock;
} // namespace odb

namespace ifp {
class InitFloorplan;
}

namespace ord {

class Tech;

class Design
{
public:
Design(Tech* tech);
void readVerilog(const std::string& file_name);
void link(const std::string& design_name);

void writeDb(const std::string& file_name);
void writeDef(const std::string& file_name);

odb::dbBlock* getBlock();
utl::Logger* getLogger();

int micronToDBU(double coord);

// Services
ifp::InitFloorplan* getFloorplan();

private:
Tech* tech_;
};

} // namespace ord
62 changes: 62 additions & 0 deletions include/ord/Tech.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2022, The Regents of the University of California
// All rights reserved.
//
// BSD 3-Clause License
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////////

#pragma once

#include <string>

namespace odb {
class dbDatabase;
}

namespace utl {
class Logger;
}

namespace ord {

class Tech
{
public:
Tech();
void readLEF(const std::string& file_name);
void readLiberty(const std::string& file_name);
odb::dbDatabase* getDB();

private:
odb::dbDatabase* db_;
};

} // namespace ord
11 changes: 7 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ set(RESIZER_HOME ${PROJECT_SOURCE_DIR}/src/rsz)
set(PAD_HOME ${OPENROAD_HOME}/src/pad)

set(OPENROAD_SOURCE
Design.cc
Tech.cc
OpenRoad.cc
Main.cc
)
Expand Down Expand Up @@ -324,10 +326,10 @@ if (Python3_FOUND AND BUILD_PYTHON)
target_compile_definitions(openroad PRIVATE ENABLE_PYTHON3)

swig_lib(NAME openroad_swig_py
NAMESPACE ord
LANGUAGE python
I_FILE OpenRoad-py.i
SCRIPTS ${CMAKE_CURRENT_BINARY_DIR}/openroad_swig_py.py
NAMESPACE ord
LANGUAGE python
I_FILE OpenRoad-py.i
SCRIPTS ${CMAKE_CURRENT_BINARY_DIR}/openroad_swig_py.py
)

target_link_libraries(openroad_swig_py
Expand All @@ -339,6 +341,7 @@ if (Python3_FOUND AND BUILD_PYTHON)
target_link_libraries(openroad
openroad_swig_py
odbpy
ifp_py
)
else()
message(STATUS "Python3 disabled")
Expand Down
106 changes: 106 additions & 0 deletions src/Design.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2022, The Regents of the University of California
// All rights reserved.
//
// BSD 3-Clause License
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
///////////////////////////////////////////////////////////////////////////////

#include "odb/db.h"
#include "ord/Design.h"
#include "ifp/InitFloorplan.hh"
#include "ord/OpenRoad.hh"
#include "ord/Tech.h"
#include "utl/Logger.h"

namespace ord {

Design::Design(Tech* tech) : tech_(tech)
{
}

odb::dbBlock* Design::getBlock()
{
auto chip = tech_->getDB()->getChip();
return chip ? chip->getBlock() : nullptr;
}

void Design::readVerilog(const std::string& file_name)
{
auto chip = tech_->getDB()->getChip();
if (chip && chip->getBlock()) {
getLogger()->error(utl::ORD, 36, "A block already exists in the db");
}

auto app = OpenRoad::openRoad();
app->readVerilog(file_name.c_str());
}

void Design::link(const std::string& design_name)
{
auto app = OpenRoad::openRoad();
app->linkDesign(design_name.c_str());
}

void Design::writeDb(const std::string& file_name)
{
auto app = OpenRoad::openRoad();
app->writeDb(file_name.c_str());
}

void Design::writeDef(const std::string& file_name)
{
auto app = OpenRoad::openRoad();
app->writeDef(file_name.c_str(), "5.8");
}

ifp::InitFloorplan* Design::getFloorplan()
{
auto app = OpenRoad::openRoad();
auto block = getBlock();
if (!block) {
getLogger()->error(utl::ORD, 37, "No block loaded.");
}
return new ifp::InitFloorplan(block, app->getLogger(), app->getDbNetwork());
}

utl::Logger* Design::getLogger()
{
auto app = OpenRoad::openRoad();
return app->getLogger();
}

int Design::micronToDBU(double coord)
Comment thread
maliberty marked this conversation as resolved.
{
int dbuPerMicron = getBlock()->getDbUnitsPerMicron();
return round(coord * dbuPerMicron);
}

} // namespace ord
Loading