Skip to content

Commit b80f22f

Browse files
committed
pin_c: check and report config.json argument
1 parent e0d3c08 commit b80f22f

File tree

7 files changed

+61
-21
lines changed

7 files changed

+61
-21
lines changed

planning/src/RS/rsOpts.cpp

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ static CStr _xml_[] = {"XM", "xm", "xml", "XML", nullptr};
2929

3030
static CStr _pcf_[] = {"PCF", "pcf", nullptr};
3131

32+
static CStr _edtf_[] = {"EDT", "edit", "edits", nullptr};
33+
3234
static CStr _blif_[] = {"BL", "blif", nullptr};
3335

3436
static CStr _json_[] = {"JS", "js", "jsf", "json", "port_info", "port_i", "PI", nullptr};
@@ -129,6 +131,7 @@ void rsOpts::print(CStr label) const noexcept {
129131
printf(" pcfFile_: %s\n", nns(pcfFile_));
130132
printf(" blifFile_: %s\n", nns(blifFile_));
131133
printf(" jsonFile_: %s\n", nns(jsonFile_));
134+
printf(" editsFile_: %s\n", nns(editsFile_));
132135
printf(" output_: %s\n", nns(output_));
133136
printf(" assignOrder_: %s\n", nns(assignOrder_));
134137

@@ -285,7 +288,7 @@ void rsOpts::parse(int argc, const char** argv) noexcept {
285288
assert(argc_ > 0 and argv_);
286289

287290
CStr inp = 0, out = 0, csv = 0, xml = 0, pcf = 0, blif = 0, jsnf = 0,
288-
fun = 0, assignOrd = 0;
291+
fun = 0, assignOrd = 0, edtf = 0;
289292

290293
for (int i = 1; i < argc_; i++) {
291294
CStr arg = argv_[i];
@@ -343,6 +346,14 @@ void rsOpts::parse(int argc, const char** argv) noexcept {
343346
pcf = nullptr;
344347
continue;
345348
}
349+
if (op_match(arg, _edtf_)) {
350+
i++;
351+
if (i < argc_)
352+
edtf = argv_[i];
353+
else
354+
edtf = nullptr;
355+
continue;
356+
}
346357
if (op_match(arg, _blif_)) {
347358
i++;
348359
if (i < argc_)
@@ -421,6 +432,7 @@ void rsOpts::parse(int argc, const char** argv) noexcept {
421432
pcfFile_ = p_strdup(pcf);
422433
blifFile_ = p_strdup(blif);
423434
jsonFile_ = p_strdup(jsnf);
435+
editsFile_ = p_strdup(edtf);
424436

425437
if (fun)
426438
setFunction(fun);
@@ -541,6 +553,7 @@ bool rsOpts::ends_with_pin_c(CStr z) noexcept {
541553

542554
// static
543555
bool rsOpts::validate_pinc_args(int argc, const char** argv) noexcept {
556+
flush_out(false);
544557
using std::cerr;
545558
if (argc < 1 or !argv)
546559
return false;
@@ -576,12 +589,24 @@ bool rsOpts::validate_pinc_args(int argc, const char** argv) noexcept {
576589
CStr pcf = tmpO.pcfFile_;
577590
if (pcf) {
578591
if (not Fio::regularFileExists(pcf)) {
579-
lprintf("\n[Error] specified PCF file %s does not exist\n", pcf);
580-
cerr << "[Error] specified PCF file does not exist" << endl;
592+
flush_out(true); err_puts();
593+
lprintf2("[Error] specified PCF file does not exist: %s\n", pcf);
594+
err_puts(); flush_out(true);
595+
return false;
596+
}
597+
}
598+
599+
CStr editf = tmpO.editsFile_;
600+
if (editf) {
601+
if (not Fio::regularFileExists(editf)) {
602+
flush_out(true); err_puts();
603+
lprintf2("[Error] specified config_json (--edits) file does not exist: %s\n", editf);
604+
err_puts(); flush_out(true);
581605
return false;
582606
}
583607
}
584608

609+
flush_out(false);
585610
return true;
586611
}
587612

planning/src/RS/rsOpts.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ struct rsOpts {
5454
char* pcfFile_ = nullptr;
5555
char* blifFile_ = nullptr;
5656
char* jsonFile_ = nullptr;
57+
char* editsFile_ = nullptr;
5758

5859
char* input_ = nullptr;
5960
char* output_ = nullptr;

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 = "pln0247";
1+
static const char* _pln_VERSION_STR = "pln0258";
22

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

planning/src/pin_loc/pcf_place.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,11 @@ void PinPlacer::print_summary(const string& csv_name) const {
349349

350350
lprintf(" auto-PCF : %s\n", auto_pcf_created_ ? "TRUE" : "FALSE");
351351
if (!auto_pcf_created_)
352-
lprintf(" user-PCF : %s\n", user_pcf_.c_str());
352+
lprintf(" user-PCF : %s\n", user_pcf_.c_str());
353+
354+
CStr editsVal = has_edits_.empty() ? "FALSE" : has_edits_.c_str();
355+
lprintf(" has edits (config.json) : %s\n", editsVal);
356+
353357
lprintf(" pinc_trace verbosity= %u\n", tr);
354358

355359
if (num_critical_warnings_) {

planning/src/pin_loc/pin_placer.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ void PinPlacer::resetState() noexcept {
164164
pin_names_translated_ = false;
165165
num_warnings_ = 0;
166166
num_critical_warnings_ = 0;
167+
user_pcf_.clear();
168+
has_edits_.clear();
167169
clear_err_code();
168170
}
169171

@@ -304,17 +306,18 @@ bool PinPlacer::read_and_write() {
304306
}
305307

306308
// --4. read netlist edits (--edits option)
307-
bool has_edits = read_edits();
309+
has_edits_ = read_edits();
308310
flush_out(false);
309-
if (tr >= 3)
310-
lprintf("\t has_edits : %i\n", has_edits);
311-
311+
if (tr >= 3) {
312+
CStr val = has_edits_.empty() ? "(FALSE)" : has_edits_.c_str();
313+
lprintf("\t has_edits_ : %s\n", val);
314+
}
312315

313316
// if no user pcf is provided, created a temp one
314317
if (usage_requirement_2 || (usage_requirement_0 && user_pcf_ == "")) {
315318
flush_out(true);
316-
if (has_edits) {
317-
// if auto-PCF and has_edits, translate and de-duplicate
319+
if (has_edits_.size()) {
320+
// if auto-PCF and has_edits_, translate and de-duplicate
318321
// user-design ports now, since edits.json could remove some design ports.
319322
if (not pin_names_translated_)
320323
translatePinNames("(auto-PCF)");
@@ -412,7 +415,7 @@ bool PinPlacer::read_and_write() {
412415
}
413416
}
414417

415-
} // has_edits
418+
} // has_edits_
416419

417420
if (!create_temp_pcf(csv_rd)) {
418421
flush_out(true);

planning/src/pin_loc/pin_placer.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ struct PinPlacer {
114114

115115
bool auto_pcf_created_ = false;
116116
string user_pcf_;
117+
string has_edits_;
117118

118119
public:
119120
enum class PortDir : uint8_t {
@@ -199,7 +200,7 @@ struct PinPlacer {
199200

200201
bool read_csv_file(PcCsvReader&);
201202
bool read_design_ports();
202-
bool read_edits();
203+
string read_edits();
203204
void translate_pcf_cmds();
204205

205206
bool read_pcf(const PcCsvReader&);

planning/src/pin_loc/read_ports.cpp

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,14 @@ bool PinPlacer::read_design_ports() {
177177
return true;
178178
}
179179

180-
bool PinPlacer::read_edits() {
180+
// returns {} on error
181+
string PinPlacer::read_edits() {
181182
flush_out(false);
182183
uint16_t tr = ltrace();
183-
if (tr >= 4) lputs("\nread_edits() __ getting io_config .json");
184+
if (tr >= 4) {
185+
flush_out(true);
186+
lputs("\nread_edits() __ getting io_config .json");
187+
}
184188

185189
all_edits_.clear();
186190
ibufs_.clear();
@@ -189,7 +193,7 @@ bool PinPlacer::read_edits() {
189193
string edits_fn = cl_.get_param("--edits");
190194
if (edits_fn.empty()) {
191195
if (tr >= 4) lputs("[Info] edits cmd option is not specified");
192-
return false;
196+
return {};
193197
}
194198

195199
if (tr >= 4)
@@ -203,7 +207,7 @@ bool PinPlacer::read_edits() {
203207
err_puts();
204208
CERROR << "specified <io edits>.json file does not exist: " << edits_fn << endl;
205209
flush_out(true);
206-
return false;
210+
return {};
207211
}
208212
if (! Fio::nonEmptyFileExists(edits_fn)) {
209213
flush_out(true);
@@ -212,7 +216,7 @@ bool PinPlacer::read_edits() {
212216
err_puts();
213217
CERROR << "specified <io edits>.json file is empty or not accessible: " << edits_fn << endl;
214218
flush_out(true);
215-
return false;
219+
return {};
216220
}
217221

218222
ifstream edits_ifs(edits_fn);
@@ -226,7 +230,7 @@ bool PinPlacer::read_edits() {
226230
err_puts();
227231
OUT_ERROR << " failed reading " << edits_fn << endl;
228232
flush_out(true);
229-
return false;
233+
return {};
230234
}
231235
}
232236
else {
@@ -236,7 +240,7 @@ bool PinPlacer::read_edits() {
236240
CERROR << " could not open <io edits>.json file : " << edits_fn << endl;
237241
err_puts();
238242
flush_out(true);
239-
return false;
243+
return {};
240244
}
241245

242246
bool check_ok = check_edit_info();
@@ -256,7 +260,9 @@ bool PinPlacer::read_edits() {
256260
}
257261

258262
flush_out(false);
259-
return bool(ibufs_.size()) or bool(obufs_.size());
263+
if (ibufs_.size() or obufs_.size())
264+
return edits_fn;
265+
return {};
260266
}
261267

262268
static bool read_json_ports(const nlohmann::ordered_json& from,

0 commit comments

Comments
 (0)