Refactor XDC parser into a little class for testing purposes.
Signed-off-by: Keith Rothman <537074+litghost@users.noreply.github.com>
This commit is contained in:
parent
d987bd2997
commit
c96d0f225c
@ -33,6 +33,7 @@
|
|||||||
#include "router2.h"
|
#include "router2.h"
|
||||||
#include "timing.h"
|
#include "timing.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "xdc.h"
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_BEGIN
|
NEXTPNR_NAMESPACE_BEGIN
|
||||||
|
|
||||||
@ -563,6 +564,16 @@ 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) {
|
||||||
|
TclInterp interp(getCtx());
|
||||||
|
auto result = Tcl_EvalFile(interp.interp, filename.c_str());
|
||||||
|
if(result != TCL_OK) {
|
||||||
|
log_error("Error in %s:%d => %s\n", filename.c_str(),
|
||||||
|
Tcl_GetErrorLine(interp.interp),
|
||||||
|
Tcl_GetStringResult(interp.interp));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
#ifdef WITH_HEAP
|
#ifdef WITH_HEAP
|
||||||
|
@ -18,9 +18,9 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "xdc.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "nextpnr.h"
|
#include "nextpnr.h"
|
||||||
#include <tcl.h>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_BEGIN
|
NEXTPNR_NAMESPACE_BEGIN
|
||||||
@ -139,8 +139,8 @@ static int set_property(
|
|||||||
return TCL_OK;
|
return TCL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Arch::parse_xdc(const std::string &filename) {
|
TclInterp::TclInterp(Context *ctx) {
|
||||||
Tcl_Interp *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);
|
||||||
@ -149,23 +149,18 @@ void Arch::parse_xdc(const std::string &filename) {
|
|||||||
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, getCtx(), nullptr);
|
Tcl_CreateObjCommand(interp, "get_ports", get_ports, ctx, nullptr);
|
||||||
Tcl_CreateObjCommand(interp, "set_property", set_property, getCtx(), nullptr);
|
Tcl_CreateObjCommand(interp, "set_property", set_property, ctx, nullptr);
|
||||||
auto result = Tcl_EvalFile(interp, filename.c_str());
|
|
||||||
if(result != TCL_OK) {
|
|
||||||
log_error("Error in %s:%d => %s\n", filename.c_str(), Tcl_GetErrorLine(interp), Tcl_GetStringResult(interp));
|
|
||||||
}
|
|
||||||
Tcl_DeleteInterp(interp);
|
|
||||||
Tcl_Finalize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TclInterp::~TclInterp() {
|
||||||
|
Tcl_DeleteInterp(interp);
|
||||||
|
}
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_END
|
NEXTPNR_NAMESPACE_END
|
||||||
|
|
||||||
|
|
||||||
|
32
fpga_interchange/xdc.h
Normal file
32
fpga_interchange/xdc.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* nextpnr -- Next Generation Place and Route
|
||||||
|
*
|
||||||
|
* Copyright (C) 2021 Symbiflow Authors
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "nextpnr.h"
|
||||||
|
#include <tcl.h>
|
||||||
|
|
||||||
|
NEXTPNR_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
struct TclInterp {
|
||||||
|
TclInterp(Context *ctx);
|
||||||
|
~TclInterp();
|
||||||
|
|
||||||
|
Tcl_Interp *interp;
|
||||||
|
};
|
||||||
|
|
||||||
|
NEXTPNR_NAMESPACE_END
|
Loading…
Reference in New Issue
Block a user