mirror of
https://github.com/YosysHQ/nextpnr.git
synced 2026-04-28 12:57:13 +00:00
refactor: id(stringf(...)) to new idf(...) helper
Signed-off-by: gatecat <gatecat@ds0.me>
This commit is contained in:
@@ -26,6 +26,18 @@
|
||||
|
||||
NEXTPNR_NAMESPACE_BEGIN
|
||||
|
||||
IdString BaseCtx::idf(const char *fmt, ...) const
|
||||
{
|
||||
std::string string;
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
string = vstringf(fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
return id(string);
|
||||
}
|
||||
|
||||
const char *BaseCtx::nameOfBel(BelId bel) const
|
||||
{
|
||||
const Context *ctx = getCtx();
|
||||
|
||||
@@ -162,6 +162,8 @@ struct BaseCtx
|
||||
|
||||
IdString id(const char *s) const { return IdString(this, s); }
|
||||
|
||||
IdString idf(const char *fmt, ...) const; // create IdString using printf formatting
|
||||
|
||||
Context *getCtx() { return as_ctx; }
|
||||
|
||||
const Context *getCtx() const { return as_ctx; }
|
||||
|
||||
@@ -152,8 +152,8 @@ void CellInfo::movePortBusTo(IdString old_name, int old_offset, bool old_bracket
|
||||
IdString new_name, int new_offset, bool new_brackets, int width)
|
||||
{
|
||||
for (int i = 0; i < width; i++) {
|
||||
IdString old_port = ctx->id(stringf(old_brackets ? "%s[%d]" : "%s%d", old_name.c_str(ctx), i + old_offset));
|
||||
IdString new_port = ctx->id(stringf(new_brackets ? "%s[%d]" : "%s%d", new_name.c_str(ctx), i + new_offset));
|
||||
IdString old_port = ctx->idf(old_brackets ? "%s[%d]" : "%s%d", old_name.c_str(ctx), i + old_offset);
|
||||
IdString new_port = ctx->idf(new_brackets ? "%s[%d]" : "%s%d", new_name.c_str(ctx), i + new_offset);
|
||||
movePortTo(old_port, new_cell, new_port);
|
||||
}
|
||||
}
|
||||
@@ -171,8 +171,8 @@ void CellInfo::copyPortBusTo(IdString old_name, int old_offset, bool old_bracket
|
||||
IdString new_name, int new_offset, bool new_brackets, int width)
|
||||
{
|
||||
for (int i = 0; i < width; i++) {
|
||||
IdString old_port = ctx->id(stringf(old_brackets ? "%s[%d]" : "%s%d", old_name.c_str(ctx), i + old_offset));
|
||||
IdString new_port = ctx->id(stringf(new_brackets ? "%s[%d]" : "%s%d", new_name.c_str(ctx), i + new_offset));
|
||||
IdString old_port = ctx->idf(old_brackets ? "%s[%d]" : "%s%d", old_name.c_str(ctx), i + old_offset);
|
||||
IdString new_port = ctx->idf(new_brackets ? "%s[%d]" : "%s%d", new_name.c_str(ctx), i + new_offset);
|
||||
copyPortTo(old_port, new_cell, new_port);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user