Updates from clangformat
Signed-off-by: Clifford Wolf <clifford@clifford.at>
This commit is contained in:
parent
5f37da9704
commit
fd40d6f58d
@ -291,10 +291,7 @@ struct Context : Arch
|
|||||||
return rngstate * 0x2545F4914F6CDD1D;
|
return rngstate * 0x2545F4914F6CDD1D;
|
||||||
}
|
}
|
||||||
|
|
||||||
int rng()
|
int rng() { return rng64() & 0x3fffffff; }
|
||||||
{
|
|
||||||
return rng64() & 0x3fffffff;
|
|
||||||
}
|
|
||||||
|
|
||||||
int rng(int n)
|
int rng(int n)
|
||||||
{
|
{
|
||||||
@ -310,22 +307,25 @@ struct Context : Arch
|
|||||||
m += 1;
|
m += 1;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
int x = rng64() & (m-1);
|
int x = rng64() & (m - 1);
|
||||||
if (x < n) return x;
|
if (x < n)
|
||||||
|
return x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void rngseed(uint64_t seed)
|
void rngseed(uint64_t seed)
|
||||||
{
|
{
|
||||||
rngstate = seed ? seed : 0x3141592653589793;
|
rngstate = seed ? seed : 0x3141592653589793;
|
||||||
for (int i = 0; i < 5; i++) rng64();
|
for (int i = 0; i < 5; i++)
|
||||||
|
rng64();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template <typename T> void shuffle(std::vector<T> &a)
|
||||||
void shuffle(std::vector<T> &a) {
|
{
|
||||||
for (size_t i = 0; i != a.size(); i++) {
|
for (size_t i = 0; i != a.size(); i++) {
|
||||||
size_t j = i + rng(a.size() - i);
|
size_t j = i + rng(a.size() - i);
|
||||||
if (j > i) std::swap(a[i], a[j]);
|
if (j > i)
|
||||||
|
std::swap(a[i], a[j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -67,7 +67,8 @@ struct Router
|
|||||||
delay_t maxDelay = 0.0;
|
delay_t maxDelay = 0.0;
|
||||||
WireId failedDest;
|
WireId failedDest;
|
||||||
|
|
||||||
Router(Context *ctx, IdString net_name, bool ripup = false, delay_t ripup_penalty = 0)
|
Router(Context *ctx, IdString net_name, bool ripup = false,
|
||||||
|
delay_t ripup_penalty = 0)
|
||||||
{
|
{
|
||||||
auto net_info = ctx->nets.at(net_name);
|
auto net_info = ctx->nets.at(net_name);
|
||||||
|
|
||||||
@ -438,7 +439,8 @@ bool route_design(Context *ctx)
|
|||||||
netCnt = 0;
|
netCnt = 0;
|
||||||
int ripCnt = 0;
|
int ripCnt = 0;
|
||||||
|
|
||||||
std::vector<IdString> ripupArray(ripupQueue.begin(), ripupQueue.end());
|
std::vector<IdString> ripupArray(ripupQueue.begin(),
|
||||||
|
ripupQueue.end());
|
||||||
ctx->shuffle(ripupArray);
|
ctx->shuffle(ripupArray);
|
||||||
|
|
||||||
for (auto net_name : ripupArray) {
|
for (auto net_name : ripupArray) {
|
||||||
@ -447,7 +449,8 @@ bool route_design(Context *ctx)
|
|||||||
net_name.c_str(ctx),
|
net_name.c_str(ctx),
|
||||||
int(ctx->nets.at(net_name)->users.size()));
|
int(ctx->nets.at(net_name)->users.size()));
|
||||||
|
|
||||||
Router router(ctx, net_name, true, ripup_penalty * (iterCnt - 1));
|
Router router(ctx, net_name, true,
|
||||||
|
ripup_penalty * (iterCnt - 1));
|
||||||
|
|
||||||
netCnt++;
|
netCnt++;
|
||||||
visitCnt += router.visitCnt;
|
visitCnt += router.visitCnt;
|
||||||
|
@ -748,12 +748,11 @@ void json_import(Context *ctx, string modname, JsonNode *node)
|
|||||||
int netid = bits->data_array.at(i)->data_number;
|
int netid = bits->data_array.at(i)->data_number;
|
||||||
if (netid >= netnames.size())
|
if (netid >= netnames.size())
|
||||||
netnames.resize(netid + 1);
|
netnames.resize(netid + 1);
|
||||||
netnames.at(netid) =
|
netnames.at(netid) = ctx->id(
|
||||||
ctx->id(basename +
|
basename +
|
||||||
(num_bits == 1 ? ""
|
(num_bits == 1 ? "" : std::string("[") +
|
||||||
: std::string("[") +
|
std::to_string(i) +
|
||||||
std::to_string(i) +
|
std::string("]")));
|
||||||
std::string("]")));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -279,8 +279,13 @@ template <> struct hash<NEXTPNR_NAMESPACE_PREFIX PipId>
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <> struct hash<NEXTPNR_NAMESPACE_PREFIX BelType> : hash<int> {};
|
template <> struct hash<NEXTPNR_NAMESPACE_PREFIX BelType> : hash<int>
|
||||||
template <> struct hash<NEXTPNR_NAMESPACE_PREFIX PortPin> : hash<int> {};
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
template <> struct hash<NEXTPNR_NAMESPACE_PREFIX PortPin> : hash<int>
|
||||||
|
{
|
||||||
|
};
|
||||||
} // namespace std
|
} // namespace std
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_BEGIN
|
NEXTPNR_NAMESPACE_BEGIN
|
||||||
|
@ -37,7 +37,7 @@ CellInfo *create_ice_cell(Context *ctx, IdString type, std::string name)
|
|||||||
CellInfo *new_cell = new CellInfo();
|
CellInfo *new_cell = new CellInfo();
|
||||||
if (name.empty()) {
|
if (name.empty()) {
|
||||||
new_cell->name = IdString(ctx, "$nextpnr_" + type.str() + "_" +
|
new_cell->name = IdString(ctx, "$nextpnr_" + type.str() + "_" +
|
||||||
std::to_string(auto_idx++));
|
std::to_string(auto_idx++));
|
||||||
} else {
|
} else {
|
||||||
new_cell->name = ctx->id(name);
|
new_cell->name = ctx->id(name);
|
||||||
}
|
}
|
||||||
@ -200,8 +200,8 @@ void nxio_to_sb(Context *ctx, CellInfo *nxio, CellInfo *sbio)
|
|||||||
}
|
}
|
||||||
NetInfo *donet = sbio->ports.at(ctx->id("D_OUT_0")).net;
|
NetInfo *donet = sbio->ports.at(ctx->id("D_OUT_0")).net;
|
||||||
CellInfo *tbuf =
|
CellInfo *tbuf =
|
||||||
net_driven_by(ctx, donet, []
|
net_driven_by(ctx, donet,
|
||||||
(const Context *ctx, const CellInfo *cell) {
|
[](const Context *ctx, const CellInfo *cell) {
|
||||||
return cell->type == ctx->id("$_TBUF_");
|
return cell->type == ctx->id("$_TBUF_");
|
||||||
},
|
},
|
||||||
"Y");
|
"Y");
|
||||||
@ -251,7 +251,8 @@ bool is_enable_port(const Context *ctx, const PortRef &port)
|
|||||||
|
|
||||||
bool is_global_net(const Context *ctx, const NetInfo *net)
|
bool is_global_net(const Context *ctx, const NetInfo *net)
|
||||||
{
|
{
|
||||||
return bool(net_driven_by(ctx, net, is_gbuf, ctx->id("GLOBAL_BUFFER_OUTPUT")));
|
return bool(
|
||||||
|
net_driven_by(ctx, net, is_gbuf, ctx->id("GLOBAL_BUFFER_OUTPUT")));
|
||||||
}
|
}
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_END
|
NEXTPNR_NAMESPACE_END
|
||||||
|
@ -27,8 +27,7 @@ NEXTPNR_NAMESPACE_BEGIN
|
|||||||
|
|
||||||
// Create a standard iCE40 cell and return it
|
// Create a standard iCE40 cell and return it
|
||||||
// Name will be automatically assigned if not specified
|
// Name will be automatically assigned if not specified
|
||||||
CellInfo *create_ice_cell(Context *ctx, IdString type,
|
CellInfo *create_ice_cell(Context *ctx, IdString type, std::string name = "");
|
||||||
std::string name = "");
|
|
||||||
|
|
||||||
// Return true if a cell is a LUT
|
// Return true if a cell is a LUT
|
||||||
inline bool is_lut(const Context *ctx, const CellInfo *cell)
|
inline bool is_lut(const Context *ctx, const CellInfo *cell)
|
||||||
|
@ -39,8 +39,8 @@ static void pack_lut_lutffs(Context *ctx)
|
|||||||
log_info("cell '%s' is of type '%s'\n", ci->name.c_str(ctx),
|
log_info("cell '%s' is of type '%s'\n", ci->name.c_str(ctx),
|
||||||
ci->type.c_str(ctx));
|
ci->type.c_str(ctx));
|
||||||
if (is_lut(ctx, ci)) {
|
if (is_lut(ctx, ci)) {
|
||||||
CellInfo *packed =
|
CellInfo *packed = create_ice_cell(ctx, "ICESTORM_LC",
|
||||||
create_ice_cell(ctx, "ICESTORM_LC", ci->name.str(ctx) + "_LC");
|
ci->name.str(ctx) + "_LC");
|
||||||
std::copy(ci->attrs.begin(), ci->attrs.end(),
|
std::copy(ci->attrs.begin(), ci->attrs.end(),
|
||||||
std::inserter(packed->attrs, packed->attrs.begin()));
|
std::inserter(packed->attrs, packed->attrs.begin()));
|
||||||
packed_cells.insert(ci->name);
|
packed_cells.insert(ci->name);
|
||||||
@ -168,7 +168,8 @@ static void set_net_constant(const Context *ctx, NetInfo *orig,
|
|||||||
for (auto user : orig->users) {
|
for (auto user : orig->users) {
|
||||||
if (user.cell != nullptr) {
|
if (user.cell != nullptr) {
|
||||||
CellInfo *uc = user.cell;
|
CellInfo *uc = user.cell;
|
||||||
log_info("%s user %s\n", orig->name.c_str(ctx), uc->name.c_str(ctx));
|
log_info("%s user %s\n", orig->name.c_str(ctx),
|
||||||
|
uc->name.c_str(ctx));
|
||||||
if (is_lut(ctx, uc) && (user.port.str(ctx).at(0) == 'I') &&
|
if (is_lut(ctx, uc) && (user.port.str(ctx).at(0) == 'I') &&
|
||||||
!constval) {
|
!constval) {
|
||||||
uc->ports[user.port].net = nullptr;
|
uc->ports[user.port].net = nullptr;
|
||||||
@ -204,7 +205,8 @@ static void pack_constants(Context *ctx)
|
|||||||
|
|
||||||
for (auto net : ctx->nets) {
|
for (auto net : ctx->nets) {
|
||||||
NetInfo *ni = net.second;
|
NetInfo *ni = net.second;
|
||||||
if (ni->driver.cell != nullptr && ni->driver.cell->type == ctx->id("GND")) {
|
if (ni->driver.cell != nullptr &&
|
||||||
|
ni->driver.cell->type == ctx->id("GND")) {
|
||||||
set_net_constant(ctx, ni, gnd_net, false);
|
set_net_constant(ctx, ni, gnd_net, false);
|
||||||
ctx->cells[gnd_cell->name] = gnd_cell;
|
ctx->cells[gnd_cell->name] = gnd_cell;
|
||||||
ctx->nets[gnd_net->name] = gnd_net;
|
ctx->nets[gnd_net->name] = gnd_net;
|
||||||
@ -224,7 +226,8 @@ static void pack_constants(Context *ctx)
|
|||||||
|
|
||||||
static bool is_nextpnr_iob(Context *ctx, CellInfo *cell)
|
static bool is_nextpnr_iob(Context *ctx, CellInfo *cell)
|
||||||
{
|
{
|
||||||
return cell->type == ctx->id("$nextpnr_ibuf") || cell->type == ctx->id("$nextpnr_obuf") ||
|
return cell->type == ctx->id("$nextpnr_ibuf") ||
|
||||||
|
cell->type == ctx->id("$nextpnr_obuf") ||
|
||||||
cell->type == ctx->id("$nextpnr_iobuf");
|
cell->type == ctx->id("$nextpnr_iobuf");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,7 +243,8 @@ static void pack_io(Context *ctx)
|
|||||||
CellInfo *ci = cell.second;
|
CellInfo *ci = cell.second;
|
||||||
if (is_nextpnr_iob(ctx, ci)) {
|
if (is_nextpnr_iob(ctx, ci)) {
|
||||||
CellInfo *sb = nullptr;
|
CellInfo *sb = nullptr;
|
||||||
if (ci->type == ctx->id("$nextpnr_ibuf") || ci->type == ctx->id("$nextpnr_iobuf")) {
|
if (ci->type == ctx->id("$nextpnr_ibuf") ||
|
||||||
|
ci->type == ctx->id("$nextpnr_iobuf")) {
|
||||||
sb = net_only_drives(ctx, ci->ports.at("O").net, is_sb_io,
|
sb = net_only_drives(ctx, ci->ports.at("O").net, is_sb_io,
|
||||||
"PACKAGE_PIN", true, ci);
|
"PACKAGE_PIN", true, ci);
|
||||||
|
|
||||||
@ -252,8 +256,8 @@ static void pack_io(Context *ctx)
|
|||||||
// Trivial case, SB_IO used. Just destroy the net and the
|
// Trivial case, SB_IO used. Just destroy the net and the
|
||||||
// iobuf
|
// iobuf
|
||||||
log_info("%s feeds SB_IO %s, removing %s %s.\n",
|
log_info("%s feeds SB_IO %s, removing %s %s.\n",
|
||||||
ci->name.c_str(ctx), sb->name.c_str(ctx), ci->type.c_str(ctx),
|
ci->name.c_str(ctx), sb->name.c_str(ctx),
|
||||||
ci->name.c_str(ctx));
|
ci->type.c_str(ctx), ci->name.c_str(ctx));
|
||||||
NetInfo *net = sb->ports.at("PACKAGE_PIN").net;
|
NetInfo *net = sb->ports.at("PACKAGE_PIN").net;
|
||||||
if (net != nullptr) {
|
if (net != nullptr) {
|
||||||
ctx->nets.erase(net->name);
|
ctx->nets.erase(net->name);
|
||||||
|
Loading…
Reference in New Issue
Block a user