common: Remove use of deprecated APIs

Signed-off-by: David Shah <davey1576@gmail.com>
This commit is contained in:
David Shah 2018-07-24 15:45:49 +02:00
parent c0c8dc7602
commit e200c281d9
3 changed files with 24 additions and 29 deletions

View File

@ -17,8 +17,8 @@
* *
*/ */
#include "nextpnr.h"
#include "log.h" #include "log.h"
#include "nextpnr.h"
#if 0 #if 0
#define dbg(...) log(__VA_ARGS__) #define dbg(...) log(__VA_ARGS__)
@ -84,8 +84,7 @@ void archcheck_locs(const Context *ctx)
log_info("Checking all locations..\n"); log_info("Checking all locations..\n");
for (int x = 0; x < ctx->getGridDimX(); x++) for (int x = 0; x < ctx->getGridDimX(); x++)
for (int y = 0; y < ctx->getGridDimY(); y++) for (int y = 0; y < ctx->getGridDimY(); y++) {
{
dbg("> %d %d\n", x, y); dbg("> %d %d\n", x, y);
std::unordered_set<int> usedz; std::unordered_set<int> usedz;

View File

@ -28,19 +28,20 @@ NEXTPNR_NAMESPACE_BEGIN
wirelen_t get_net_metric(const Context *ctx, const NetInfo *net, MetricType type, float &tns) wirelen_t get_net_metric(const Context *ctx, const NetInfo *net, MetricType type, float &tns)
{ {
wirelen_t wirelength = 0; wirelen_t wirelength = 0;
int driver_x, driver_y; Loc driver_loc;
bool driver_gb; bool driver_gb;
CellInfo *driver_cell = net->driver.cell; CellInfo *driver_cell = net->driver.cell;
if (!driver_cell) if (!driver_cell)
return 0; return 0;
if (driver_cell->bel == BelId()) if (driver_cell->bel == BelId())
return 0; return 0;
ctx->estimatePosition(driver_cell->bel, driver_x, driver_y, driver_gb); driver_gb = ctx->getBelGlobalBuf(driver_cell->bel);
driver_loc = ctx->getBelLocation(driver_cell->bel);
WireId drv_wire = ctx->getBelPinWire(driver_cell->bel, ctx->portPinFromId(net->driver.port)); WireId drv_wire = ctx->getBelPinWire(driver_cell->bel, ctx->portPinFromId(net->driver.port));
if (driver_gb) if (driver_gb)
return 0; return 0;
float worst_slack = 1000; float worst_slack = 1000;
int xmin = driver_x, xmax = driver_x, ymin = driver_y, ymax = driver_y; int xmin = driver_loc.x, xmax = driver_loc.x, ymin = driver_loc.y, ymax = driver_loc.y;
for (auto load : net->users) { for (auto load : net->users) {
if (load.cell == nullptr) if (load.cell == nullptr)
continue; continue;
@ -56,15 +57,14 @@ wirelen_t get_net_metric(const Context *ctx, const NetInfo *net, MetricType type
worst_slack = std::min(slack, worst_slack); worst_slack = std::min(slack, worst_slack);
} }
int load_x, load_y; if (ctx->getBelGlobalBuf(load_cell->bel))
bool load_gb;
ctx->estimatePosition(load_cell->bel, load_x, load_y, load_gb);
if (load_gb)
continue; continue;
xmin = std::min(xmin, load_x); Loc load_loc = ctx->getBelLocation(load_cell->bel);
ymin = std::min(ymin, load_y);
xmax = std::max(xmax, load_x); xmin = std::min(xmin, load_loc.x);
ymax = std::max(ymax, load_y); ymin = std::min(ymin, load_loc.y);
xmax = std::max(xmax, load_loc.x);
ymax = std::max(ymax, load_loc.y);
} }
if (ctx->timing_driven && type == MetricType::COST) { if (ctx->timing_driven && type == MetricType::COST) {
wirelength = wirelen_t((((ymax - ymin) + (xmax - xmin)) * std::min(5.0, (1.0 + std::exp(-worst_slack / 5))))); wirelength = wirelen_t((((ymax - ymin) + (xmax - xmin)) * std::min(5.0, (1.0 + std::exp(-worst_slack / 5)))));

View File

@ -50,9 +50,7 @@ class SAPlacer
{ {
int num_bel_types = 0; int num_bel_types = 0;
for (auto bel : ctx->getBels()) { for (auto bel : ctx->getBels()) {
int x, y; Loc loc = ctx->getBelLocation(bel);
bool gb;
ctx->estimatePosition(bel, x, y, gb);
BelType type = ctx->getBelType(bel); BelType type = ctx->getBelType(bel);
int type_idx; int type_idx;
if (bel_types.find(type) == bel_types.end()) { if (bel_types.find(type) == bel_types.end()) {
@ -63,13 +61,13 @@ class SAPlacer
} }
if (int(fast_bels.size()) < type_idx + 1) if (int(fast_bels.size()) < type_idx + 1)
fast_bels.resize(type_idx + 1); fast_bels.resize(type_idx + 1);
if (int(fast_bels.at(type_idx).size()) < (x + 1)) if (int(fast_bels.at(type_idx).size()) < (loc.x + 1))
fast_bels.at(type_idx).resize(x + 1); fast_bels.at(type_idx).resize(loc.x + 1);
if (int(fast_bels.at(type_idx).at(x).size()) < (y + 1)) if (int(fast_bels.at(type_idx).at(loc.x).size()) < (loc.y + 1))
fast_bels.at(type_idx).at(x).resize(y + 1); fast_bels.at(type_idx).at(loc.x).resize(loc.y + 1);
max_x = std::max(max_x, x); max_x = std::max(max_x, loc.x);
max_y = std::max(max_y, y); max_y = std::max(max_y, loc.y);
fast_bels.at(type_idx).at(x).at(y).push_back(bel); fast_bels.at(type_idx).at(loc.x).at(loc.y).push_back(bel);
} }
diameter = std::max(max_x, max_y) + 1; diameter = std::max(max_x, max_y) + 1;
} }
@ -404,12 +402,10 @@ class SAPlacer
BelId random_bel_for_cell(CellInfo *cell) BelId random_bel_for_cell(CellInfo *cell)
{ {
BelType targetType = ctx->belTypeFromId(cell->type); BelType targetType = ctx->belTypeFromId(cell->type);
int x, y; Loc curr_loc = ctx->getBelLocation(cell->bel);
bool gb;
ctx->estimatePosition(cell->bel, x, y, gb);
while (true) { while (true) {
int nx = ctx->rng(2 * diameter + 1) + std::max(x - diameter, 0); int nx = ctx->rng(2 * diameter + 1) + std::max(curr_loc.x - diameter, 0);
int ny = ctx->rng(2 * diameter + 1) + std::max(y - diameter, 0); int ny = ctx->rng(2 * diameter + 1) + std::max(curr_loc.y - diameter, 0);
int beltype_idx = bel_types.at(targetType); int beltype_idx = bel_types.at(targetType);
if (nx >= int(fast_bels.at(beltype_idx).size())) if (nx >= int(fast_bels.at(beltype_idx).size()))
continue; continue;