aboutsummaryrefslogtreecommitdiffstats
path: root/backends/firrtl/firrtl.cc
diff options
context:
space:
mode:
authorSahand Kashani <sahand.kashani@gmail.com>2020-03-24 21:07:08 +0100
committerSahand Kashani <sahand.kashani@gmail.com>2020-03-24 21:07:08 +0100
commit6c2b220af56ccac5ce343914cab095114656c83a (patch)
treee64a80761d243ded94c9a19fbc724a796a61dd87 /backends/firrtl/firrtl.cc
parent018116e478259f175a0a239da52bbbca8fa69b22 (diff)
downloadyosys-6c2b220af56ccac5ce343914cab095114656c83a.tar.gz
yosys-6c2b220af56ccac5ce343914cab095114656c83a.tar.bz2
yosys-6c2b220af56ccac5ce343914cab095114656c83a.zip
Remove use of auto for simple types + simplify src attribute computation
Diffstat (limited to 'backends/firrtl/firrtl.cc')
-rw-r--r--backends/firrtl/firrtl.cc15
1 files changed, 5 insertions, 10 deletions
diff --git a/backends/firrtl/firrtl.cc b/backends/firrtl/firrtl.cc
index 48a4d0465..0cac437ac 100644
--- a/backends/firrtl/firrtl.cc
+++ b/backends/firrtl/firrtl.cc
@@ -46,15 +46,10 @@ static const int FIRRTL_MAX_DSH_WIDTH_ERROR = 20; // For historic reasons, this
std::string getFileinfo(const RTLIL::AttrObject *design_entity)
{
std::string src(design_entity->get_src_attribute());
-
- std::ostringstream fileinfo;
- if (!src.empty()) {
- fileinfo << "@[" << src << "]";
- }
+ std::string fileinfo_str = src.empty() ? "" : "@[" + src + "]";
// Remove quotes from src attribute as firrtl automatically escapes and
// double-quotes them.
- std::string fileinfo_str(fileinfo.str());
fileinfo_str.erase(std::remove(fileinfo_str.begin(), fileinfo_str.end(), '\"'), fileinfo_str.end());
return fileinfo_str;
@@ -348,7 +343,7 @@ struct FirrtlWorker
log_warning("No instance for %s.%s\n", cell_type.c_str(), cell_name.c_str());
return;
}
- auto cellFileinfo = getFileinfo(cell);
+ std::string cellFileinfo = getFileinfo(cell);
wire_exprs.push_back(stringf("%s" "inst %s%s of %s %s", indent.c_str(), cell_name.c_str(), cell_name_comment.c_str(), instanceOf.c_str(), cellFileinfo.c_str()));
for (auto it = cell->connections().begin(); it != cell->connections().end(); ++it) {
@@ -414,14 +409,14 @@ struct FirrtlWorker
void run()
{
- auto moduleFileinfo = getFileinfo(module);
+ std::string moduleFileinfo = getFileinfo(module);
f << stringf(" module %s: %s\n", make_id(module->name), moduleFileinfo.c_str());
vector<string> port_decls, wire_decls, cell_exprs, wire_exprs;
for (auto wire : module->wires())
{
const auto wireName = make_id(wire->name);
- auto wireFileinfo = getFileinfo(wire);
+ std::string wireFileinfo = getFileinfo(wire);
// If a wire has initial data, issue a warning since FIRRTL doesn't currently support it.
if (wire->attributes.count("\\init")) {
@@ -1155,7 +1150,7 @@ struct FirrtlBackend : public Backend {
if (top == nullptr)
top = last;
- auto circuitFileinfo = getFileinfo(top);
+ std::string circuitFileinfo = getFileinfo(top);
*f << stringf("circuit %s: %s\n", make_id(top->name), circuitFileinfo.c_str());
for (auto module : design->modules())