ice40: Optimise reset/enable net checking

Signed-off-by: David Shah <davey1576@gmail.com>
This commit is contained in:
David Shah 2018-07-20 11:36:32 +02:00
parent 79dc910b40
commit 3bad9c26cf
3 changed files with 14 additions and 11 deletions

View File

@ -25,7 +25,7 @@
#include "placer1.h"
#include "router1.h"
#include "util.h"
#include "cells.h"
NEXTPNR_NAMESPACE_BEGIN
// -----------------------------------------------------------------------
@ -704,6 +704,14 @@ void Arch::assignArchInfo()
NetInfo *ni = net.second.get();
if (isGlobalNet(ni))
ni->is_global = true;
ni->is_enable = false;
ni->is_reset = false;
for (auto usr : ni->users) {
if (is_enable_port(this, usr))
ni->is_enable = true;
if (is_reset_port(this, usr))
ni->is_reset = true;
}
}
for (auto &cell : getCtx()->cells) {
CellInfo *ci = cell.second.get();

View File

@ -108,21 +108,15 @@ bool Arch::isValidBelForCell(CellInfo *cell, BelId bel) const
} else if (cell->type == id_sb_io) {
return getBelPackagePin(bel) != "";
} else if (cell->type == id_sb_gb) {
bool is_reset = false, is_cen = false;
NPNR_ASSERT(cell->ports.at(id_glb_buf_out).net != nullptr);
for (auto user : cell->ports.at(id_glb_buf_out).net->users) {
if (is_reset_port(this, user))
is_reset = true;
if (is_enable_port(this, user))
is_cen = true;
}
const NetInfo *net = cell->ports.at(id_glb_buf_out).net;
IdString glb_net = getWireName(getWireBelPin(bel, PIN_GLOBAL_BUFFER_OUTPUT));
int glb_id = std::stoi(std::string("") + glb_net.str(this).back());
if (is_reset && is_cen)
if (net->is_reset && net->is_enable)
return false;
else if (is_reset)
else if (net->is_reset)
return (glb_id % 2) == 0;
else if (is_cen)
else if (net->is_enable)
return (glb_id % 2) == 1;
else
return true;

View File

@ -153,6 +153,7 @@ struct DecalId
struct ArchNetInfo
{
bool is_global = false;
bool is_reset = false, is_enable = false;
};
struct NetInfo;