forked from SymbiFlow/vtr-verilog-to-routing
-
Notifications
You must be signed in to change notification settings - Fork 0
XDC physical constraints with TCL interpreter. #15
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
Open
kboronski-ant
wants to merge
20
commits into
acom/fpga-interchange-rr-graph+constants
Choose a base branch
from
kbor/xdc-interchange
base: acom/fpga-interchange-rr-graph+constants
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
604a105
Added xdc_constraints.cpp
kboronski-ant 5a89005
WIP XDC constraints
kboronski-ant 2242ce9
XDC: improve TCL handling, associate physical pin names with grid loc…
kboronski-ant 885153d
Refactor XDC handling, add comments, separate wrappers for tcl stuff …
kboronski-ant 15a9d7e
USe atom block names when getting ports
kboronski-ant 2f1d44e
WIP set_propertty IOSTANDARD, a bit of refactoring
kboronski-ant f28745b
Further cleanup/refactor
kboronski-ant 09a9c6a
Fixed set_property IOSTANDARD no-return
kboronski-ant 61ed2c2
Moved TCL C++ abstraction into libtclcpp
kboronski-ant e9013da
Use vpr_throw for reporting XDC errors
kboronski-ant 0379c1d
Remove _argv0 global
kboronski-ant bb44f69
libtclcpp: TCL List wrapper. get_ports: return list of ports. set_pro…
kboronski-ant eb5d914
Indented switch/case
kboronski-ant d2f0b92
make format, added trait requirements for some functions in libtclcpp
kboronski-ant 7e3299a
Added tk-dev dependency
kboronski-ant 38ce761
throwaway: enable vtr_reg_strong test run
kboronski-ant 6662ede
Added tk-dev to install_apt_packages.sh
kboronski-ant 81519eb
Allow parsing multiple XDC files
kboronski-ant f3bf2be
libtclcpp: Added TclDynList
kboronski-ant 9bee76d
Cleanup
kboronski-ant File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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
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
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
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
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,21 @@ | ||
cmake_minimum_required(VERSION 3.9) | ||
|
||
project("libtclcpp") | ||
|
||
file(GLOB_RECURSE LIB_SOURCES src/*.cpp) | ||
file(GLOB_RECURSE LIB_HEADERS src/*.h) | ||
files_to_dirs(LIB_HEADERS LIB_INCLUDE_DIRS) | ||
|
||
add_library(libtclcpp STATIC | ||
${LIB_HEADERS} | ||
${LIB_SOURCES} | ||
) | ||
|
||
target_include_directories(libtclcpp PUBLIC ${LIB_INCLUDE_DIRS}) | ||
|
||
set_target_properties(libtclcpp PROPERTIES PREFIX "") | ||
|
||
find_package(TCL REQUIRED) | ||
target_link_libraries(libtclcpp tcl) | ||
|
||
install(TARGETS libtclcpp DESTINATION bin) |
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,157 @@ | ||
#include "tclcpp.h" | ||
|
||
#include <functional> | ||
#include <vector> | ||
#include <list> | ||
#include <tcl/tcl.h> | ||
#include <cstring> | ||
#include <sstream> | ||
|
||
/* TCL ERRORS */ | ||
#define OV_TOSTRING(c, e) \ | ||
c::operator std::string() const { return (e); } | ||
|
||
OV_TOSTRING(TCL_eException, "Unknown error") | ||
|
||
TCL_eCustomException::TCL_eCustomException(std::string&& message_) | ||
: message(std::move(message_)) {} | ||
TCL_eCustomException::operator std::string() const { return (this->message); } | ||
|
||
TCL_eFailedToInitTcl::TCL_eFailedToInitTcl(int error_code_) | ||
: error_code(error_code_) {} | ||
OV_TOSTRING(TCL_eFailedToInitTcl, "Can't initialize TCL (code " + std::to_string(error_code) + ")") | ||
|
||
TCL_eErroneousTCL::TCL_eErroneousTCL( | ||
std::string&& filename_, | ||
int line_, | ||
int column_, | ||
std::string&& message_) | ||
: filename(std::move(filename_)) | ||
, line(line_) | ||
, column(column_) | ||
, message(message_) {} | ||
OV_TOSTRING(TCL_eErroneousTCL, this->filename + ":" + std::to_string(this->line) + "," + std::to_string(this->column) + ": " + this->message) | ||
|
||
void Tcl_SetStringResult(Tcl_Interp* interp, const std::string& s) { | ||
char* copy = Tcl_Alloc(s.length() + 1); | ||
std::strcpy(copy, s.c_str()); | ||
Tcl_SetResult(interp, copy, TCL_DYNAMIC); | ||
} | ||
|
||
TclClient::TclClient() | ||
: cmd_status(e_TclCommandStatus::TCL_CMD_SUCCESS) | ||
, string("No errors") {} | ||
|
||
void tcl_obj_dup(Tcl_Obj* src, Tcl_Obj* dst) { | ||
dst->internalRep.twoPtrValue = src->internalRep.twoPtrValue; | ||
dst->typePtr = src->typePtr; | ||
dst->bytes = nullptr; | ||
dst->length = 0; | ||
} | ||
|
||
void tcl_set_obj_string(Tcl_Obj* obj, const std::string& str) { | ||
if (obj->bytes != nullptr) | ||
Tcl_Free(obj->bytes); | ||
obj->bytes = Tcl_Alloc(str.length() + 1); | ||
obj->length = str.length(); | ||
std::strcpy(obj->bytes, str.c_str()); | ||
} | ||
|
||
int tcl_set_from_none(Tcl_Interp* tcl_interp, Tcl_Obj* obj) { | ||
(void)(obj); /* Surpress "unused parameter" macro */ | ||
/* TODO: Better error message */ | ||
Tcl_SetStringResult(tcl_interp, "Attempted an invalid conversion."); | ||
return TCL_ERROR; | ||
} | ||
|
||
TclCtx::TclCtx() { | ||
this->_tcl_interp = Tcl_CreateInterp(); | ||
#ifdef DEBUG | ||
this->_init = false; | ||
#endif | ||
} | ||
|
||
TclCtx::~TclCtx() { | ||
Tcl_DeleteInterp(this->_tcl_interp); | ||
} | ||
|
||
void TclCtx::_init() { | ||
int error; | ||
|
||
if ((error = Tcl_Init(this->_tcl_interp)) != TCL_OK) | ||
throw TCL_eFailedToInitTcl(error); | ||
|
||
#ifdef DEBUG | ||
this->_init = true; | ||
#endif | ||
} | ||
|
||
void TclCtx::read_tcl(std::istream& tcl_stream) { | ||
int error; | ||
|
||
this->_debug_init(); | ||
|
||
std::ostringstream os; | ||
tcl_stream >> os.rdbuf(); | ||
std::string tcl = os.str(); | ||
|
||
error = Tcl_Eval(this->_tcl_interp, tcl.c_str()); | ||
/* TODO: More precise error */ | ||
if (error != TCL_OK) { | ||
int error_line = Tcl_GetErrorLine(this->_tcl_interp); | ||
const char* msg = Tcl_GetStringResult(this->_tcl_interp); | ||
throw TCL_eErroneousTCL("<unknown file>", error_line, 0, std::string(msg)); | ||
} | ||
} | ||
|
||
int TclCtx::_tcl_do_method( | ||
ClientData cd, | ||
Tcl_Interp* tcl_interp, | ||
int objc, | ||
Tcl_Obj* const objvp[]) { | ||
TclMethodDispatchBase* d = static_cast<TclMethodDispatchBase*>(cd); | ||
d->do_method(objc, objvp); | ||
|
||
switch (d->client.cmd_status) { | ||
case e_TclCommandStatus::TCL_CMD_FAIL: | ||
Tcl_SetStringResult(tcl_interp, d->client.string); | ||
return TCL_ERROR; | ||
case e_TclCommandStatus::TCL_CMD_SUCCESS_STRING: | ||
Tcl_SetStringResult(tcl_interp, d->client.string); | ||
return TCL_OK; | ||
case e_TclCommandStatus::TCL_CMD_SUCCESS_OBJECT: | ||
case e_TclCommandStatus::TCL_CMD_SUCCESS_LIST: | ||
Tcl_SetObjResult(tcl_interp, d->client.object); | ||
default: | ||
break; | ||
} | ||
return TCL_OK; | ||
} | ||
|
||
TclDynList::TclDynList(Tcl_Interp* interp, Tcl_Obj* obj) | ||
: _interp(interp) { | ||
const Tcl_ObjType* obj_type = obj->typePtr; | ||
if (obj_type == nullptr) | ||
return; | ||
|
||
if (obj_type == nullptr || std::strcmp(obj_type->name, "list")) | ||
this->_obj = Tcl_NewListObj(1, &obj); | ||
else | ||
this->_obj = obj; | ||
} | ||
|
||
TclDynList tcl_obj_getdynlist (TclClient* client, Tcl_Obj* obj) { | ||
return TclDynList(client->_interp, obj); | ||
} | ||
|
||
Tcl_Obj* TclDynList::operator[](size_t idx) { | ||
int count; | ||
Tcl_Obj* objp; | ||
|
||
Tcl_ListObjLength(this->_interp, this->_obj, &count); | ||
if (idx >= size_t(count)) | ||
return nullptr; | ||
Tcl_ListObjIndex(this->_interp, this->_obj, idx, &objp); | ||
|
||
return objp; | ||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably a typo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo still needs fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not my typo, will fix in another commit.