Run "make clangformat".
Signed-off-by: Keith Rothman <537074+litghost@users.noreply.github.com>
This commit is contained in:
parent
8a860857ea
commit
82ab3c1aad
@ -564,13 +564,13 @@ TimingClockingInfo Arch::getPortClockingInfo(const CellInfo *cell, IdString port
|
|||||||
void Arch::read_logical_netlist(const std::string &filename) {}
|
void Arch::read_logical_netlist(const std::string &filename) {}
|
||||||
void Arch::write_physical_netlist(const std::string &filename) const {}
|
void Arch::write_physical_netlist(const std::string &filename) const {}
|
||||||
|
|
||||||
void Arch::parse_xdc(const std::string &filename) {
|
void Arch::parse_xdc(const std::string &filename)
|
||||||
|
{
|
||||||
TclInterp interp(getCtx());
|
TclInterp interp(getCtx());
|
||||||
auto result = Tcl_EvalFile(interp.interp, filename.c_str());
|
auto result = Tcl_EvalFile(interp.interp, filename.c_str());
|
||||||
if(result != TCL_OK) {
|
if (result != TCL_OK) {
|
||||||
log_error("Error in %s:%d => %s\n", filename.c_str(),
|
log_error("Error in %s:%d => %s\n", filename.c_str(), Tcl_GetErrorLine(interp.interp),
|
||||||
Tcl_GetErrorLine(interp.interp),
|
Tcl_GetStringResult(interp.interp));
|
||||||
Tcl_GetStringResult(interp.interp));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ std::unique_ptr<Context> FpgaInterchangeCommandHandler::createContext(std::unord
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (vm.count("xdc")) {
|
if (vm.count("xdc")) {
|
||||||
for(auto & x : vm["xdc"].as<std::vector<std::string>>()) {
|
for (auto &x : vm["xdc"].as<std::vector<std::string>>()) {
|
||||||
ctx->parse_xdc(x);
|
ctx->parse_xdc(x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,20 +19,19 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "xdc.h"
|
#include "xdc.h"
|
||||||
|
#include <string>
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "nextpnr.h"
|
#include "nextpnr.h"
|
||||||
#include <string>
|
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_BEGIN
|
NEXTPNR_NAMESPACE_BEGIN
|
||||||
|
|
||||||
static int port_set_from_any(Tcl_Interp *interp, Tcl_Obj *objPtr) {
|
static int port_set_from_any(Tcl_Interp *interp, Tcl_Obj *objPtr) { return TCL_ERROR; }
|
||||||
return TCL_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void set_tcl_obj_string(Tcl_Obj *objPtr, const std::string &s) {
|
static void set_tcl_obj_string(Tcl_Obj *objPtr, const std::string &s)
|
||||||
|
{
|
||||||
NPNR_ASSERT(objPtr->bytes == nullptr);
|
NPNR_ASSERT(objPtr->bytes == nullptr);
|
||||||
// Need to have space for the end null byte.
|
// Need to have space for the end null byte.
|
||||||
objPtr->bytes = Tcl_Alloc(s.size()+1);
|
objPtr->bytes = Tcl_Alloc(s.size() + 1);
|
||||||
|
|
||||||
// Length is length of string, not including the end null byte.
|
// Length is length of string, not including the end null byte.
|
||||||
objPtr->length = s.size();
|
objPtr->length = s.size();
|
||||||
@ -41,63 +40,55 @@ static void set_tcl_obj_string(Tcl_Obj *objPtr, const std::string &s) {
|
|||||||
objPtr->bytes[objPtr->length] = '\0';
|
objPtr->bytes[objPtr->length] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
static void port_update_string(Tcl_Obj *objPtr) {
|
static void port_update_string(Tcl_Obj *objPtr)
|
||||||
const Context *ctx = static_cast<const Context*>(objPtr->internalRep.twoPtrValue.ptr1);
|
{
|
||||||
PortInfo * port_info = static_cast<PortInfo*>(objPtr->internalRep.twoPtrValue.ptr2);
|
const Context *ctx = static_cast<const Context *>(objPtr->internalRep.twoPtrValue.ptr1);
|
||||||
|
PortInfo *port_info = static_cast<PortInfo *>(objPtr->internalRep.twoPtrValue.ptr2);
|
||||||
|
|
||||||
std::string port_name = port_info->name.str(ctx);
|
std::string port_name = port_info->name.str(ctx);
|
||||||
set_tcl_obj_string(objPtr, port_name);
|
set_tcl_obj_string(objPtr, port_name);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void port_dup(Tcl_Obj *srcPtr, Tcl_Obj *dupPtr) {
|
static void port_dup(Tcl_Obj *srcPtr, Tcl_Obj *dupPtr)
|
||||||
|
{
|
||||||
dupPtr->internalRep.twoPtrValue = srcPtr->internalRep.twoPtrValue;
|
dupPtr->internalRep.twoPtrValue = srcPtr->internalRep.twoPtrValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void port_free(Tcl_Obj *objPtr) {
|
static void port_free(Tcl_Obj *objPtr) {}
|
||||||
}
|
|
||||||
|
|
||||||
|
static void Tcl_SetStringResult(Tcl_Interp *interp, const std::string &s)
|
||||||
static void Tcl_SetStringResult(Tcl_Interp *interp, const std::string &s) {
|
{
|
||||||
char * copy = Tcl_Alloc(s.size()+1);
|
char *copy = Tcl_Alloc(s.size() + 1);
|
||||||
std::copy(s.begin(), s.end(), copy);
|
std::copy(s.begin(), s.end(), copy);
|
||||||
copy[s.size()] = '\0';
|
copy[s.size()] = '\0';
|
||||||
Tcl_SetResult(interp, copy, TCL_DYNAMIC);
|
Tcl_SetResult(interp, copy, TCL_DYNAMIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Tcl_ObjType port_object = {
|
static Tcl_ObjType port_object = {
|
||||||
"port",
|
"port", port_free, port_dup, port_update_string, port_set_from_any,
|
||||||
port_free,
|
|
||||||
port_dup,
|
|
||||||
port_update_string,
|
|
||||||
port_set_from_any,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static int get_ports(
|
static int get_ports(ClientData data, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
|
||||||
ClientData data,
|
{
|
||||||
Tcl_Interp *interp,
|
const Context *ctx = static_cast<const Context *>(data);
|
||||||
int objc,
|
if (objc == 1) {
|
||||||
Tcl_Obj *CONST objv[]) {
|
|
||||||
const Context *ctx = static_cast<const Context*>(data);
|
|
||||||
if(objc == 1) {
|
|
||||||
// Return list of all ports.
|
// Return list of all ports.
|
||||||
Tcl_SetStringResult(interp, "Unimplemented");
|
Tcl_SetStringResult(interp, "Unimplemented");
|
||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
} else if(objc == 2) {
|
} else if (objc == 2) {
|
||||||
const char * arg0 = Tcl_GetString(objv[1]);
|
const char *arg0 = Tcl_GetString(objv[1]);
|
||||||
IdString port_name = ctx->id(arg0);
|
IdString port_name = ctx->id(arg0);
|
||||||
|
|
||||||
auto iter = ctx->ports.find(port_name);
|
auto iter = ctx->ports.find(port_name);
|
||||||
if(iter == ctx->ports.end()) {
|
if (iter == ctx->ports.end()) {
|
||||||
Tcl_SetStringResult(interp, "Could not find port " + port_name.str(ctx));
|
Tcl_SetStringResult(interp, "Could not find port " + port_name.str(ctx));
|
||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
Tcl_Obj * result = Tcl_NewObj();
|
Tcl_Obj *result = Tcl_NewObj();
|
||||||
result->typePtr = &port_object;
|
result->typePtr = &port_object;
|
||||||
result->internalRep.twoPtrValue.ptr1 = (void*)(ctx);
|
result->internalRep.twoPtrValue.ptr1 = (void *)(ctx);
|
||||||
result->internalRep.twoPtrValue.ptr2 = (void*)(&iter->second);
|
result->internalRep.twoPtrValue.ptr2 = (void *)(&iter->second);
|
||||||
|
|
||||||
result->bytes = nullptr;
|
result->bytes = nullptr;
|
||||||
port_update_string(result);
|
port_update_string(result);
|
||||||
@ -109,13 +100,10 @@ static int get_ports(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int set_property(
|
static int set_property(ClientData data, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
|
||||||
ClientData data,
|
{
|
||||||
Tcl_Interp *interp,
|
|
||||||
int objc,
|
|
||||||
Tcl_Obj *CONST objv[]) {
|
|
||||||
// set_property <property> <value> <object>
|
// set_property <property> <value> <object>
|
||||||
if(objc != 4) {
|
if (objc != 4) {
|
||||||
Tcl_SetStringResult(interp, "Only simple 'set_property <property> <value> <object>' is supported");
|
Tcl_SetStringResult(interp, "Only simple 'set_property <property> <value> <object>' is supported");
|
||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
}
|
}
|
||||||
@ -124,43 +112,41 @@ static int set_property(
|
|||||||
const char *value = Tcl_GetString(objv[2]);
|
const char *value = Tcl_GetString(objv[2]);
|
||||||
const Tcl_Obj *object = objv[3];
|
const Tcl_Obj *object = objv[3];
|
||||||
|
|
||||||
if(object->typePtr != &port_object) {
|
if (object->typePtr != &port_object) {
|
||||||
Tcl_SetStringResult(interp, "Only port objects are handled right now!");
|
Tcl_SetStringResult(interp, "Only port objects are handled right now!");
|
||||||
return TCL_ERROR;
|
return TCL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Context *ctx = static_cast<const Context*>(object->internalRep.twoPtrValue.ptr1);
|
const Context *ctx = static_cast<const Context *>(object->internalRep.twoPtrValue.ptr1);
|
||||||
PortInfo * port_info = static_cast<PortInfo*>(object->internalRep.twoPtrValue.ptr2);
|
PortInfo *port_info = static_cast<PortInfo *>(object->internalRep.twoPtrValue.ptr2);
|
||||||
NPNR_ASSERT(port_info->net != nullptr);
|
NPNR_ASSERT(port_info->net != nullptr);
|
||||||
CellInfo * cell = ctx->port_cells.at(port_info->name);
|
CellInfo *cell = ctx->port_cells.at(port_info->name);
|
||||||
|
|
||||||
cell->attrs[ctx->id(property)] = Property(value);
|
cell->attrs[ctx->id(property)] = Property(value);
|
||||||
|
|
||||||
return TCL_OK;
|
return TCL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
TclInterp::TclInterp(Context *ctx) {
|
TclInterp::TclInterp(Context *ctx)
|
||||||
|
{
|
||||||
interp = Tcl_CreateInterp();
|
interp = Tcl_CreateInterp();
|
||||||
NPNR_ASSERT(Tcl_Init(interp) == TCL_OK);
|
NPNR_ASSERT(Tcl_Init(interp) == TCL_OK);
|
||||||
|
|
||||||
Tcl_RegisterObjType(&port_object);
|
Tcl_RegisterObjType(&port_object);
|
||||||
|
|
||||||
NPNR_ASSERT(Tcl_Eval(interp, "rename unknown _original_unknown") == TCL_OK);
|
NPNR_ASSERT(Tcl_Eval(interp, "rename unknown _original_unknown") == TCL_OK);
|
||||||
NPNR_ASSERT(Tcl_Eval(interp,
|
NPNR_ASSERT(Tcl_Eval(interp, "proc unknown args {\n"
|
||||||
"proc unknown args {\n"
|
" set result [scan [lindex $args 0] \"%d\" value]\n"
|
||||||
" set result [scan [lindex $args 0] \"%d\" value]\n"
|
" if { $result == 1 && [llength $args] == 1 } {\n"
|
||||||
" if { $result == 1 && [llength $args] == 1 } {\n"
|
" return \\[$value\\]\n"
|
||||||
" return \\[$value\\]\n"
|
" } else {\n"
|
||||||
" } else {\n"
|
" uplevel 1 [list _original_unknown {*}$args]\n"
|
||||||
" uplevel 1 [list _original_unknown {*}$args]\n"
|
" }\n"
|
||||||
" }\n"
|
"}") == TCL_OK);
|
||||||
"}") == TCL_OK);
|
|
||||||
Tcl_CreateObjCommand(interp, "get_ports", get_ports, ctx, nullptr);
|
Tcl_CreateObjCommand(interp, "get_ports", get_ports, ctx, nullptr);
|
||||||
Tcl_CreateObjCommand(interp, "set_property", set_property, ctx, nullptr);
|
Tcl_CreateObjCommand(interp, "set_property", set_property, ctx, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
TclInterp::~TclInterp() {
|
TclInterp::~TclInterp() { Tcl_DeleteInterp(interp); }
|
||||||
Tcl_DeleteInterp(interp);
|
|
||||||
}
|
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_END
|
NEXTPNR_NAMESPACE_END
|
||||||
|
@ -17,12 +17,13 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "nextpnr.h"
|
|
||||||
#include <tcl.h>
|
#include <tcl.h>
|
||||||
|
#include "nextpnr.h"
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_BEGIN
|
NEXTPNR_NAMESPACE_BEGIN
|
||||||
|
|
||||||
struct TclInterp {
|
struct TclInterp
|
||||||
|
{
|
||||||
TclInterp(Context *ctx);
|
TclInterp(Context *ctx);
|
||||||
~TclInterp();
|
~TclInterp();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user