From f2a240550e14184041d3f0cfd7526386d985f27c Mon Sep 17 00:00:00 2001 From: "William D. Jones" Date: Mon, 23 Nov 2020 22:17:47 -0500 Subject: machxo2: Always remove nextpnr_iobufs for now- assume manually instantiated primitives. --- machxo2/main.cc | 2 +- machxo2/pack.cc | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/machxo2/main.cc b/machxo2/main.cc index 84b99edc..92a60d38 100644 --- a/machxo2/main.cc +++ b/machxo2/main.cc @@ -67,7 +67,7 @@ po::options_description MachXO2CommandHandler::getArchOptions() specific.add_options()("lpf", po::value>(), "LPF pin constraint file(s)"); - specific.add_options()("no-iobs", "disable automatic IO buffer insertion"); + specific.add_options()("no-iobs", "disable automatic IO buffer insertion (unimplemented- always enabled)"); return specific; } diff --git a/machxo2/pack.cc b/machxo2/pack.cc index 6af7a58b..c418ceda 100644 --- a/machxo2/pack.cc +++ b/machxo2/pack.cc @@ -95,6 +95,36 @@ 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") || + cell->type == ctx->id("$nextpnr_iobuf"); +} + +static bool is_facade_iob(const Context *ctx, const CellInfo *cell) { return cell->type == ctx->id("FACADE_IO"); } + +// Pack IO buffers- Right now, all this does is remove $nextpnr_[io]buf cells. +// User is expected to manually instantiate FACADE_IO with BEL/IO_TYPE +// attributes. +static void pack_io(Context *ctx) +{ + std::unordered_set packed_cells; + + log_info("Packing IOs..\n"); + + for (auto cell : sorted(ctx->cells)) { + CellInfo *ci = cell.second; + if (is_nextpnr_iob(ctx, ci)) { + for (auto &p : ci->ports) + disconnect_port(ctx, ci, p.first); + packed_cells.insert(ci->name); + } + } + + for (auto pcell : packed_cells) { + ctx->cells.erase(pcell); + } +} // Main pack function bool Arch::pack() @@ -104,6 +134,7 @@ bool Arch::pack() try { log_break(); pack_constants(ctx); + pack_io(ctx); ctx->settings[ctx->id("pack")] = 1; ctx->assignArchInfo(); log_info("Checksum: 0x%08x\n", ctx->checksum()); -- cgit v1.2.3