Skip to content

Commit b6ba088

Browse files
authored
Merge pull request #766 from os-fpga/pinc_impr_debug_print_4_translations
pin_c: improved debug print for name translations
2 parents 24ff41b + 19d7ac7 commit b6ba088

File tree

8 files changed

+95
-203
lines changed

8 files changed

+95
-203
lines changed

planning/src/file_readers/blif_reader.cpp

Lines changed: 0 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ namespace pln {
55

66
using std::vector;
77
using std::string;
8-
using std::cerr;
98
using std::endl;
109

1110
bool BlifReader::read_blif(const string& blif_fn) {
@@ -77,132 +76,5 @@ bool BlifReader::read_blif(const string& blif_fn) {
7776
return true;
7877
}
7978

80-
// ========================= OLD ONE:
81-
#ifdef _PLN_OLD_BLIF_READER_MODE
82-
83-
using namespace blifparse;
84-
85-
struct PlnBlifParserCB : public blifparse::Callback {
86-
int lineno_ = -1;
87-
e_circuit_format circuit_format = e_circuit_format::BLIF;
88-
89-
public:
90-
PlnBlifParserCB(e_circuit_format circuit_format_) : circuit_format(circuit_format_) {}
91-
void start_parse() override {}
92-
93-
void filename(string /*fname*/) override {}
94-
void lineno(int /*line_num*/) override {}
95-
96-
void begin_model(string /*model_name*/) override {}
97-
void inputs(vector<string> input_ports) override {
98-
for (auto input_port : input_ports) {
99-
inputs_.push_back(input_port);
100-
}
101-
}
102-
void outputs(vector<string> output_ports) override {
103-
for (auto output_port : output_ports) {
104-
outputs_.push_back(output_port);
105-
}
106-
}
107-
108-
void names(vector<string> /*nets*/, vector<vector<LogicValue>> /*so_cover*/) override {}
109-
void latch(string /*input*/,
110-
string /*output*/,
111-
LatchType /* type*/,
112-
string /*control*/,
113-
LogicValue /*init*/) override {}
114-
void subckt(string /*model*/,
115-
vector<string> /*ports*/,
116-
vector<string> /*nets*/) override {}
117-
void blackbox() override {}
118-
119-
//BLIF Extensions
120-
void conn(string src, string dst) override {
121-
if (circuit_format != e_circuit_format::EBLIF) {
122-
parse_error(lineno_, ".conn", "Supported only in extended BLIF format");
123-
}
124-
}
125-
126-
void cname(string cell_name) override {
127-
if (circuit_format != e_circuit_format::EBLIF) {
128-
parse_error(lineno_, ".cname", "Supported only in extended BLIF format");
129-
}
130-
}
131-
132-
void attr(string name, string value) override {
133-
if (circuit_format != e_circuit_format::EBLIF) {
134-
parse_error(lineno_, ".attr", "Supported only in extended BLIF format");
135-
}
136-
}
137-
138-
void param(string name, string value) override {
139-
if (circuit_format != e_circuit_format::EBLIF) {
140-
parse_error(lineno_, ".param", "Supported only in extended BLIF format");
141-
}
142-
}
143-
144-
void end_model() override {}
145-
146-
void finish_parse() override {}
147-
148-
void parse_error(const int curr_lineno, const string& near_text, const string& msg) override {
149-
fprintf(stderr, "pin_c read_blif: Error at line %d near '%s': %s\n", curr_lineno,
150-
near_text.c_str(), msg.c_str());
151-
lprintf("pin_c read_blif: Error at line %d near '%s': %s\n", curr_lineno,
152-
near_text.c_str(), msg.c_str());
153-
had_error_ = true;
154-
}
155-
156-
public:
157-
bool had_error_ = false;
158-
vector<string> inputs_;
159-
vector<string> outputs_;
160-
};
161-
162-
// read port info from blif file
163-
bool BlifReader::read_blif(const string& blif_fn) {
164-
using namespace fio;
165-
e_circuit_format circuit_format;
166-
auto name_ext = vtr::split_ext(blif_fn);
167-
if (name_ext[1] == ".blif") {
168-
circuit_format = e_circuit_format::BLIF;
169-
} else if (name_ext[1] == ".eblif") {
170-
circuit_format = e_circuit_format::EBLIF;
171-
} else {
172-
lputs("\n[Error] pin_c read_blif: blif-file must have either .blif or .eblif extension");
173-
lprintf(" pin_c read_blif file_name= %s\n", blif_fn.c_str());
174-
cerr << "[Error] pin_c read_blif: blif-file must have either .blif or .eblif extension" << endl;
175-
return false;
176-
}
177-
178-
const char* fn = blif_fn.c_str();
179-
if (not Fio::regularFileExists(fn)) {
180-
lprintf("\n[Error] specified BLIF file %s does not exist\n", fn);
181-
cerr << "[Error] specified BLIF file does not exist: " << fn << endl;
182-
return false;
183-
}
184-
if (not Fio::nonEmptyFileExists(fn)) {
185-
lprintf("\n[Error] specified BLIF file %s is empty\n", fn);
186-
cerr << "[Error] specified BLIF file is empty: " << fn << endl;
187-
return false;
188-
}
189-
190-
PlnBlifParserCB callback(circuit_format);
191-
blif_parse_filename(blif_fn, callback);
192-
if (callback.had_error_) {
193-
return false;
194-
}
195-
196-
std::swap(inputs_, callback.inputs_);
197-
std::swap(outputs_, callback.outputs_);
198-
if (ltrace() >= 4) {
199-
lprintf("pin_c: finished read_blif(). #inputs= %zu #outputs= %zu\n",
200-
inputs_.size(), outputs_.size());
201-
}
202-
return true;
203-
}
204-
205-
#endif // _PLN_OLD_BLIF_READER_MODE
206-
20779
}
20880

planning/src/file_readers/pln_pcf_reader.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ namespace pln {
66
using namespace std;
77
using fio::Fio;
88

9-
bool PcfReader::read_pcf(const string& f) {
9+
bool PcfReader::read_pcf_file(const string& f) {
1010
uint16_t tr = ltrace();
1111
auto& ls = lout();
12-
if (tr >= 2) ls << "PcfReader::read_pcf( " << f << " )" << endl;
12+
flush_out(false);
13+
if (tr >= 2) ls << "PcfReader::read_pcf_file( " << f << " )" << endl;
1314

1415
assert(!f.empty());
1516

@@ -135,13 +136,13 @@ bool PcfReader::read_pcf(const string& f) {
135136
}
136137

137138
if (tr >= 4) {
138-
lprintf("done PcfReader::read_pcf(). commands_.size()= %zu has_error:%i\n",
139+
lprintf("done PcfReader::read_pcf_file(). commands_.size()= %zu has_error:%i\n",
139140
commands_.size(), has_error);
140141
}
141142
if (tr >= 1 && has_error) {
142143
flush_out(true);
143144
err_puts();
144-
lprintf2("[Error] in PcfReader::read_pcf()\n");
145+
lprintf2("[Error] in PcfReader::read_pcf_file()\n");
145146
flush_out(true);
146147
}
147148
flush_out(false);

planning/src/file_readers/pln_pcf_reader.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ struct PcfReader {
3535

3636
PcfReader() noexcept = default;
3737

38-
PcfReader(const string& f) { read_pcf(f); }
38+
PcfReader(const string& f) { read_pcf_file(f); }
3939

40-
bool read_pcf(const string& f);
40+
bool read_pcf_file(const string& f);
4141
};
4242

4343
}

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

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

planning/src/pin_loc/pcf_place.cpp

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -379,13 +379,13 @@ void PinPlacer::printTileUsage(const PcCsvReader& csv) const {
379379
<< " used_tiles_.size()= " << used_tiles_.size() << endl;
380380
}
381381

382-
bool PinPlacer::read_pcf(const PcCsvReader& csv) {
382+
bool PinPlacer::read_PCF(const PcCsvReader& csv) {
383383
flush_out(true);
384384
uint16_t tr = ltrace();
385385
auto& ls = lout();
386386
string cur_dir = get_CWD();
387387
if (tr >= 4) {
388-
lputs("pin_c: PinPlacer::read_pcf()");
388+
lputs("pin_c: PinPlacer::read_PCF()");
389389
lprintf("pin_c: current directory= %s\n", cur_dir.c_str());
390390
}
391391

@@ -407,7 +407,7 @@ bool PinPlacer::read_pcf(const PcCsvReader& csv) {
407407
}
408408

409409
PcfReader rd_pcf;
410-
if (!rd_pcf.read_pcf(pcf_name)) {
410+
if (!rd_pcf.read_pcf_file(pcf_name)) {
411411
flush_out(true);
412412
OUT_ERROR << err_lookup("PIN_CONSTRAINT_PARSE_ERROR") << endl;
413413
CERROR << err_lookup("PIN_CONSTRAINT_PARSE_ERROR") << endl;
@@ -481,64 +481,62 @@ bool PinPlacer::read_pcf(const PcCsvReader& csv) {
481481

482482
if (tr >= 3) {
483483
flush_out(true);
484-
lputs("\t *** pin_c read_pcf SUCCEEDED ***");
484+
lputs("\t *** pin_c read_PCF SUCCEEDED ***");
485485
}
486486

487487
return true;
488488
}
489489

490-
void PinPlacer::translate_pcf_cmds() {
490+
uint PinPlacer::translate_PCF_names() noexcept {
491491
if (pcf_pin_cmds_.empty() or all_edits_.empty())
492-
return;
492+
return 0;
493493

494494
uint16_t tr = ltrace();
495495
flush_out(tr >= 6);
496496

497-
if (1) {
498-
499-
if (tr >= 6) {
500-
lprintf(" ---- pcf_pin_cmds_ before translation (%zu):\n",
501-
pcf_pin_cmds_.size());
502-
for (const auto& cmd : pcf_pin_cmds_)
503-
logVec(cmd.cmd_, " ");
504-
lprintf(" ---- \n");
505-
}
497+
if (tr >= 6) {
498+
lprintf(" ---- pcf_pin_cmds_ before translation (%zu):\n",
499+
pcf_pin_cmds_.size());
500+
for (const auto& cmd : pcf_pin_cmds_)
501+
logVec(cmd.cmd_, " ");
502+
lprintf(" ---- \n");
503+
}
506504

507-
uint numInpTr = 0, numOutTr = 0;
508-
string was;
509-
for (auto& cmd : pcf_pin_cmds_) {
510-
if (cmd.size() < 2)
511-
continue;
512-
string& pinName = cmd.cmd_[1];
513-
was = pinName;
514-
if (findIbufByOldPin(was)) {
515-
// input
516-
pinName = translatePinName(was, true);
517-
if (pinName != was) numInpTr++;
518-
} else if (findObufByOldPin(was)) {
519-
// output
520-
pinName = translatePinName(was, false);
521-
if (pinName != was) numOutTr++;
522-
}
505+
uint numInpTr = 0, numOutTr = 0;
506+
string was;
507+
for (auto& cmd : pcf_pin_cmds_) {
508+
if (cmd.size() < 2)
509+
continue;
510+
string& pinName = cmd.cmd_[1];
511+
was = pinName;
512+
if (findIbufByOldPin(was)) {
513+
// input
514+
pinName = translatePinName(was, true);
515+
if (pinName != was) numInpTr++;
516+
} else if (findObufByOldPin(was)) {
517+
// output
518+
pinName = translatePinName(was, false);
519+
if (pinName != was) numOutTr++;
523520
}
521+
}
524522

525-
flush_out(tr >= 6);
526-
if (tr >= 3) {
527-
lprintf("PCF command translation: #input translations= %u #output translations= %u\n",
528-
numInpTr, numOutTr);
529-
}
523+
flush_out(tr >= 6);
524+
if (tr >= 3) {
525+
lprintf("PCF command translation: #input translations= %u #output translations= %u\n",
526+
numInpTr, numOutTr);
527+
}
530528

531-
if (tr >= 6) {
532-
lprintf(" ++++ pcf_pin_cmds_ after translation (%zu):\n",
533-
pcf_pin_cmds_.size());
534-
for (const auto& cmd : pcf_pin_cmds_)
535-
logVec(cmd.cmd_, " ");
536-
lprintf(" ++++ \n");
537-
flush_out(true);
538-
}
529+
if (tr >= 6) {
530+
lprintf(" ++++ pcf_pin_cmds_ after translation (%zu):\n",
531+
pcf_pin_cmds_.size());
532+
for (const auto& cmd : pcf_pin_cmds_)
533+
logVec(cmd.cmd_, " ");
534+
lprintf(" ++++ \n");
535+
flush_out(true);
539536
}
540537

541538
flush_out(false);
539+
return numInpTr + numOutTr;
542540
}
543541

544542
void PinPlacer::get_pcf_directions(
@@ -1023,10 +1021,12 @@ static bool try_open_csv_file(const string& csv_name) {
10231021
return true;
10241022
}
10251023

1026-
bool PinPlacer::read_csv_file(PcCsvReader& csv) {
1027-
flush_out(false);
1024+
bool PinPlacer::read_PT_CSV(PcCsvReader& csv) {
10281025
uint16_t tr = ltrace();
1029-
if (tr >= 2) lputs("\nread_csv_file() __ Reading csv");
1026+
if (tr >= 2) {
1027+
flush_out(true);
1028+
lputs("read_PT_CSV() __ Reading csv");
1029+
}
10301030

10311031
string csv_name;
10321032
if (temp_csv_file_name_.size()) {
@@ -1061,7 +1061,7 @@ bool PinPlacer::read_csv_file(PcCsvReader& csv) {
10611061

10621062
if (tr >= 2) {
10631063
flush_out(true);
1064-
lputs("\t *** pin_c read_csv_file SUCCEEDED ***\n");
1064+
lputs("\t *** pin_c read_PT_CSV SUCCEEDED ***\n");
10651065
}
10661066

10671067
flush_out(false);
@@ -1127,7 +1127,7 @@ DevPin PinPlacer::get_available_axi_ipin(vector<string>& Q) {
11271127
result.set_first(Q.back());
11281128
Q.pop_back();
11291129

1130-
// need to pick a mode, othewise PcfReader::read_pcf() will not tokenize pcf line properly
1130+
// need to pick a mode, othewise PcfReader will not tokenize pcf line properly
11311131
result.mode_ = "MODE_GPIO";
11321132

11331133
return result;
@@ -1148,7 +1148,7 @@ DevPin PinPlacer::get_available_axi_opin(vector<string>& Q) {
11481148
result.set_first(Q.back());
11491149
Q.pop_back();
11501150

1151-
// need to pick a mode, othewise PcfReader::read_pcf() will not tokenize pcf line properly
1151+
// need to pick a mode, othewise PcfReader will not tokenize pcf line properly
11521152
result.mode_ = "MODE_GPIO";
11531153

11541154
return result;

0 commit comments

Comments
 (0)