Skip to content

Commit

Permalink
Improve log messages, move many messages to verbose mode
Browse files Browse the repository at this point in the history
Signed-off-by: Clifford Wolf <[email protected]>
  • Loading branch information
cliffordwolf committed Jun 21, 2018
1 parent 693c34a commit 993f6ef
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 48 deletions.
8 changes: 5 additions & 3 deletions common/design_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,13 @@ void print_utilisation(const Context *ctx)
for (auto bel : ctx->getBels()) {
available_types[ctx->getBelType(bel)]++;
}
log("\nDesign utilisation:\n");
log_break();
log_info("Device utilisation:\n");
for (auto type : available_types) {
log("\t%20s: %5d/%5d\n", ctx->belTypeToId(type.first).c_str(ctx),
get_or_default(used_types, type.first, 0), type.second);
log_info("\t%20s: %5d/%5d\n", ctx->belTypeToId(type.first).c_str(ctx),
get_or_default(used_types, type.first, 0), type.second);
}
log_break();
}

NEXTPNR_NAMESPACE_END
12 changes: 1 addition & 11 deletions common/log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -212,20 +212,14 @@ void log_cmd_error(const char *format, ...)
logv_error(format, ap);
}

void log_spacer()
void log_break()
{
if (log_newline_count < 2)
log("\n");
if (log_newline_count < 2)
log("\n");
}

void log_push() {}

void log_pop() { log_flush(); }

void log_reset_stack() { log_flush(); }

void log_flush()
{
for (auto f : log_files)
Expand All @@ -235,8 +229,4 @@ void log_flush()
f->flush();
}

void log_cell(CellInfo *cell, std::string indent) {}

void log_net(NetInfo *net, std::string indent) {}

NEXTPNR_NAMESPACE_END
18 changes: 1 addition & 17 deletions common/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,25 +71,9 @@ NXP_NORETURN void log_error(const char *format, ...)
NXP_NORETURN void log_cmd_error(const char *format, ...)
NXP_ATTRIBUTE(format(printf, 1, 2), noreturn);

void log_spacer();
void log_push();
void log_pop();

void log_backtrace(const char *prefix, int levels);
void log_reset_stack();
void log_break();
void log_flush();

/*
const char *log_id(RTLIL::IdString id);
template<typename T> static inline const char *log_id(T *obj) {
return log_id(obj->name);
}
*/

void log_cell(CellInfo *cell, std::string indent = "");
void log_net(NetInfo *net, std::string indent = "");

#ifndef NDEBUG
static inline void log_assert_worker(bool cond, const char *expr,
const char *file, int line)
Expand Down
8 changes: 5 additions & 3 deletions common/place_sa.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ class SAPlacer

bool place()
{
log_break();

size_t placed_cells = 0;
// Initial constraints placer
for (auto cell_entry : ctx->cells) {
Expand Down Expand Up @@ -408,9 +410,9 @@ class SAPlacer
delta = new_wirelength - curr_wirelength;
n_move++;
// SA acceptance criterea
if (delta < 0 ||
(temp > 1e-6 && (ctx->rng() / float(0x3fffffff)) <=
std::exp(-(delta / 2) / temp))) {
if (delta < 0 || (temp > 1e-6 &&
(ctx->rng() / float(0x3fffffff)) <=
std::exp(-(delta / 2) / temp))) {
n_accept++;
if (delta < 2)
improved = true;
Expand Down
1 change: 1 addition & 0 deletions common/route.cc
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ bool route_design(Context *ctx)
delay_t ripup_penalty = ctx->getRipupDelayPenalty();
RipupScoreboard scores;

log_break();
log_info("Routing..\n");

std::unordered_set<IdString> netsQueue;
Expand Down
9 changes: 6 additions & 3 deletions frontend/json/jsonparse.cc
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,8 @@ static void insert_iobuf(Context *ctx, NetInfo *net, PortType type,
std::copy(net->attrs.begin(), net->attrs.end(),
std::inserter(iobuf->attrs, iobuf->attrs.begin()));
if (type == PORT_IN) {
log_info("processing input port %s\n", name.c_str());
if (ctx->verbose)
log_info("processing input port %s\n", name.c_str());
iobuf->type = ctx->id("$nextpnr_ibuf");
iobuf->ports[ctx->id("O")] = PortInfo{ctx->id("O"), net, PORT_OUT};
// Special case: input, etc, directly drives inout
Expand All @@ -671,15 +672,17 @@ static void insert_iobuf(Context *ctx, NetInfo *net, PortType type,
net->driver.port = ctx->id("O");
net->driver.cell = iobuf;
} else if (type == PORT_OUT) {
log_info("processing output port %s\n", name.c_str());
if (ctx->verbose)
log_info("processing output port %s\n", name.c_str());
iobuf->type = ctx->id("$nextpnr_obuf");
iobuf->ports[ctx->id("I")] = PortInfo{ctx->id("I"), net, PORT_IN};
PortRef ref;
ref.cell = iobuf;
ref.port = ctx->id("I");
net->users.push_back(ref);
} else if (type == PORT_INOUT) {
log_info("processing inout port %s\n", name.c_str());
if (ctx->verbose)
log_info("processing inout port %s\n", name.c_str());
iobuf->type = ctx->id("$nextpnr_iobuf");
iobuf->ports[ctx->id("I")] = PortInfo{ctx->id("I"), nullptr, PORT_IN};

Expand Down
28 changes: 17 additions & 11 deletions ice40/pack.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,28 @@ static void pack_lut_lutffs(Context *ctx)
std::vector<CellInfo *> new_cells;
for (auto cell : ctx->cells) {
CellInfo *ci = cell.second;
log_info("cell '%s' is of type '%s'\n", ci->name.c_str(ctx),
ci->type.c_str(ctx));
if (ctx->verbose)
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");
std::copy(ci->attrs.begin(), ci->attrs.end(),
std::inserter(packed->attrs, packed->attrs.begin()));
packed_cells.insert(ci->name);
new_cells.push_back(packed);
log_info("packed cell %s into %s\n", ci->name.c_str(ctx),
packed->name.c_str(ctx));
if (ctx->verbose)
log_info("packed cell %s into %s\n", ci->name.c_str(ctx),
packed->name.c_str(ctx));
// See if we can pack into a DFF
// TODO: LUT cascade
NetInfo *o = ci->ports.at(ctx->id("O")).net;
CellInfo *dff = net_only_drives(ctx, o, is_ff, "D", true);
auto lut_bel = ci->attrs.find(ctx->id("BEL"));
bool packed_dff = false;
if (dff) {
log_info("found attached dff %s\n", dff->name.c_str(ctx));
if (ctx->verbose)
log_info("found attached dff %s\n", dff->name.c_str(ctx));
auto dff_bel = dff->attrs.find(ctx->id("BEL"));
if (lut_bel != ci->attrs.end() && dff_bel != dff->attrs.end() &&
lut_bel->second != dff_bel->second) {
Expand All @@ -66,8 +69,9 @@ static void pack_lut_lutffs(Context *ctx)
if (dff_bel != dff->attrs.end())
packed->attrs[ctx->id("BEL")] = dff_bel->second;
packed_cells.insert(dff->name);
log_info("packed cell %s into %s\n", dff->name.c_str(ctx),
packed->name.c_str(ctx));
if (ctx->verbose)
log_info("packed cell %s into %s\n",
dff->name.c_str(ctx), packed->name.c_str(ctx));
packed_dff = true;
}
}
Expand Down Expand Up @@ -99,8 +103,9 @@ static void pack_nonlut_ffs(Context *ctx)
ci->name.str(ctx) + "_DFFLC");
std::copy(ci->attrs.begin(), ci->attrs.end(),
std::inserter(packed->attrs, packed->attrs.begin()));
log_info("packed cell %s into %s\n", ci->name.c_str(ctx),
packed->name.c_str(ctx));
if (ctx->verbose)
log_info("packed cell %s into %s\n", ci->name.c_str(ctx),
packed->name.c_str(ctx));
packed_cells.insert(ci->name);
new_cells.push_back(packed);
dff_to_lc(ctx, ci, packed, true);
Expand Down Expand Up @@ -242,8 +247,9 @@ 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));
if (ctx->verbose)
log_info("%s user %s\n", orig->name.c_str(ctx),
uc->name.c_str(ctx));
if ((is_lut(ctx, uc) || is_lc(ctx, uc)) &&
(user.port.str(ctx).at(0) == 'I') && !constval) {
uc->ports[user.port].net = nullptr;
Expand Down

0 comments on commit 993f6ef

Please sign in to comment.