python: Convert empty BelId to None

Signed-off-by: David Shah <davey1576@gmail.com>
This commit is contained in:
David Shah 2018-07-04 15:26:09 +02:00
parent 11fb625195
commit 726f2020f1
5 changed files with 12 additions and 6 deletions

View File

@ -20,8 +20,8 @@
#ifndef NO_PYTHON
#include "pybindings.h"
#include "nextpnr.h"
#include "pybindings.h"
NEXTPNR_NAMESPACE_BEGIN

View File

@ -21,8 +21,8 @@
#define ARCH_PYBINDINGS_H
#ifndef NO_PYTHON
#include "pybindings.h"
#include "nextpnr.h"
#include "pybindings.h"
NEXTPNR_NAMESPACE_BEGIN

View File

@ -20,9 +20,9 @@
#ifndef NO_PYTHON
#include "pybindings.h"
#include "arch_pybindings.h"
#include "nextpnr.h"
#include "pybindings.h"
NEXTPNR_NAMESPACE_BEGIN

View File

@ -21,8 +21,9 @@
#define ARCH_PYBINDINGS_H
#ifndef NO_PYTHON
#include "pybindings.h"
#include "nextpnr.h"
#include "pybindings.h"
#include "pywrappers.h"
NEXTPNR_NAMESPACE_BEGIN
@ -32,7 +33,12 @@ template <> struct string_converter<BelId>
{
BelId from_str(Context *ctx, std::string name) { return ctx->getBelByName(ctx->id(name)); }
std::string to_str(Context *ctx, BelId id) { return ctx->getBelName(id).str(ctx); }
std::string to_str(Context *ctx, BelId id)
{
if (id == BelId())
throw bad_wrap();
return ctx->getBelName(id).str(ctx);
}
};
template <> struct string_converter<BelType>

View File

@ -20,6 +20,6 @@ for cell, cinfo in sorted(ctx.cells, key=lambda x: x.first):
val = "{}'b{}".format(len(val), val)
print("\t\t{}: {}".format(param, val))
if cinfo.bel.index != -1:
if cinfo.bel is not None:
print("\tBel: {}".format(cinfo.bel))
print()