-
Notifications
You must be signed in to change notification settings - Fork 894
The new Python API for the ifp module (re #1812) #1849
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
maliberty
merged 23 commits into
The-OpenROAD-Project:master
from
The-OpenROAD-Project-staging:python-api
Sep 20, 2022
Merged
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 6a7fc4a
Python API: remove lib_name from Tech::readLEF
maliberty 149b955
Merge branch 'master' into python-api
maliberty 9b687da
Swig InitFloorplan directly and drop the wrapper Floorplan class.
maliberty 5ed51c2
add __pycache__ to .gitignore
maliberty 915fbb8
ifp: add make_tracks1.py with refactoring
maliberty c4cd9c0
ifp: make imports pep8 compliant
maliberty 2e122f1
Merge branch 'master' into python-api
maliberty 2d0532f
ifp: py test, read single LEF
maliberty eec6255
Merge branch 'master' into python-api
maliberty 137614e
Merge branch 'master' into python-api
maliberty 766adff
get regression scripts to work with python tests
maliberty f9227d9
Merge branch 'master' into python-api
maliberty 8aeba8f
Add suppress_message and get regression working with python
maliberty 313c5f1
get flow regressions working
maliberty 5f0e5f9
Merge branch 'master' into python-api
maliberty a899bd1
Merge branch 'master' into python-api
maliberty 8e59f2d
Merge branch 'master' into python-api
maliberty 5e4a1c6
merge master
maliberty 9000d09
pdn/rsz: update tests for python
maliberty 7de1a46
Finished Python tests for ifp
macd 787ec36
Merge pull request #2 from macd/python-api
maliberty 37a35d0
ifp: minor cleanup
maliberty File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ TAGS | |
| .~lock.*# | ||
| .DS_Store | ||
| Makefile | ||
| __pycache__ | ||
|
|
||
| include/ord/Version.hh | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | ||
| { | ||
| int dbuPerMicron = getBlock()->getDbUnitsPerMicron(); | ||
| return round(coord * dbuPerMicron); | ||
| } | ||
|
|
||
| } // namespace ord | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.