Skip to content

Commit eacd26a

Browse files
authored
Merge pull request #761 from os-fpga/pinc_check_and_report_clk_map_arg
pin_c: check and report --clk_map argument
2 parents 83be860 + 284bd05 commit eacd26a

File tree

7 files changed

+35
-5
lines changed

7 files changed

+35
-5
lines changed

planning/src/RS/rsOpts.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ static CStr _xml_[] = {"XM", "xm", "xml", "XML", nullptr};
3030
static CStr _pcf_[] = {"PCF", "pcf", nullptr};
3131

3232
static CStr _edtf_[] = {"EDT", "edit", "edits", nullptr};
33+
static CStr _cmap_[] = {"MAPC", "clkmap", "clk_map", nullptr};
3334

3435
static CStr _blif_[] = {"BL", "blif", nullptr};
3536

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

290291
CStr inp = 0, out = 0, csv = 0, xml = 0, pcf = 0, blif = 0, jsnf = 0,
291-
fun = 0, assignOrd = 0, edtf = 0;
292+
fun = 0, assignOrd = 0, edtf = 0, cmapf = 0;
292293

293294
for (int i = 1; i < argc_; i++) {
294295
CStr arg = argv_[i];
@@ -354,6 +355,14 @@ void rsOpts::parse(int argc, const char** argv) noexcept {
354355
edtf = nullptr;
355356
continue;
356357
}
358+
if (op_match(arg, _cmap_)) {
359+
i++;
360+
if (i < argc_)
361+
cmapf = argv_[i];
362+
else
363+
cmapf = nullptr;
364+
continue;
365+
}
357366
if (op_match(arg, _blif_)) {
358367
i++;
359368
if (i < argc_)
@@ -433,6 +442,7 @@ void rsOpts::parse(int argc, const char** argv) noexcept {
433442
blifFile_ = p_strdup(blif);
434443
jsonFile_ = p_strdup(jsnf);
435444
editsFile_ = p_strdup(edtf);
445+
cmapFile_ = p_strdup(cmapf);
436446

437447
if (fun)
438448
setFunction(fun);
@@ -606,6 +616,16 @@ bool rsOpts::validate_pinc_args(int argc, const char** argv) noexcept {
606616
}
607617
}
608618

619+
CStr cmap = tmpO.cmapFile_;
620+
if (cmap) {
621+
if (not Fio::regularFileExists(cmap)) {
622+
flush_out(true); err_puts();
623+
lprintf2("[Error] specified --clk_map file does not exist: %s\n", cmap);
624+
err_puts(); flush_out(true);
625+
return false;
626+
}
627+
}
628+
609629
flush_out(false);
610630
return true;
611631
}

planning/src/RS/rsOpts.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ struct rsOpts {
5454
char* pcfFile_ = nullptr;
5555
char* blifFile_ = nullptr;
5656
char* jsonFile_ = nullptr;
57+
5758
char* editsFile_ = nullptr;
59+
char* cmapFile_ = nullptr;
5860

5961
char* input_ = nullptr;
6062
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 = "pln0258";
1+
static const char* _pln_VERSION_STR = "pln0259";
22

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

planning/src/pin_loc/map_clocks.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ using fio::Fio;
2525
#define CERROR std::cerr << "[Error] "
2626

2727
int PinPlacer::map_clocks() {
28+
clk_map_file_.clear();
2829
uint16_t tr = ltrace();
2930
if (tr >= 4) {
3031
flush_out(true);
@@ -33,9 +34,9 @@ int PinPlacer::map_clocks() {
3334

3435
string fpga_repack = cl_.get_param("--read_repack");
3536
string user_constrained_repack = cl_.get_param("--write_repack");
36-
string clk_map_file = cl_.get_param("--clk_map");
37+
clk_map_file_ = cl_.get_param("--clk_map");
3738

38-
bool constraint_xml_requested = fpga_repack.size() or clk_map_file.size();
39+
bool constraint_xml_requested = fpga_repack.size() or clk_map_file_.size();
3940
if (not constraint_xml_requested) {
4041
if (tr >= 4)
4142
lputs("PinPlacer::map_clocks() returns NOP");
@@ -65,7 +66,9 @@ int PinPlacer::write_clocks_logical_to_physical() {
6566
}
6667

6768
bool rd_ok = false, wr_ok = false;
68-
string clkmap_fn = cl_.get_param("--clk_map");
69+
70+
clk_map_file_ = cl_.get_param("--clk_map");
71+
const string& clkmap_fn = clk_map_file_;
6972

7073
if (not Fio::regularFileExists(clkmap_fn)) {
7174
flush_out(true);

planning/src/pin_loc/pcf_place.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,9 @@ void PinPlacer::print_summary(const string& csv_name) const {
354354
CStr editsVal = has_edits_.empty() ? "FALSE" : has_edits_.c_str();
355355
lprintf(" has edits (config.json) : %s\n", editsVal);
356356

357+
CStr cmapVal = clk_map_file_.empty() ? "(NONE)" : clk_map_file_.c_str();
358+
lprintf(" clk_map_file : %s\n", cmapVal);
359+
357360
lprintf(" pinc_trace verbosity= %u\n", tr);
358361

359362
if (num_critical_warnings_) {

planning/src/pin_loc/pin_placer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ void PinPlacer::resetState() noexcept {
166166
num_critical_warnings_ = 0;
167167
user_pcf_.clear();
168168
has_edits_.clear();
169+
clk_map_file_.clear();
169170
clear_err_code();
170171
}
171172

planning/src/pin_loc/pin_placer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ struct PinPlacer {
115115
bool auto_pcf_created_ = false;
116116
string user_pcf_;
117117
string has_edits_;
118+
string clk_map_file_;
118119

119120
public:
120121
enum class PortDir : uint8_t {

0 commit comments

Comments
 (0)