ecp5: Refactor skeleton of packer

Signed-off-by: David Shah <davey1576@gmail.com>
This commit is contained in:
David Shah 2018-07-17 13:19:27 +02:00
parent 0e31a8e266
commit ac4cdd6604
2 changed files with 55 additions and 41 deletions

View File

@ -38,6 +38,8 @@ inline bool is_carry(const BaseCtx *ctx, const CellInfo *cell) { return cell->ty
inline bool is_lc(const BaseCtx *ctx, const CellInfo *cell) { return cell->type == ctx->id("TRELLIS_LC"); }
inline bool is_trellis_io(const BaseCtx *ctx, const CellInfo *cell) { return cell->type == ctx->id("TRELLIS_IO"); }
inline bool is_dpram(const BaseCtx *ctx, const CellInfo *cell) { return cell->type == ctx->id("TRELLIS_DPR16X4"); }
inline bool is_pfumx(const BaseCtx *ctx, const CellInfo *cell) { return cell->type == ctx->id("PFUMX"); }

View File

@ -20,6 +20,7 @@
#include <algorithm>
#include <iterator>
#include <unordered_set>
#include "cells.h"
#include "design_utils.h"
#include "log.h"
#include "util.h"
@ -32,8 +33,12 @@ static bool is_nextpnr_iob(Context *ctx, CellInfo *cell)
cell->type == ctx->id("$nextpnr_iobuf");
}
static bool is_trellis_io(const Context *ctx, const CellInfo *cell) { return cell->type == ctx->id("TRELLIS_IO"); }
class Ecp5Packer
{
public:
Ecp5Packer(Context *ctx) : ctx(ctx){};
private:
// Simple "packer" to remove nextpnr IOBUFs, this assumes IOBUFs are manually instantiated
void pack_io(Context *ctx)
{
@ -82,13 +87,20 @@ void pack_io(Context *ctx)
}
}
public:
void pack() { pack_io(ctx); }
private:
Context *ctx;
};
// Main pack function
bool Arch::pack()
{
Context *ctx = getCtx();
try {
log_break();
pack_io(ctx);
Ecp5Packer(ctx).pack();
log_info("Checksum: 0x%08x\n", ctx->checksum());
return true;
} catch (log_execution_error_exception) {