Skip to content

Commit b75c238

Browse files
committed
planning: restructured pcf_reader
1 parent d47cc38 commit b75c238

File tree

10 files changed

+160
-172
lines changed

10 files changed

+160
-172
lines changed

planning/src/RS/rsCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ static bool do_check_csv(CStr cfn) {
114114
flush_out(true);
115115

116116
// run CSV reader
117-
RapidCsvReader csv_rd;
117+
PcCsvReader csv_rd;
118118
bool chk_ok = csv_rd.read_csv(string{cfn}, 1000);
119119

120120
flush_out(true);

planning/src/file_readers/pcf_reader.cpp

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
namespace pln {
55

66
using namespace std;
7+
using fio::Fio;
78

89
bool PcfReader::read_pcf(const string& f) {
910
uint16_t tr = ltrace();
@@ -14,8 +15,10 @@ bool PcfReader::read_pcf(const string& f) {
1415

1516
std::ifstream infile(f);
1617
if (!infile.is_open()) {
17-
cerr << "ERROR: could not open the file " << f << endl;
18-
ls << "ERROR: could not open the file " << f << endl;
18+
flush_out(true);
19+
err_puts();
20+
lprintf2("[Error] PCF Reader: could not open the file %s\n", f.c_str());
21+
flush_out(true);
1922
return false;
2023
}
2124

@@ -38,7 +41,7 @@ bool PcfReader::read_pcf(const string& f) {
3841
dat.clear();
3942
row_str.clear();
4043
row_num = -1;
41-
bool split_ok = fio::Fio::split_spa(line.c_str(), dat);
44+
bool split_ok = Fio::split_spa(line.c_str(), dat);
4245
if (split_ok && dat.size() > 2) {
4346
for (uint j = 1; j < dat.size() - 1; j++) {
4447
if (dat[j] == "-pt_row") {
@@ -88,7 +91,8 @@ bool PcfReader::read_pcf(const string& f) {
8891
}
8992

9093
commands_.emplace_back();
91-
vector<string>& cur_command = commands_.back();
94+
Cmd& last = commands_.back();
95+
vector<string>& cur_command = last.cmd_;
9296

9397
cur_command.push_back(set_io_cmd);
9498
cur_command.push_back(user_pin);
@@ -107,35 +111,18 @@ bool PcfReader::read_pcf(const string& f) {
107111
}
108112
}
109113

110-
if (tr >= 2) {
111-
ls << "done PcfReader::read_pcf(). commands_.size()= " << commands_.size()
112-
<< " has_error= " << boolalpha << has_error << endl;
114+
if (tr >= 4) {
115+
lprintf("done PcfReader::read_pcf(). commands_.size()= %zu has_error:%i\n",
116+
commands_.size(), has_error);
113117
}
114-
if (tr >= 1 && has_error)
115-
ls << "\nNOTE error in PcfReader::read_pcf()\n" << endl;
116-
117-
return true;
118-
}
119-
120-
bool PcfReader::read_os_pcf(const string& f) {
121-
std::ifstream infile(f);
122-
if (!infile.is_open()) {
123-
cerr << "ERROR: could not open the file " << f << endl;
124-
return false;
125-
}
126-
string line;
127-
while (std::getline(infile, line)) {
128-
std::istringstream iss(line);
129-
string a, b, c;
130-
if (!(iss >> a >> b >> c)) {
131-
break;
132-
} // error
133-
commands_.push_back(vector<string>());
134-
commands_.back().push_back(a);
135-
commands_.back().push_back(b);
136-
commands_.back().push_back(c);
137-
// pcf_pin_map.insert(std::pair<string, string>(b, c));
118+
if (tr >= 1 && has_error) {
119+
flush_out(true);
120+
err_puts();
121+
lprintf2("[Error] in PcfReader::read_pcf()\n");
122+
flush_out(true);
138123
}
124+
flush_out(false);
125+
139126
return true;
140127
}
141128

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,33 @@
11
#pragma once
22

3-
#include <unordered_map>
4-
#include <map>
5-
63
#include "util/pln_log.h"
74

8-
/*
9-
Supported PCF commands:
10-
11-
* set_io <net> <pad> - constrain a given <net> to a given physical <pad> in
12-
eFPGA pinout.
13-
* set_clk <pin> <net> - constrain a given global clock <pin> to a given <net>
14-
15-
Every tile where <net> is present will be constrained to use a given global
16-
clock.
17-
*/
18-
195
namespace pln {
206

217
using std::string;
228
using std::vector;
239

2410
struct PcfReader {
25-
vector<vector<string>> commands_;
26-
// std::map<string, string> pcf_pin_map;
2711

28-
PcfReader() = default;
12+
struct Cmd {
13+
vector<string> cmd_;
14+
bool hasInternalPin_ = false;
15+
16+
Cmd() noexcept = default;
17+
18+
size_t size() const noexcept { return cmd_.size(); }
19+
};
20+
21+
vector<Cmd> commands_;
22+
23+
PcfReader() noexcept = default;
2924

3025
PcfReader(const string& f) { read_pcf(f); }
3126

3227
bool read_pcf(const string& f);
33-
bool read_os_pcf(const string& f);
34-
35-
const vector<vector<string>>& get_commands() const { return commands_; }
3628

37-
// unordered_map<string, string>& get_pcf_pin_map()const { return pcf_pin_map;
38-
// }
29+
//// const vector<Cmd>& get_commands() const noexcept { return commands_; }
3930
};
4031

41-
} // NS pln
32+
}
4233

0 commit comments

Comments
 (0)