92 lines
2.3 KiB
C++
92 lines
2.3 KiB
C++
/*
|
|
* nextpnr -- Next Generation Place and Route
|
|
*
|
|
* Copyright (C) 2018 David Shah <david@symbioticeda.com>
|
|
*
|
|
* 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 "log.h"
|
|
|
|
NEXTPNR_NAMESPACE_BEGIN
|
|
|
|
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");
|
|
}
|
|
|
|
class LeuctraPacker
|
|
{
|
|
public:
|
|
LeuctraPacker(Context *ctx) : ctx(ctx){};
|
|
|
|
private:
|
|
// Process the contents of packed_cells and new_cells
|
|
void flush_cells()
|
|
{
|
|
for (auto pcell : packed_cells) {
|
|
ctx->cells.erase(pcell);
|
|
}
|
|
for (auto &ncell : new_cells) {
|
|
ctx->cells[ncell->name] = std::move(ncell);
|
|
}
|
|
packed_cells.clear();
|
|
new_cells.clear();
|
|
}
|
|
|
|
// Remove nextpnr iob cells, insert Xilinx primitives instead.
|
|
void pack_iob()
|
|
{
|
|
log_info("Packing IOBs..\n");
|
|
|
|
// XXX
|
|
|
|
flush_cells();
|
|
}
|
|
|
|
public:
|
|
void pack()
|
|
{
|
|
pack_iob();
|
|
}
|
|
|
|
private:
|
|
Context *ctx;
|
|
|
|
std::unordered_set<IdString> packed_cells;
|
|
std::vector<std::unique_ptr<CellInfo>> new_cells;
|
|
};
|
|
|
|
// Main pack function
|
|
bool Arch::pack()
|
|
{
|
|
Context *ctx = getCtx();
|
|
try {
|
|
log_break();
|
|
LeuctraPacker(ctx).pack();
|
|
log_info("Checksum: 0x%08x\n", ctx->checksum());
|
|
// XXX
|
|
//assignArchInfo();
|
|
return true;
|
|
} catch (log_execution_error_exception) {
|
|
// XXX
|
|
//assignArchInfo();
|
|
return false;
|
|
}
|
|
}
|
|
|
|
NEXTPNR_NAMESPACE_END
|