Add ctx->route() API

Signed-off-by: Clifford Wolf <clifford@clifford.at>
This commit is contained in:
Clifford Wolf 2018-07-11 18:04:09 +02:00
parent e9b27860da
commit 7df67c91b3
13 changed files with 57 additions and 18 deletions

View File

@ -260,6 +260,10 @@ struct BaseCtx
delete idstring_idx_to_str;
}
Context *getCtx() { return reinterpret_cast<Context*>(this); }
const Context *getCtx() const { return reinterpret_cast<const Context*>(this); }
// --------------------------------------------------------------
bool allUiReload = false;
@ -366,6 +370,11 @@ struct Context : Arch
// --------------------------------------------------------------
// provided by router1.cc
bool getActualRouteDelay(WireId src_wire, WireId dst_wire, delay_t &delay);
// --------------------------------------------------------------
uint64_t rngstate = 0x3141592653589793;
uint64_t rng64()

View File

@ -21,7 +21,7 @@
#include <queue>
#include "log.h"
#include "route.h"
#include "router1.h"
namespace {
@ -402,7 +402,7 @@ struct Router
NEXTPNR_NAMESPACE_BEGIN
bool route_design(Context *ctx)
bool router1(Context *ctx)
{
try {
int totalVisitCnt = 0, totalRevisitCnt = 0, totalOvertimeRevisitCnt = 0;
@ -643,10 +643,10 @@ bool route_design(Context *ctx)
}
}
bool get_actual_route_delay(Context *ctx, WireId src_wire, WireId dst_wire, delay_t &delay)
bool Context::getActualRouteDelay(WireId src_wire, WireId dst_wire, delay_t &delay)
{
RipupScoreboard scores;
Router router(ctx, scores, src_wire, dst_wire);
Router router(this, scores, src_wire, dst_wire);
if (router.routedOkay)
delay = router.visited.at(dst_wire).delay;
return router.routedOkay;

View File

@ -17,16 +17,15 @@
*
*/
#ifndef ROUTE_H
#define ROUTE_H
#ifndef ROUTER1_H
#define ROUTER1_H
#include "nextpnr.h"
NEXTPNR_NAMESPACE_BEGIN
extern bool route_design(Context *ctx);
extern bool get_actual_route_delay(Context *ctx, WireId src_wire, WireId dst_wire, delay_t &delay);
extern bool router1(Context *ctx);
NEXTPNR_NAMESPACE_END
#endif // ROUTE_H
#endif // ROUTER1_H

View File

@ -23,6 +23,7 @@
#include <cstring>
#include "log.h"
#include "nextpnr.h"
#include "router1.h"
#include "util.h"
NEXTPNR_NAMESPACE_BEGIN
@ -288,6 +289,13 @@ delay_t Arch::estimateDelay(WireId src, WireId dst) const
// -----------------------------------------------------------------------
bool Arch::route()
{
return router1(getCtx());
}
// -----------------------------------------------------------------------
std::vector<GraphicElement> Arch::getDecalGraphics(DecalId decalId) const
{
std::vector<GraphicElement> ret;

View File

@ -720,6 +720,10 @@ struct Arch : BaseCtx
// -------------------------------------------------
bool route();
// -------------------------------------------------
std::vector<GraphicElement> getDecalGraphics(DecalId decal) const;
DecalXY getFrameDecal() const;

View File

@ -45,7 +45,6 @@
#include "jsonparse.h"
#include "pack.h"
#include "place_sa.h"
#include "route.h"
#include "timing.h"
USING_NEXTPNR_NAMESPACE
@ -150,7 +149,7 @@ int main(int argc, char *argv[])
if (!place_design_sa(&ctx) && !ctx.force)
log_error("Placing design failed.\n");
ctx.check();
if (!route_design(&ctx) && !ctx.force)
if (!ctx.route() && !ctx.force)
log_error("Routing design failed.\n");
std::string basecfg;

View File

@ -19,6 +19,7 @@
#include <math.h>
#include "nextpnr.h"
#include "router1.h"
NEXTPNR_NAMESPACE_BEGIN
@ -315,6 +316,14 @@ delay_t Arch::estimateDelay(WireId src, WireId dst) const
// ---------------------------------------------------------------
bool Arch::route()
{
return router1(getCtx());
}
// ---------------------------------------------------------------
const std::vector<GraphicElement> &Arch::getDecalGraphics(DecalId decal) const { return decal_graphics.at(decal); }
DecalXY Arch::getFrameDecal() const { return frame_decalxy; }

View File

@ -158,6 +158,8 @@ struct Arch : BaseCtx
float getDelayNS(delay_t v) const { return v; }
uint32_t getDelayChecksum(delay_t v) const { return 0; }
bool route();
const std::vector<GraphicElement> &getDecalGraphics(DecalId decal) const;
DecalXY getFrameDecal() const;
DecalXY getBelDecal(BelId bel) const;

View File

@ -30,7 +30,6 @@
#include "pack.h"
#include "pcf.h"
#include "place_sa.h"
#include "route.h"
static void initMainResource() { Q_INIT_RESOURCE(nextpnr); }
@ -444,4 +443,4 @@ void MainWindow::budget()
void MainWindow::place() { Q_EMIT task->place(timing_driven); }
NEXTPNR_NAMESPACE_END
NEXTPNR_NAMESPACE_END

View File

@ -26,7 +26,6 @@
#include "pack.h"
#include "pcf.h"
#include "place_sa.h"
#include "route.h"
#include "timing.h"
NEXTPNR_NAMESPACE_BEGIN
@ -134,7 +133,7 @@ void Worker::route()
{
Q_EMIT taskStarted();
try {
Q_EMIT route_finished(route_design(ctx));
Q_EMIT route_finished(ctx->route());
} catch (WorkerInterruptionRequested) {
Q_EMIT taskCanceled();
}

View File

@ -21,6 +21,7 @@
#include <cmath>
#include "log.h"
#include "nextpnr.h"
#include "router1.h"
#include "util.h"
#include "gfx.h"
@ -400,6 +401,13 @@ delay_t Arch::estimateDelay(WireId src, WireId dst) const
// -----------------------------------------------------------------------
bool Arch::route()
{
return router1(getCtx());
}
// -----------------------------------------------------------------------
DecalXY Arch::getFrameDecal() const
{
DecalXY decalxy;

View File

@ -643,6 +643,10 @@ struct Arch : BaseCtx
// -------------------------------------------------
bool route();
// -------------------------------------------------
std::vector<GraphicElement> getDecalGraphics(DecalId decal) const;
DecalXY getFrameDecal() const;

View File

@ -43,7 +43,6 @@
#include "pcf.h"
#include "place_legaliser.h"
#include "place_sa.h"
#include "route.h"
#include "timing.h"
#include "version.h"
@ -339,7 +338,7 @@ int main(int argc, char *argv[])
for (int i = 0; i < int(src_wires.size()) && i < int(dst_wires.size()); i++) {
delay_t actual_delay;
WireId src = src_wires[i], dst = dst_wires[i];
if (!get_actual_route_delay(&ctx, src, dst, actual_delay))
if (!ctx.getActualRouteDelay(src, dst, actual_delay))
continue;
printf("%s %s %.3f %.3f %d %d %d %d %d %d\n", ctx.getWireName(src).c_str(&ctx),
ctx.getWireName(dst).c_str(&ctx), ctx.getDelayNS(actual_delay),
@ -376,7 +375,7 @@ int main(int argc, char *argv[])
if (!place_design_sa(&ctx) && !ctx.force)
log_error("Placing design failed.\n");
ctx.check();
if (!route_design(&ctx) && !ctx.force)
if (!ctx.route() && !ctx.force)
log_error("Routing design failed.\n");
}
}