Skip to content

Commit 9d64850

Browse files
committed
pin_c: error checking in map_clocks
1 parent 3046d08 commit 9d64850

File tree

2 files changed

+38
-12
lines changed

2 files changed

+38
-12
lines changed

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

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

planning/src/pin_loc/map_clocks.cpp

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ using fio::Fio;
2626

2727
int PinPlacer::map_clocks() {
2828
uint16_t tr = ltrace();
29-
auto& ls = lout();
3029
if (tr >= 4) {
31-
lputs();
30+
flush_out(true);
3231
lputs("PinPlacer::map_clocks()..");
3332
}
3433

@@ -40,6 +39,7 @@ int PinPlacer::map_clocks() {
4039
if (not constraint_xml_requested) {
4140
if (tr >= 4)
4241
lputs("PinPlacer::map_clocks() returns NOP");
42+
flush_out(false);
4343
return 0;
4444
}
4545

@@ -49,11 +49,13 @@ int PinPlacer::map_clocks() {
4949
}
5050

5151
if (tr >= 3)
52-
ls << "PinPlacer::map_clocks() returns OK" << endl;
52+
lputs("PinPlacer::map_clocks() returns OK");
53+
flush_out(false);
5354
return 1;
5455
}
5556

5657
int PinPlacer::write_clocks_logical_to_physical() {
58+
flush_out(false);
5759
uint16_t tr = ltrace();
5860
auto& ls = lout();
5961
string cur_dir = get_CWD();
@@ -66,8 +68,11 @@ int PinPlacer::write_clocks_logical_to_physical() {
6668
string clkmap_fn = cl_.get_param("--clk_map");
6769

6870
if (not Fio::regularFileExists(clkmap_fn)) {
69-
CERROR << " no such file (--clk_map): " << clkmap_fn << endl;
70-
ls << " [Error] no such file (--clk_map): " << clkmap_fn << endl;
71+
flush_out(true);
72+
err_puts();
73+
lprintf2("[Error] no such file (--clk_map): %s\n", clkmap_fn.c_str());
74+
err_puts();
75+
flush_out(true);
7176
return -1;
7277
}
7378

@@ -86,7 +91,7 @@ int PinPlacer::write_clocks_logical_to_physical() {
8691
} else {
8792
ls << "\n pin_c WARNING: --clk_map file is not readable: " << clkmap_fn << endl;
8893
}
89-
ls << endl;
94+
flush_out(true);
9095
}
9196

9297
// read clkmap file
@@ -178,7 +183,7 @@ int PinPlacer::write_clocks_logical_to_physical() {
178183
for (const auto& tcmd : tokenized_cmds) {
179184
assert(tcmd.size() < USHRT_MAX);
180185
uint sz = tcmd.size();
181-
if (tr >= 5) {
186+
if (tr >= 6) {
182187
logVec(tcmd, " tcmd: ");
183188
lprintf("\t tcmd.size()= %u\n", sz);
184189
}
@@ -198,16 +203,36 @@ int PinPlacer::write_clocks_logical_to_physical() {
198203
}
199204
}
200205
}
206+
207+
if (tr >= 3) {
208+
flush_out(true);
209+
lprintf("clock mapping: # user-design clocks = %zu # device clocks = %zu",
210+
udes_clocks.size(), pdev_clocks.size());
211+
}
201212
if (tr >= 4) {
202-
lprintf("\n udes_clocks.size()= %zu pdev_clocks.size()= %zu\n",
213+
flush_out(true);
214+
lprintf(" udes_clocks.size()= %zu pdev_clocks.size()= %zu\n",
203215
udes_clocks.size(), pdev_clocks.size());
216+
flush_out(true);
204217
logVec(udes_clocks, " udes_clocks: ");
218+
flush_out(true);
205219
logVec(pdev_clocks, " pdev_clocks: ");
220+
flush_out(true);
206221
}
207-
assert(udes_clocks.size() == pdev_clocks.size());
222+
208223
if (udes_clocks.empty()) {
209-
CERROR << " no clocks in file (--clk_map): " << clkmap_fn << endl;
210-
ls << " [Error] no clocks in file (--clk_map): " << clkmap_fn << endl;
224+
flush_out(true); err_puts();
225+
lprintf2("[Error] no clocks in file (--clk_map): %s\n", clkmap_fn.c_str());
226+
err_puts(); flush_out(true);
227+
return -1;
228+
}
229+
if (udes_clocks.size() != pdev_clocks.size()) {
230+
flush_out(true); err_puts();
231+
lprintf2("[Error] reading --clk_map file: %s\n", clkmap_fn.c_str());
232+
flush_out(true); err_puts();
233+
lprintf2("[Error] number of user-design clocks (%zu) does not match number of device clocks (%zu)\n",
234+
udes_clocks.size(), pdev_clocks.size());
235+
err_puts(); flush_out(true);
211236
return -1;
212237
}
213238

@@ -293,6 +318,7 @@ int PinPlacer::write_clocks_logical_to_physical() {
293318
if (tr >= 4)
294319
lprintf("pin_c: current directory= %s\n", cur_dir.c_str());
295320

321+
flush_out(false);
296322
return 1;
297323
}
298324

0 commit comments

Comments
 (0)