Skip to content

Commit 1a6fe90

Browse files
committed
pln: adding shell mode for timing debug EDA-1999
1 parent 32c6309 commit 1a6fe90

File tree

3 files changed

+95
-42
lines changed

3 files changed

+95
-42
lines changed

planning/src/RS/rsOpts.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,45 +203,69 @@ static char* make_file_name(CStr arg) noexcept {
203203
void rsOpts::setFunction(CStr fun) noexcept {
204204
function_ = nullptr;
205205
if (!fun) return;
206+
207+
uint16_t tr = ltrace();
208+
206209
static CStr s_funList[] = {"cmd", // 0
207210
"pinc", // 1
208211
"stars", // 2
209212
"partition", // 3
210213
"pack", // 4
211214
"route", // 5
215+
"shell", // 6
212216
nullptr};
213217
string f = str::s2lower(fun);
214218
if (f.empty()) return;
215219
if (f == "cmd") {
216220
function_ = s_funList[0];
221+
if (tr >= 5)
222+
lprintf("Opts::setFunction: %s\n", function_);
217223
assert(is_fun_cmd());
218224
return;
219225
}
220226
if (f == "pin" or f == "pinc" or f == "pin_c") {
221227
function_ = s_funList[1];
228+
if (tr >= 5)
229+
lprintf("Opts::setFunction: %s\n", function_);
222230
assert(is_fun_pinc());
223231
return;
224232
}
225233
if (f == "sta" or f == "star" or f == "stars") {
226234
function_ = s_funList[2];
235+
if (tr >= 5)
236+
lprintf("Opts::setFunction: %s\n", function_);
227237
assert(is_fun_stars());
228238
return;
229239
}
230240
if (f == "par" or f == "part" or f == "partition") {
231241
function_ = s_funList[3];
242+
if (tr >= 5)
243+
lprintf("Opts::setFunction: %s\n", function_);
232244
assert(is_fun_partition());
233245
return;
234246
}
235247
if (f == "pac" or f == "pack" or f == "packing") {
236248
function_ = s_funList[4];
249+
if (tr >= 5)
250+
lprintf("Opts::setFunction: %s\n", function_);
237251
assert(is_fun_pack());
238252
return;
239253
}
240254
if (f == "rt" or f == "route" or f == "routing") {
241255
function_ = s_funList[5];
256+
if (tr >= 5)
257+
lprintf("Opts::setFunction: %s\n", function_);
242258
assert(is_fun_route());
243259
return;
244260
}
261+
if (f == "sh" or f == "SH" or f == "shell" or
262+
f == "shel" or f == "Shell") {
263+
function_ = s_funList[6];
264+
if (tr >= 5)
265+
lprintf("Opts::setFunction: %s\n", function_);
266+
assert(is_fun_shell());
267+
return;
268+
}
245269
}
246270

247271
bool rsOpts::is_arg0_pinc() const noexcept {

planning/src/RS/rsOpts.h

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
#define __pln_Opts_H__e91c943c16c2d_
44

55
#include "util/pln_log.h"
6+
#include <bitset>
7+
8+
#undef MAX_UNITS
69

710
namespace pln {
811

@@ -12,30 +15,39 @@ using CStr = const char*;
1215

1316
struct rsOpts {
1417

18+
static constexpr uint MAX_UNITS = 64;
19+
1520
CStr shortVer_ = nullptr;
1621

1722
int argc_ = 0;
1823
const char** argv_ = nullptr;
1924

20-
CStr function_ = nullptr; // {cmd, pinc, stars, partition, pack, route}
25+
CStr function_ = nullptr; // {cmd, pinc, stars, partition, pack, route, shell}
2126
bool have_function() const noexcept { return function_; }
27+
bool function_is(CStr x) const noexcept {
28+
if (!x) return !function_;
29+
return function_ and ::strcmp(function_, x) == 0;
30+
}
2231
bool is_fun_cmd() const noexcept {
23-
return function_ && !strcmp(function_, "cmd");
32+
return function_is("cmd");
2433
}
2534
bool is_fun_pinc() const noexcept {
26-
return function_ && !strcmp(function_, "pinc");
35+
return function_is("pinc");
2736
}
2837
bool is_fun_stars() const noexcept {
29-
return function_ && !strcmp(function_, "stars");
38+
return function_is("stars");
3039
}
3140
bool is_fun_partition() const noexcept {
32-
return function_ && !strcmp(function_, "partition");
41+
return function_is("partition");
3342
}
3443
bool is_fun_pack() const noexcept {
35-
return function_ && !strcmp(function_, "pack");
44+
return function_is("pack");
3645
}
3746
bool is_fun_route() const noexcept {
38-
return function_ && !strcmp(function_, "route");
47+
return function_is("route");
48+
}
49+
bool is_fun_shell() const noexcept {
50+
return function_is("shell");
3951
}
4052
bool is_arg0_pinc() const noexcept;
4153
bool is_implicit_pinc() const noexcept;
@@ -74,13 +86,7 @@ struct rsOpts {
7486
bool check_ = false;
7587
bool cleanup_ = false;
7688

77-
bool unit1_ = false;
78-
bool unit2_ = false;
79-
bool unit3_ = false;
80-
bool unit4_ = false;
81-
bool unit5_ = false;
82-
bool unit6_ = false;
83-
bool unit7_ = false;
89+
std::bitset<MAX_UNITS> units_;
8490

8591
rsOpts() noexcept = default;
8692
rsOpts(int argc, const char** argv) noexcept { parse(argc, argv); }
@@ -92,13 +98,13 @@ struct rsOpts {
9298
void print(CStr label = nullptr) const noexcept;
9399
void printHelp() const noexcept;
94100

95-
bool unit_specified() const noexcept {
96-
return unit1_ or unit2_ or unit3_ or unit4_ or unit5_ or unit6_
97-
or unit7_;
98-
}
101+
bool unit_specified() const noexcept { return units_.any(); }
102+
99103
bool ver_or_help() const noexcept { return version_ or det_ver_ or help_; }
100104

101-
bool trace_specified() const noexcept { return traceIndex_ > 0 and trace_ > 0; }
105+
bool trace_specified() const noexcept {
106+
return traceIndex_ > 0 and trace_ > 0;
107+
}
102108
bool test_id_specified() const noexcept { return test_id_ > 0; }
103109

104110
bool set_STA_testCase(int TC_id) noexcept;

planning/src/main.cpp

Lines changed: 46 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
static const char* _pln_VERSION_STR = "pln0363";
1+
static const char* _pln_VERSION_STR = "pln0364";
22

33
#include "RS/rsEnv.h"
44
#include "util/pln_log.h"
@@ -470,16 +470,20 @@ static void deal_help(const rsOpts& opts) {
470470
static void deal_units(const rsOpts& opts) {
471471
#ifdef PLN_UNIT_TEST_ON
472472
using namespace tes;
473-
if (opts.unit1_) tes::run_U1();
474-
if (opts.unit2_) tes::run_U2();
475-
if (opts.unit3_) tes::run_U3();
476-
if (opts.unit4_) tes::run_U4();
477-
if (opts.unit5_) tes::run_U5();
478-
if (opts.unit6_) tes::run_U6();
479-
if (opts.unit7_) tes::run_U7();
473+
if (opts.units_[1]) tes::run_U1();
474+
if (opts.units_[2]) tes::run_U2();
475+
if (opts.units_[3]) tes::run_U3();
476+
if (opts.units_[4]) tes::run_U4();
477+
if (opts.units_[5]) tes::run_U5();
478+
if (opts.units_[6]) tes::run_U6();
479+
if (opts.units_[7]) tes::run_U7();
480480
#endif
481481
}
482482

483+
static bool deal_shell(const rsOpts& opts) {
484+
return true;
485+
}
486+
483487
} // NS pln
484488

485489
int main(int argc, char** argv) {
@@ -503,13 +507,14 @@ int main(int argc, char** argv) {
503507
if (opts.trace_specified())
504508
set_ltrace(opts.trace_);
505509

506-
if (opts.trace_ >= 8 or ltrace() >= 9 or ::getenv("pln_trace_env")) {
510+
uint16_t tr = ltrace();
511+
if (opts.trace_ >= 8 or tr >= 9 or ::getenv("pln_trace_env")) {
507512
s_env.dump("\n----env----\n");
508513
lout() << "-----------" << endl;
509514
}
510515

511516
if (opts.ver_or_help()) {
512-
if (ltrace() >= 2) {
517+
if (tr >= 2) {
513518
printf("\t %s\n", _pln_VERSION_STR);
514519
printf("\t compiled: %s\n", s_env.compTimeCS());
515520
}
@@ -518,12 +523,12 @@ int main(int argc, char** argv) {
518523
std::quick_exit(0);
519524
}
520525

521-
if (ltrace() >= 2) {
526+
if (tr >= 2) {
522527
lprintf("\t %s\n", _pln_VERSION_STR);
523528
lprintf("\t compiled: %s\n", s_env.compTimeCS());
524529
}
525-
if (ltrace() >= 4) {
526-
lprintf("ltrace()= %u cmd.argc= %i\n", ltrace(), argc);
530+
if (tr >= 4) {
531+
lprintf("ltrace= %u cmd.argc= %i\n", tr, argc);
527532
}
528533

529534
if (opts.unit_specified()) {
@@ -552,21 +557,21 @@ int main(int argc, char** argv) {
552557
if (opts.is_fun_cmd()) {
553558
ok = deal_cmd(opts);
554559
if (ok) {
555-
if (ltrace() >= 2) lputs("deal_cmd() succeeded.");
560+
if (tr >= 2) lputs("deal_cmd() succeeded.");
556561
status = 0;
557562
} else {
558-
if (ltrace() >= 2) lputs("deal_cmd() failed.");
563+
if (tr >= 2) lputs("deal_cmd() failed.");
559564
}
560565
goto ret;
561566
}
562567

563568
if (opts.is_fun_pinc() or opts.is_arg0_pinc() or opts.is_implicit_pinc()) {
564569
ok = deal_pinc(opts, true);
565570
if (ok) {
566-
if (ltrace() >= 2) lputs("deal_pinc() succeeded.");
571+
if (tr >= 2) lputs("deal_pinc() succeeded.");
567572
status = 0;
568573
} else {
569-
if (ltrace() >= 2) lputs("deal_pinc() failed.");
574+
if (tr >= 2) lputs("deal_pinc() failed.");
570575
}
571576
goto ret;
572577
}
@@ -575,7 +580,7 @@ int main(int argc, char** argv) {
575580
lputs("======== PARTITION MODE specified ========");
576581
ok = validate_partition_opts(opts);
577582
if (!ok) {
578-
if (ltrace() >= 4) lputs("validate_partition_opts() failed.");
583+
if (tr >= 4) lputs("validate_partition_opts() failed.");
579584
status = 2;
580585
goto ret;
581586
}
@@ -584,25 +589,43 @@ int main(int argc, char** argv) {
584589
if (opts.is_fun_partition() or opts.is_fun_pack()) {
585590
ok = deal_vpr(opts, true);
586591
if (ok) {
587-
if (ltrace() >= 2) lputs("deal_vpr() succeeded.");
592+
if (tr >= 2) lputs("deal_vpr() succeeded.");
588593
status = 0;
589594
} else {
590-
if (ltrace() >= 2) lputs("deal_vpr() failed.");
595+
if (tr >= 2) lputs("deal_vpr() failed.");
596+
}
597+
goto ret;
598+
}
599+
600+
if (opts.is_fun_shell()) {
601+
lputs("======== SHELL MODE specified ========");
602+
ok = true; // validate_shell_opts(opts);
603+
if (!ok) {
604+
if (tr >= 4) lputs("validate_shell_opts() failed.");
605+
status = 2;
606+
goto ret;
607+
}
608+
ok = deal_shell(opts);
609+
if (ok) {
610+
if (tr >= 2) lputs("deal_shell() succeeded.");
611+
status = 0;
612+
} else {
613+
if (tr >= 2) lputs("deal_shell() failed.");
591614
}
592615
goto ret;
593616
}
594617

595618
// default function is stars
596619
ok = deal_stars(opts, true);
597620
if (ok) {
598-
if (ltrace() >= 2) lputs("deal_stars() succeeded.");
621+
if (tr >= 2) lputs("deal_stars() succeeded.");
599622
status = 0;
600623
} else {
601-
if (ltrace() >= 2) lputs("deal_stars() failed.");
624+
if (tr >= 2) lputs("deal_stars() failed.");
602625
}
603626

604627
ret:
605-
if (ltrace() >= 4)
628+
if (tr >= 4)
606629
lprintf("(planner main status) %i\n", status);
607630
pln::flush_out(true);
608631
return status;

0 commit comments

Comments
 (0)