Skip to content

Commit 0994029

Browse files
authored
Merge pull request #901 from os-fpga/checker_writeBlif_path_cleanup
checker: writeBlif path cleanup
2 parents f79f43a + 087f440 commit 0994029

File tree

4 files changed

+31
-10
lines changed

4 files changed

+31
-10
lines changed

planning/src/RS/rsCheck.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "RS/rsCheck.h"
22
#include "file_io/pln_blif_file.h"
33
#include "file_io/pln_csv_reader.h"
4+
#include <filesystem>
45

56
namespace pln {
67

@@ -117,8 +118,13 @@ bool do_check_blif(CStr cfn,
117118
lprintf(" # WARNINGS= %u", numWarn);
118119
lputs();
119120
if (numWarn or ::getenv("pln_always_write_blif")) {
120-
string outFn = str::concat("PLN_W", std::to_string(numWarn), "_", cfn);
121+
std::filesystem::path full_path{bfile.fnm_};
122+
std::filesystem::path base_path = full_path.filename();
123+
std::string base = base_path.string();
124+
string outFn = str::concat("PLN_W", std::to_string(numWarn), "_", base);
125+
121126
string wr_ok = bfile.writeBlif(outFn, numWarn);
127+
122128
if (wr_ok.empty())
123129
lprintf("---!! FAILED writeBlif to '%s'\n", outFn.c_str());
124130
else

planning/src/file_io/pln_blif_file.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ bool BLIF_file::readBlif() noexcept {
306306
}
307307

308308
size_t num_escaped = escapeNL();
309-
if (trace_ >= 4) {
309+
if (trace_ >= 6) {
310310
lprintf(" ....\\ ... num_escaped= %zu\n", num_escaped);
311311
}
312312

@@ -2509,7 +2509,12 @@ string BLIF_file::writeBlif(const string& toFn, bool cleanUp) noexcept {
25092509
if (not hasLines())
25102510
return {};
25112511

2512-
string fn2 = (toFn == fnm_ ? str::concat("2_", toFn) : toFn);
2512+
string fn2 = toFn; // (toFn == fnm_ ? str::concat("2_", toFn) : toFn);
2513+
2514+
if (trace_ >= 4) {
2515+
lout() << "pln_blif_file: writing BLIF to " << fn2
2516+
<< "\n CWD= " << get_CWD() << endl;
2517+
}
25132518

25142519
CStr cnm = fn2.c_str();
25152520
FILE* f = ::fopen(cnm, "w");
@@ -2562,7 +2567,7 @@ string BLIF_file::writeBlif(const string& toFn, bool cleanUp) noexcept {
25622567
buf[0] = 0; buf[1] = 0;
25632568
size_t rdsz = dNode.realData_.size();
25642569
if (trace_ >= 4) {
2565-
lprintf("wrBlif: cell %s at line %zu has dangling bit, filtering..\n",
2570+
lprintf(" wrBlif: cell %s at line %zu has dangling bit, filtering..\n",
25662571
dNode.cPrimType(), lineNum);
25672572
if (trace_ >= 5) {
25682573
lprintf(" dangling cell realData_.size()= %zu\n", rdsz);
@@ -2581,7 +2586,7 @@ string BLIF_file::writeBlif(const string& toFn, bool cleanUp) noexcept {
25812586
tail = ::stpcpy(tail, ts);
25822587
}
25832588
if (trace_ >= 4) {
2584-
lprintf("wrBlif: filtered dangling bits (%u) for cell %s at line %zu\n",
2589+
lprintf(" wrBlif: filtered dangling bits (%u) for cell %s at line %zu\n",
25852590
skipCnt, dNode.cPrimType(), lineNum);
25862591
}
25872592
}
@@ -2617,6 +2622,8 @@ string BLIF_file::writeBlif(const string& toFn, bool cleanUp) noexcept {
26172622

26182623
flush_out(trace_ >= 5);
26192624

2625+
if (error)
2626+
return {};
26202627
return fn2;
26212628
}
26222629

planning/src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
static const char* _pln_VERSION_STR = "pln0355";
1+
static const char* _pln_VERSION_STR = "pln0356";
22

33
#include "RS/rsEnv.h"
44
#include "util/pln_log.h"

planning/src/util/pln_log.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,18 @@ inline string concat(CStr a, const string& b, CStr c, CStr d) noexcept {
156156
if (a)
157157
z = a;
158158
z += b;
159-
if (c)
160-
z += c;
161-
if (d)
162-
z += d;
159+
if (c) z += c;
160+
if (d) z += d;
161+
return z;
162+
}
163+
inline string concat(CStr a, const string& b, CStr c, const string& d) noexcept {
164+
string z;
165+
z.reserve(p_strlen(a) + b.length() + p_strlen(c) + d.length() + 1);
166+
if (a)
167+
z = a;
168+
z += b;
169+
if (c) z += c;
170+
z += d;
163171
return z;
164172
}
165173
inline string concat(const string& a, CStr b) noexcept { return b ? a + b : a; }

0 commit comments

Comments
 (0)