ice40: Improve error reporting for invalid tristate usage
Signed-off-by: David Shah <davey1576@gmail.com>
This commit is contained in:
parent
ecc2c486d9
commit
a8071a418d
@ -37,7 +37,7 @@ CellInfo *create_ice_cell(Context *ctx, IdString type, std::string name)
|
||||
CellInfo *new_cell = new CellInfo();
|
||||
if (name.empty()) {
|
||||
new_cell->name = IdString(ctx, "$nextpnr_" + type.str() + "_" +
|
||||
std::to_string(auto_idx++));
|
||||
std::to_string(auto_idx++));
|
||||
} else {
|
||||
new_cell->name = ctx->id(name);
|
||||
}
|
||||
@ -200,8 +200,8 @@ void nxio_to_sb(Context *ctx, CellInfo *nxio, CellInfo *sbio)
|
||||
}
|
||||
NetInfo *donet = sbio->ports.at(ctx->id("D_OUT_0")).net;
|
||||
CellInfo *tbuf =
|
||||
net_driven_by(ctx, donet, []
|
||||
(const Context *ctx, const CellInfo *cell) {
|
||||
net_driven_by(ctx, donet,
|
||||
[](const Context *ctx, const CellInfo *cell) {
|
||||
return cell->type == ctx->id("$_TBUF_");
|
||||
},
|
||||
"Y");
|
||||
@ -210,6 +210,10 @@ void nxio_to_sb(Context *ctx, CellInfo *nxio, CellInfo *sbio)
|
||||
replace_port(tbuf, "A", sbio, "D_OUT_0");
|
||||
replace_port(tbuf, "E", sbio, "OUTPUT_ENABLE");
|
||||
ctx->nets.erase(donet->name);
|
||||
if (!donet->users.empty())
|
||||
log_error("unsupported tristate IO pattern for IO buffer '%s', "
|
||||
"instantiate SB_IO manually to ensure correct behaviour\n",
|
||||
nxio->name.c_str(ctx));
|
||||
ctx->cells.erase(tbuf->name);
|
||||
}
|
||||
}
|
||||
@ -251,7 +255,8 @@ bool is_enable_port(const Context *ctx, const PortRef &port)
|
||||
|
||||
bool is_global_net(const Context *ctx, const NetInfo *net)
|
||||
{
|
||||
return bool(net_driven_by(ctx, net, is_gbuf, ctx->id("GLOBAL_BUFFER_OUTPUT")));
|
||||
return bool(
|
||||
net_driven_by(ctx, net, is_gbuf, ctx->id("GLOBAL_BUFFER_OUTPUT")));
|
||||
}
|
||||
|
||||
NEXTPNR_NAMESPACE_END
|
||||
|
@ -27,8 +27,7 @@ NEXTPNR_NAMESPACE_BEGIN
|
||||
|
||||
// Create a standard iCE40 cell and return it
|
||||
// Name will be automatically assigned if not specified
|
||||
CellInfo *create_ice_cell(Context *ctx, IdString type,
|
||||
std::string name = "");
|
||||
CellInfo *create_ice_cell(Context *ctx, IdString type, std::string name = "");
|
||||
|
||||
// Return true if a cell is a LUT
|
||||
inline bool is_lut(const Context *ctx, const CellInfo *cell)
|
||||
|
@ -39,8 +39,8 @@ static void pack_lut_lutffs(Context *ctx)
|
||||
log_info("cell '%s' is of type '%s'\n", ci->name.c_str(ctx),
|
||||
ci->type.c_str(ctx));
|
||||
if (is_lut(ctx, ci)) {
|
||||
CellInfo *packed =
|
||||
create_ice_cell(ctx, "ICESTORM_LC", ci->name.str(ctx) + "_LC");
|
||||
CellInfo *packed = create_ice_cell(ctx, "ICESTORM_LC",
|
||||
ci->name.str(ctx) + "_LC");
|
||||
std::copy(ci->attrs.begin(), ci->attrs.end(),
|
||||
std::inserter(packed->attrs, packed->attrs.begin()));
|
||||
packed_cells.insert(ci->name);
|
||||
@ -168,7 +168,8 @@ static void set_net_constant(const Context *ctx, NetInfo *orig,
|
||||
for (auto user : orig->users) {
|
||||
if (user.cell != nullptr) {
|
||||
CellInfo *uc = user.cell;
|
||||
log_info("%s user %s\n", orig->name.c_str(ctx), uc->name.c_str(ctx));
|
||||
log_info("%s user %s\n", orig->name.c_str(ctx),
|
||||
uc->name.c_str(ctx));
|
||||
if (is_lut(ctx, uc) && (user.port.str(ctx).at(0) == 'I') &&
|
||||
!constval) {
|
||||
uc->ports[user.port].net = nullptr;
|
||||
@ -206,7 +207,8 @@ static void pack_constants(Context *ctx)
|
||||
|
||||
for (auto net : ctx->nets) {
|
||||
NetInfo *ni = net.second;
|
||||
if (ni->driver.cell != nullptr && ni->driver.cell->type == ctx->id("GND")) {
|
||||
if (ni->driver.cell != nullptr &&
|
||||
ni->driver.cell->type == ctx->id("GND")) {
|
||||
set_net_constant(ctx, ni, gnd_net, false);
|
||||
gnd_used = true;
|
||||
dead_nets.push_back(net.first);
|
||||
@ -234,7 +236,8 @@ static void pack_constants(Context *ctx)
|
||||
|
||||
static bool is_nextpnr_iob(Context *ctx, CellInfo *cell)
|
||||
{
|
||||
return cell->type == ctx->id("$nextpnr_ibuf") || cell->type == ctx->id("$nextpnr_obuf") ||
|
||||
return cell->type == ctx->id("$nextpnr_ibuf") ||
|
||||
cell->type == ctx->id("$nextpnr_obuf") ||
|
||||
cell->type == ctx->id("$nextpnr_iobuf");
|
||||
}
|
||||
|
||||
@ -250,7 +253,8 @@ static void pack_io(Context *ctx)
|
||||
CellInfo *ci = cell.second;
|
||||
if (is_nextpnr_iob(ctx, ci)) {
|
||||
CellInfo *sb = nullptr;
|
||||
if (ci->type == ctx->id("$nextpnr_ibuf") || ci->type == ctx->id("$nextpnr_iobuf")) {
|
||||
if (ci->type == ctx->id("$nextpnr_ibuf") ||
|
||||
ci->type == ctx->id("$nextpnr_iobuf")) {
|
||||
sb = net_only_drives(ctx, ci->ports.at("O").net, is_sb_io,
|
||||
"PACKAGE_PIN", true, ci);
|
||||
|
||||
@ -262,8 +266,8 @@ static void pack_io(Context *ctx)
|
||||
// Trivial case, SB_IO used. Just destroy the net and the
|
||||
// iobuf
|
||||
log_info("%s feeds SB_IO %s, removing %s %s.\n",
|
||||
ci->name.c_str(ctx), sb->name.c_str(ctx), ci->type.c_str(ctx),
|
||||
ci->name.c_str(ctx));
|
||||
ci->name.c_str(ctx), sb->name.c_str(ctx),
|
||||
ci->type.c_str(ctx), ci->name.c_str(ctx));
|
||||
NetInfo *net = sb->ports.at("PACKAGE_PIN").net;
|
||||
if (net != nullptr) {
|
||||
ctx->nets.erase(net->name);
|
||||
@ -271,7 +275,8 @@ static void pack_io(Context *ctx)
|
||||
}
|
||||
} else {
|
||||
// Create a SB_IO buffer
|
||||
sb = create_ice_cell(ctx, "SB_IO");
|
||||
sb = create_ice_cell(ctx, "SB_IO",
|
||||
ci->name.str(ctx) + "$sb_io");
|
||||
nxio_to_sb(ctx, ci, sb);
|
||||
new_cells.push_back(sb);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user