Skip to content

Commit 1aed94c

Browse files
authored
Merge pull request #902 from os-fpga/checker_add_cleanup_option
checker: added --cleanup option
2 parents 0994029 + 3efdd45 commit 1aed94c

File tree

5 files changed

+83
-13
lines changed

5 files changed

+83
-13
lines changed

planning/src/RS/rsCheck.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ bool do_check_blif(CStr cfn,
121121
std::filesystem::path full_path{bfile.fnm_};
122122
std::filesystem::path base_path = full_path.filename();
123123
std::string base = base_path.string();
124+
//lputs9();
124125
string outFn = str::concat("PLN_W", std::to_string(numWarn), "_", base);
125126

126127
string wr_ok = bfile.writeBlif(outFn, numWarn);
@@ -154,6 +155,14 @@ bool do_check_blif(CStr cfn,
154155
return false;
155156
}
156157

158+
// 'corrected' : (lnum, removed_net)
159+
bool do_cleanup_blif(CStr cfn, std::vector<uspair>& corrected) {
160+
assert(cfn);
161+
corrected.clear();
162+
163+
return false;
164+
}
165+
157166
static bool do_check_csv(CStr cfn) {
158167
assert(cfn);
159168
uint16_t tr = ltrace();

planning/src/RS/rsCheck.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ bool do_check_blif(CStr cfn,
1313
std::vector<std::string>& badInputs,
1414
std::vector<std::string>& badOutputs);
1515

16+
bool do_cleanup_blif(
17+
CStr cfn,
18+
std::vector<uspair>& corrected // (lnum, removed_net)
19+
);
20+
1621
}
1722

1823
#endif

planning/src/RS/rsOpts.cpp

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,24 @@ namespace alias {
1515

1616
static CStr _ver_[] = {"V", "v", "ver", "vers", "version", nullptr};
1717

18-
static CStr _det_ver_[] = {"VV", "vv", "VVV", "vvv", "det_ver", "detailed_version", nullptr};
18+
static CStr _det_ver_[] = { "VV", "vv", "VVV", "vvv", "det_ver",
19+
"detailed_version", nullptr };
1920

20-
static CStr _help_[] = {"H", "h", "help", "hel", "hlp", "he", nullptr};
21+
static CStr _help_[] = { "H", "HH", "h", "hh", "help",
22+
"hel", "hlp", "he", nullptr };
2123

22-
static CStr _fun_[] = {"F", "fu", "fun", "func", "funct", "function", nullptr};
24+
static CStr _fun_[] = { "F", "FF", "ff", "fu", "fun", "func",
25+
"funct", "function", nullptr };
2326

24-
static CStr _check_[] = {"CH", "ch", "CC", "cc", "che", "chec", "check", nullptr};
27+
static CStr _check_[] = { "CH", "CHECK", "ch", "CC", "cc", "che", "chec",
28+
"check", "check_blif", nullptr };
2529

26-
static CStr _csv_[] = {"CSV", "cs", "csv", nullptr};
30+
static CStr _clean_[] = { "CLEAN", "CLEANUP", "clean", "cleanup", "clean_up",
31+
"cleanup_blif", "cleanupblif", "clean_up_blif", nullptr };
2732

28-
static CStr _xml_[] = {"XM", "xm", "xml", "XML", nullptr};
33+
static CStr _csv_[] = {"CSV", "cs", "csv", "Csv", nullptr};
34+
35+
static CStr _xml_[] = {"XM", "xm", "xml", "Xml", "XML", nullptr};
2936

3037
static CStr _pcf_[] = {"PCF", "pcf", nullptr};
3138

@@ -38,15 +45,13 @@ static CStr _json_[] = {"JS", "js", "jsf", "json", "port_info", "port_i", "PI",
3845

3946
static CStr _output_[] = {"OU", "ou", "out", "outp", "output", nullptr};
4047

41-
static CStr _assOrd_[] = {"ASS", "ass", "assign", "assign_unconstrained", "assign_unconstrained_pins", nullptr};
48+
static CStr _assOrd_[] = { "ASS", "ass", "assign", "assign_unconstrained",
49+
"assign_unconstrained_pins", nullptr };
4250

4351
static CStr _trace_[] = {"TR", "T", "TT", "tt", "trace", "Trace", "Tr", "tr", "tra", "trac", nullptr};
4452

4553
static CStr _test_[] = {"TE", "TC", "test", "te", "tc", "tes", "tst", "test_case", "test_c", nullptr};
4654

47-
#ifdef RSBE_UNIT_TEST_ON
48-
#endif // RSBE_UNIT_TEST_ON
49-
5055
}
5156

5257
static constexpr size_t UNIX_Path_Max = PATH_MAX - 4;
@@ -158,6 +163,7 @@ void rsOpts::printHelp() const noexcept {
158163
"--version,-V", "Version",
159164
"--trace,-T <number>", "Trace level, default 3",
160165
"--check <blif_file_name>", "BLIF or EBLIF file to check",
166+
"--clean_up <blif_file_name>", "BLIF or EBLIF file to clean up",
161167
"--csv <csv_file_name>", "CSV file (pin table) to check",
162168
nullptr, nullptr, nullptr };
163169

@@ -323,9 +329,12 @@ void rsOpts::parse(int argc, const char** argv) noexcept {
323329
check_ = true;
324330
continue;
325331
}
332+
if (op_match(arg, _clean_)) {
333+
cleanup_ = true;
334+
continue;
335+
}
326336

327-
#ifdef RSBE_UNIT_TEST_ON
328-
#endif // RSBE_UNIT_TEST_ON
337+
// --
329338

330339
if (op_match(arg, _csv_)) {
331340
i++;

planning/src/RS/rsOpts.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ struct rsOpts {
7272

7373
bool help_ = false;
7474
bool check_ = false;
75+
bool cleanup_ = false;
7576

7677
bool unit1_ = false;
7778
bool unit2_ = false;

planning/src/main.cpp

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

33
#include "RS/rsEnv.h"
44
#include "util/pln_log.h"
@@ -62,6 +62,45 @@ static bool deal_check(const rsOpts& opts) {
6262
return status;
6363
}
6464

65+
static bool deal_cleanup(const rsOpts& opts) {
66+
bool status = false;
67+
uint16_t tr = ltrace();
68+
69+
if (tr >= 4) {
70+
flush_out(true);
71+
lprintf("[PLANNER BLIF-CLEANER] deal_cleanup()\n");
72+
}
73+
74+
if (not opts.hasInputFile()) {
75+
err_puts("\n[PLANNER BLIF-CLEANER] : something wrong with input file\n");
76+
if (!opts.input_) {
77+
lputs("[PLANNER BLIF-CLEANER] : input file is not specified");
78+
} else {
79+
lprintf("[PLANNER BLIF-CLEANER] : input file '%s'\n", opts.input_);
80+
lprintf(" : does not exist or not readable\n");
81+
}
82+
flush_out(true);
83+
return false;
84+
}
85+
86+
std::vector<uspair> corrected;
87+
status = do_cleanup_blif(opts.input_, corrected);
88+
89+
if (tr >= 3) {
90+
lprintf(" deal_cleanup status: %s\n", status ? "TRUE" : "FALSE");
91+
if (corrected.empty()) {
92+
if (status)
93+
lprintf(" deal_cleanup: BLIF was not modified (NOP)\n");
94+
} else {
95+
lprintf(" deal_cleanup: modified BLIF, #changes= %zu\n",
96+
corrected.size());
97+
}
98+
}
99+
100+
flush_out(true);
101+
return status;
102+
}
103+
65104
static bool deal_stars(const rsOpts& opts, bool orig_args) {
66105
bool status = false;
67106

@@ -498,6 +537,13 @@ int main(int argc, char** argv) {
498537
else
499538
::exit(1);
500539
}
540+
if (opts.cleanup_) {
541+
bool cleanup_ok = deal_cleanup(opts);
542+
if (cleanup_ok)
543+
::exit(0);
544+
else
545+
::exit(1);
546+
}
501547

502548
int status = 1;
503549
bool ok = false;

0 commit comments

Comments
 (0)