Skip to content

Commit

Permalink
Merge pull request #107 from YosysHQ/router_improve
Browse files Browse the repository at this point in the history
Major rewrite of "router1"
  • Loading branch information
eddiehung authored Nov 13, 2018
2 parents d0ae4c7 + caca485 commit 3b2b15d
Show file tree
Hide file tree
Showing 14 changed files with 931 additions and 753 deletions.
26 changes: 26 additions & 0 deletions common/nextpnr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@
*/

#include "nextpnr.h"
#include "log.h"

NEXTPNR_NAMESPACE_BEGIN

assertion_failure::assertion_failure(std::string msg, std::string expr_str, std::string filename, int line)
: runtime_error("Assertion failure: " + msg + " (" + filename + ":" + std::to_string(line) + ")"), msg(msg),
expr_str(expr_str), filename(filename), line(line)
{
log_flush();
}

void IdString::set(const BaseCtx *ctx, const std::string &s)
Expand All @@ -51,6 +53,30 @@ void IdString::initialize_add(const BaseCtx *ctx, const char *s, int idx)
ctx->idstring_idx_to_str->push_back(&insert_rc.first->first);
}

const char *BaseCtx::nameOfBel(BelId bel) const
{
const Context *ctx = getCtx();
return ctx->getBelName(bel).c_str(ctx);
}

const char *BaseCtx::nameOfWire(WireId wire) const
{
const Context *ctx = getCtx();
return ctx->getWireName(wire).c_str(ctx);
}

const char *BaseCtx::nameOfPip(PipId pip) const
{
const Context *ctx = getCtx();
return ctx->getPipName(pip).c_str(ctx);
}

const char *BaseCtx::nameOfGroup(GroupId group) const
{
const Context *ctx = getCtx();
return ctx->getGroupName(group).c_str(ctx);
}

WireId Context::getNetinfoSourceWire(const NetInfo *net_info) const
{
if (net_info->driver.cell == nullptr)
Expand Down
17 changes: 14 additions & 3 deletions common/nextpnr.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ struct PipMap
struct NetInfo : ArchNetInfo
{
IdString name;
int32_t udata;
int32_t udata = 0;

PortRef driver;
std::vector<PortRef> users;
Expand Down Expand Up @@ -487,13 +487,23 @@ struct BaseCtx

const Context *getCtx() const { return reinterpret_cast<const Context *>(this); }

template <typename T> const char *nameOf(const T *obj)
const char *nameOf(IdString name) const
{
return name.c_str(this);
}

template <typename T> const char *nameOf(const T *obj) const
{
if (obj == nullptr)
return "";
return obj->name.c_str(getCtx());
return obj->name.c_str(this);
}

const char *nameOfBel(BelId bel) const;
const char *nameOfWire(WireId wire) const;
const char *nameOfPip(PipId pip) const;
const char *nameOfGroup(GroupId group) const;

// --------------------------------------------------------------

bool allUiReload = true;
Expand Down Expand Up @@ -541,6 +551,7 @@ struct Context : Arch, DeterministicRNG
delay_t getNetinfoRouteDelay(const NetInfo *net_info, const PortRef &sink) const;

// provided by router1.cc
bool checkRoutedDesign() const;
bool getActualRouteDelay(WireId src_wire, WireId dst_wire, delay_t *delay = nullptr,
std::unordered_map<WireId, PipId> *route = nullptr, bool useEstimate = true);

Expand Down
Loading

0 comments on commit 3b2b15d

Please sign in to comment.