2018-06-01 21:53:46 +08:00
|
|
|
/*
|
|
|
|
* nextpnr -- Next Generation Place and Route
|
|
|
|
*
|
2018-06-22 22:19:17 +08:00
|
|
|
* Copyright (C) 2018 Clifford Wolf <clifford@symbioticeda.com>
|
2018-06-17 17:49:57 +08:00
|
|
|
* Copyright (C) 2018 David Shah <david@symbioticeda.com>
|
2018-06-01 21:53:46 +08:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2018-06-23 20:32:18 +08:00
|
|
|
#ifndef NO_PYTHON
|
|
|
|
|
2018-07-04 20:13:55 +08:00
|
|
|
#include "arch_pybindings.h"
|
2018-06-12 02:12:57 +08:00
|
|
|
#include "nextpnr.h"
|
2018-07-04 21:26:09 +08:00
|
|
|
#include "pybindings.h"
|
2018-06-01 21:18:18 +08:00
|
|
|
|
2018-06-12 20:24:59 +08:00
|
|
|
NEXTPNR_NAMESPACE_BEGIN
|
|
|
|
|
2018-06-07 19:10:53 +08:00
|
|
|
void arch_wrap_python()
|
|
|
|
{
|
2018-07-02 21:13:09 +08:00
|
|
|
using namespace PythonConversion;
|
2018-06-18 19:35:25 +08:00
|
|
|
class_<ArchArgs>("ArchArgs").def_readwrite("type", &ArchArgs::type);
|
2018-06-01 21:18:18 +08:00
|
|
|
|
2018-06-18 19:35:25 +08:00
|
|
|
enum_<decltype(std::declval<ArchArgs>().type)>("iCE40Type")
|
|
|
|
.value("NONE", ArchArgs::NONE)
|
|
|
|
.value("LP384", ArchArgs::LP384)
|
|
|
|
.value("LP1K", ArchArgs::LP1K)
|
|
|
|
.value("LP8K", ArchArgs::LP8K)
|
|
|
|
.value("HX1K", ArchArgs::HX1K)
|
|
|
|
.value("HX8K", ArchArgs::HX8K)
|
|
|
|
.value("UP5K", ArchArgs::UP5K)
|
2018-06-01 21:18:18 +08:00
|
|
|
.export_values();
|
|
|
|
|
2018-06-10 00:41:38 +08:00
|
|
|
class_<BelId>("BelId").def_readwrite("index", &BelId::index);
|
2018-06-01 21:53:46 +08:00
|
|
|
|
2018-06-10 00:41:38 +08:00
|
|
|
class_<WireId>("WireId").def_readwrite("index", &WireId::index);
|
2018-06-01 21:53:46 +08:00
|
|
|
|
2018-06-10 00:41:38 +08:00
|
|
|
class_<PipId>("PipId").def_readwrite("index", &PipId::index);
|
2018-06-07 20:36:35 +08:00
|
|
|
|
2018-06-23 22:12:52 +08:00
|
|
|
class_<BelPin>("BelPin").def_readwrite("bel", &BelPin::bel).def_readwrite("pin", &BelPin::pin);
|
2018-06-07 20:36:35 +08:00
|
|
|
|
|
|
|
enum_<PortPin>("PortPin")
|
|
|
|
#define X(t) .value("PIN_" #t, PIN_##t)
|
2018-07-02 21:29:58 +08:00
|
|
|
|
2018-06-07 20:36:35 +08:00
|
|
|
#include "portpins.inc"
|
|
|
|
;
|
|
|
|
#undef X
|
|
|
|
|
2018-07-02 21:29:58 +08:00
|
|
|
auto arch_cls = class_<Arch, Arch *, bases<BaseCtx>, boost::noncopyable>("Arch", init<ArchArgs>());
|
2018-07-02 21:59:18 +08:00
|
|
|
auto ctx_cls = class_<Context, Context *, bases<Arch>, boost::noncopyable>("Context", no_init)
|
2018-07-13 21:16:44 +08:00
|
|
|
.def("checksum", &Context::checksum)
|
|
|
|
.def("pack", &Context::pack)
|
|
|
|
.def("place", &Context::place)
|
|
|
|
.def("route", &Context::route);
|
2018-07-02 21:59:18 +08:00
|
|
|
|
2018-07-05 16:13:29 +08:00
|
|
|
fn_wrapper_1a<Context, decltype(&Context::getBelType), &Context::getBelType, conv_to_str<BelType>,
|
2018-07-02 22:20:59 +08:00
|
|
|
conv_from_str<BelId>>::def_wrap(ctx_cls, "getBelType");
|
2018-07-15 01:50:07 +08:00
|
|
|
//fn_wrapper_1a<Context, decltype(&Context::checkBelAvail), &Context::checkBelAvail, pass_through<bool>,
|
|
|
|
// conv_from_str<BelId>>::def_wrap(ctx_cls, "checkBelAvail");
|
2018-07-05 16:13:29 +08:00
|
|
|
fn_wrapper_1a<Context, decltype(&Context::getBelChecksum), &Context::getBelChecksum, pass_through<uint32_t>,
|
2018-07-04 19:35:15 +08:00
|
|
|
conv_from_str<BelId>>::def_wrap(ctx_cls, "getBelChecksum");
|
2018-07-15 01:50:07 +08:00
|
|
|
//fn_wrapper_3a_v<Context, decltype(&Context::bindBel), &Context::bindBel, conv_from_str<BelId>,
|
|
|
|
// conv_from_str<IdString>, pass_through<PlaceStrength>>::def_wrap(ctx_cls, "bindBel");
|
|
|
|
//fn_wrapper_1a_v<Context, decltype(&Context::unbindBel), &Context::unbindBel, conv_from_str<BelId>>::def_wrap(
|
|
|
|
// ctx_cls, "unbindBel");
|
|
|
|
//fn_wrapper_1a<Context, decltype(&Context::getBoundBelCell), &Context::getBoundBelCell, conv_to_str<IdString>,
|
|
|
|
// conv_from_str<BelId>>::def_wrap(ctx_cls, "getBoundBelCell");
|
|
|
|
//fn_wrapper_1a<Context, decltype(&Context::getConflictingBelCell), &Context::getConflictingBelCell,
|
|
|
|
// conv_to_str<IdString>, conv_from_str<BelId>>::def_wrap(ctx_cls, "getConflictingBelCell");
|
2018-07-05 16:13:29 +08:00
|
|
|
fn_wrapper_0a<Context, decltype(&Context::getBels), &Context::getBels, wrap_context<BelRange>>::def_wrap(ctx_cls,
|
2018-07-06 02:59:11 +08:00
|
|
|
"getBels");
|
2018-07-05 16:13:29 +08:00
|
|
|
fn_wrapper_1a<Context, decltype(&Context::getBelsAtSameTile), &Context::getBelsAtSameTile, wrap_context<BelRange>,
|
2018-07-04 19:35:15 +08:00
|
|
|
conv_from_str<BelId>>::def_wrap(ctx_cls, "getBelsAtSameTile");
|
|
|
|
|
2018-07-15 01:50:07 +08:00
|
|
|
//fn_wrapper_2a<Context, decltype(&Context::getWireBelPin), &Context::getWireBelPin, conv_to_str<WireId>,
|
|
|
|
// conv_from_str<BelId>, conv_from_str<PortPin>>::def_wrap(ctx_cls, "getWireBelPin");
|
2018-07-05 16:13:29 +08:00
|
|
|
fn_wrapper_1a<Context, decltype(&Context::getBelPinUphill), &Context::getBelPinUphill, wrap_context<BelPin>,
|
2018-07-04 19:51:46 +08:00
|
|
|
conv_from_str<WireId>>::def_wrap(ctx_cls, "getBelPinUphill");
|
2018-07-05 16:13:29 +08:00
|
|
|
fn_wrapper_1a<Context, decltype(&Context::getBelPinsDownhill), &Context::getBelPinsDownhill,
|
2018-07-04 19:51:46 +08:00
|
|
|
wrap_context<BelPinRange>, conv_from_str<WireId>>::def_wrap(ctx_cls, "getBelPinsDownhill");
|
|
|
|
|
2018-07-05 16:13:29 +08:00
|
|
|
fn_wrapper_1a<Context, decltype(&Context::getWireChecksum), &Context::getWireChecksum, pass_through<uint32_t>,
|
2018-07-04 20:13:55 +08:00
|
|
|
conv_from_str<WireId>>::def_wrap(ctx_cls, "getWireChecksum");
|
2018-07-15 01:50:07 +08:00
|
|
|
//fn_wrapper_3a_v<Context, decltype(&Context::bindWire), &Context::bindWire, conv_from_str<WireId>,
|
|
|
|
// conv_from_str<IdString>, pass_through<PlaceStrength>>::def_wrap(ctx_cls, "bindWire");
|
|
|
|
//fn_wrapper_1a_v<Context, decltype(&Context::unbindWire), &Context::unbindWire, conv_from_str<WireId>>::def_wrap(
|
|
|
|
// ctx_cls, "unbindWire");
|
|
|
|
//fn_wrapper_1a<Context, decltype(&Context::checkWireAvail), &Context::checkWireAvail, pass_through<bool>,
|
|
|
|
// conv_from_str<WireId>>::def_wrap(ctx_cls, "checkWireAvail");
|
|
|
|
//fn_wrapper_1a<Context, decltype(&Context::getBoundWireNet), &Context::getBoundWireNet, conv_to_str<IdString>,
|
|
|
|
// conv_from_str<WireId>>::def_wrap(ctx_cls, "getBoundWireNet");
|
|
|
|
//fn_wrapper_1a<Context, decltype(&Context::getConflictingWireNet), &Context::getConflictingWireNet,
|
|
|
|
// conv_to_str<IdString>, conv_from_str<WireId>>::def_wrap(ctx_cls, "getConflictingWireNet");
|
2018-07-04 19:51:46 +08:00
|
|
|
|
2018-07-05 16:13:29 +08:00
|
|
|
fn_wrapper_0a<Context, decltype(&Context::getWires), &Context::getWires, wrap_context<WireRange>>::def_wrap(
|
2018-07-02 22:20:59 +08:00
|
|
|
ctx_cls, "getWires");
|
2018-07-04 19:51:46 +08:00
|
|
|
|
2018-07-05 16:13:29 +08:00
|
|
|
fn_wrapper_0a<Context, decltype(&Context::getPips), &Context::getPips, wrap_context<AllPipRange>>::def_wrap(
|
2018-07-03 16:55:32 +08:00
|
|
|
ctx_cls, "getPips");
|
2018-07-05 16:13:29 +08:00
|
|
|
fn_wrapper_1a<Context, decltype(&Context::getPipChecksum), &Context::getPipChecksum, pass_through<uint32_t>,
|
2018-07-04 20:13:55 +08:00
|
|
|
conv_from_str<PipId>>::def_wrap(ctx_cls, "getPipChecksum");
|
2018-07-15 01:50:07 +08:00
|
|
|
//fn_wrapper_3a_v<Context, decltype(&Context::bindPip), &Context::bindPip, conv_from_str<PipId>,
|
|
|
|
// conv_from_str<IdString>, pass_through<PlaceStrength>>::def_wrap(ctx_cls, "bindPip");
|
|
|
|
//fn_wrapper_1a_v<Context, decltype(&Context::unbindPip), &Context::unbindPip, conv_from_str<PipId>>::def_wrap(
|
|
|
|
// ctx_cls, "unbindPip");
|
|
|
|
//fn_wrapper_1a<Context, decltype(&Context::checkPipAvail), &Context::checkPipAvail, pass_through<bool>,
|
|
|
|
// conv_from_str<PipId>>::def_wrap(ctx_cls, "checkPipAvail");
|
|
|
|
//fn_wrapper_1a<Context, decltype(&Context::getBoundPipNet), &Context::getBoundPipNet, conv_to_str<IdString>,
|
|
|
|
// conv_from_str<PipId>>::def_wrap(ctx_cls, "getBoundPipNet");
|
|
|
|
//fn_wrapper_1a<Context, decltype(&Context::getConflictingPipNet), &Context::getConflictingPipNet,
|
|
|
|
// conv_to_str<IdString>, conv_from_str<PipId>>::def_wrap(ctx_cls, "getConflictingPipNet");
|
2018-07-03 16:55:32 +08:00
|
|
|
|
2018-07-05 16:13:29 +08:00
|
|
|
fn_wrapper_1a<Context, decltype(&Context::getPipsDownhill), &Context::getPipsDownhill, wrap_context<PipRange>,
|
2018-07-02 22:20:59 +08:00
|
|
|
conv_from_str<WireId>>::def_wrap(ctx_cls, "getPipsDownhill");
|
2018-07-05 16:13:29 +08:00
|
|
|
fn_wrapper_1a<Context, decltype(&Context::getPipsUphill), &Context::getPipsUphill, wrap_context<PipRange>,
|
2018-07-03 16:55:32 +08:00
|
|
|
conv_from_str<WireId>>::def_wrap(ctx_cls, "getPipsUphill");
|
2018-07-05 16:13:29 +08:00
|
|
|
fn_wrapper_1a<Context, decltype(&Context::getWireAliases), &Context::getWireAliases, wrap_context<PipRange>,
|
2018-07-04 20:13:55 +08:00
|
|
|
conv_from_str<WireId>>::def_wrap(ctx_cls, "getWireAliases");
|
2018-07-03 16:55:32 +08:00
|
|
|
|
2018-07-05 16:13:29 +08:00
|
|
|
fn_wrapper_1a<Context, decltype(&Context::getPipSrcWire), &Context::getPipSrcWire, conv_to_str<WireId>,
|
2018-07-03 16:55:32 +08:00
|
|
|
conv_from_str<PipId>>::def_wrap(ctx_cls, "getPipSrcWire");
|
2018-07-05 16:13:29 +08:00
|
|
|
fn_wrapper_1a<Context, decltype(&Context::getPipDstWire), &Context::getPipDstWire, conv_to_str<WireId>,
|
2018-07-03 16:55:32 +08:00
|
|
|
conv_from_str<PipId>>::def_wrap(ctx_cls, "getPipDstWire");
|
2018-07-05 16:13:29 +08:00
|
|
|
fn_wrapper_1a<Context, decltype(&Context::getPipDelay), &Context::getPipDelay, pass_through<DelayInfo>,
|
2018-07-04 20:13:55 +08:00
|
|
|
conv_from_str<PipId>>::def_wrap(ctx_cls, "getPipDelay");
|
2018-07-04 19:51:46 +08:00
|
|
|
|
2018-07-05 16:13:29 +08:00
|
|
|
fn_wrapper_1a<Context, decltype(&Context::getPackagePinBel), &Context::getPackagePinBel, conv_to_str<BelId>,
|
2018-07-04 20:13:55 +08:00
|
|
|
pass_through<std::string>>::def_wrap(ctx_cls, "getPackagePinBel");
|
2018-07-05 16:13:29 +08:00
|
|
|
fn_wrapper_1a<Context, decltype(&Context::getBelPackagePin), &Context::getBelPackagePin, pass_through<std::string>,
|
2018-07-04 20:13:55 +08:00
|
|
|
conv_from_str<BelId>>::def_wrap(ctx_cls, "getBelPackagePin");
|
2018-07-03 16:55:32 +08:00
|
|
|
|
2018-07-05 16:13:29 +08:00
|
|
|
fn_wrapper_0a<Context, decltype(&Context::getChipName), &Context::getChipName, pass_through<std::string>>::def_wrap(
|
2018-07-04 19:35:15 +08:00
|
|
|
ctx_cls, "getChipName");
|
2018-07-05 16:13:29 +08:00
|
|
|
fn_wrapper_0a<Context, decltype(&Context::archId), &Context::archId, conv_to_str<IdString>>::def_wrap(ctx_cls,
|
2018-07-06 02:59:11 +08:00
|
|
|
"archId");
|
2018-07-04 19:35:15 +08:00
|
|
|
|
2018-07-03 16:55:32 +08:00
|
|
|
typedef std::unordered_map<IdString, std::unique_ptr<CellInfo>> CellMap;
|
2018-07-04 19:51:46 +08:00
|
|
|
typedef std::unordered_map<IdString, std::unique_ptr<NetInfo>> NetMap;
|
2018-07-02 22:20:59 +08:00
|
|
|
|
2018-07-05 16:13:29 +08:00
|
|
|
readonly_wrapper<Context, decltype(&Context::cells), &Context::cells, wrap_context<CellMap &>>::def_wrap(ctx_cls,
|
2018-07-06 02:59:11 +08:00
|
|
|
"cells");
|
2018-07-05 16:13:29 +08:00
|
|
|
readonly_wrapper<Context, decltype(&Context::nets), &Context::nets, wrap_context<NetMap &>>::def_wrap(ctx_cls,
|
2018-07-06 02:59:11 +08:00
|
|
|
"nets");
|
2018-07-02 21:59:18 +08:00
|
|
|
WRAP_RANGE(Bel, conv_to_str<BelId>);
|
2018-07-02 22:20:59 +08:00
|
|
|
WRAP_RANGE(Wire, conv_to_str<WireId>);
|
|
|
|
WRAP_RANGE(AllPip, conv_to_str<PipId>);
|
|
|
|
WRAP_RANGE(Pip, conv_to_str<PipId>);
|
|
|
|
|
2018-07-03 16:55:32 +08:00
|
|
|
WRAP_MAP_UPTR(CellMap, "IdCellMap");
|
2018-07-04 19:51:46 +08:00
|
|
|
WRAP_MAP_UPTR(NetMap, "IdNetMap");
|
2018-06-01 21:18:18 +08:00
|
|
|
}
|
2018-06-12 20:24:59 +08:00
|
|
|
|
|
|
|
NEXTPNR_NAMESPACE_END
|
2018-06-23 20:32:18 +08:00
|
|
|
|
2018-06-24 01:51:22 +08:00
|
|
|
#endif // NO_PYTHON
|