Skip to content

Commit 0c17906

Browse files
authored
Merge pull request #683 from os-fpga/pln_pinc_prep_to_read_fabric_eblif_1
pln/pinc: prepare to read fabric_.eblif
2 parents 174a7d1 + a052a36 commit 0c17906

File tree

5 files changed

+55
-8
lines changed

5 files changed

+55
-8
lines changed

stars/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 = "pln0189";
1+
static const char* _pln_VERSION_STR = "pln0191";
22

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

stars/src/pin_loc/pin.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ struct Pin {
1616

1717
static constexpr uint MAX_PT_COLS = 128;
1818

19-
string udes_pin_name_;
19+
string orig_pin_name_; // never translated
20+
string udes_pin_name_; // maybe translated
2021
string trans_pin_name_; // translated due to netlist edits
2122

2223
string device_pin_name_;
@@ -42,13 +43,19 @@ struct Pin {
4243
}
4344

4445
Pin(const string& u, const string& d, const XYZ& xyz, uint r) noexcept
45-
: udes_pin_name_(u), device_pin_name_(d),
46+
: orig_pin_name_(u), udes_pin_name_(u),
47+
device_pin_name_(d),
4648
xyz_(xyz), pt_row_(r) {
4749
rx_modes_.reset();
4850
tx_modes_.reset();
4951
all_modes_.reset();
5052
}
5153

54+
void set_udes_pin_name(const string& pn) noexcept {
55+
orig_pin_name_ = pn;
56+
udes_pin_name_ = pn;
57+
}
58+
5259
bool is_translated() const noexcept {
5360
if (trans_pin_name_.empty())
5461
return false;
@@ -59,6 +66,7 @@ struct Pin {
5966
rx_modes_.reset();
6067
tx_modes_.reset();
6168
all_modes_.reset();
69+
orig_pin_name_.clear();
6270
udes_pin_name_.clear();
6371
trans_pin_name_.clear();
6472
device_pin_name_.clear();

stars/src/pin_loc/pin_placer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ bool PinPlacer::read_and_write() {
227227
!(csv_name.empty() || no_b_json || output_name.empty()) &&
228228
user_pcf_.empty();
229229

230-
if (tr >= 2) {
230+
if (tr >= 4) {
231231
ls << "\t usage_requirement_1 : " << boolalpha << usage_requirement_1 << endl;
232232
ls << "\t usage_requirement_2 : " << boolalpha << usage_requirement_2 << endl;
233233
}

stars/src/pin_loc/pin_placer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,8 @@ struct PinPlacer {
206206
bool no_more_inp_bumps_ = false; // state for get_available_device_pin()
207207
bool no_more_out_bumps_ = false; //
208208

209+
bool is_fabric_eblif_ = false;
210+
209211
mutable uint num_warnings_ = 0, num_critical_warnings_ = 0;
210212
void incrCriticalWarnings() const noexcept { num_critical_warnings_++; }
211213

stars/src/pin_loc/read_ports.cpp

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,36 @@ using namespace std;
1111
using fio::Fio;
1212

1313
#define CERROR std::cerr << "[Error] "
14-
#define OUT_ERROR std::cout << "[Error] "
14+
#define OUT_ERROR lout() << "[Error] "
15+
16+
bool s_is_fabric_eblif(const string& fn) noexcept {
17+
size_t len = fn.length();
18+
if (len < 12 or len > 5000)
19+
return false;
20+
char buf[len + 2] = {};
21+
::strcpy(buf, fn.c_str());
22+
23+
// replace '/' and '.' by spaces to use space-based tokenizer
24+
for (char* p = buf; *p; p++) {
25+
if (*p == '/' or *p == '.')
26+
*p = ' ';
27+
}
28+
29+
vector<string> W;
30+
Fio::split_spa(buf, W);
31+
if (W.size() < 2)
32+
return false;
33+
if (W.back() != "eblif")
34+
return false;
35+
36+
const string& f = W[W.size() - 2];
37+
if (f.length() < 7)
38+
return false;
39+
CStr s = f.c_str();
40+
41+
return s[0] == 'f' and s[1] == 'a' and s[2] == 'b' and
42+
s[3] == 'r' and s[4] == 'i' and s[5] == 'c' and s[6] == '_';
43+
}
1544

1645
bool PinPlacer::read_design_ports() {
1746
uint16_t tr = ltrace();
@@ -48,7 +77,7 @@ bool PinPlacer::read_design_ports() {
4877
}
4978
}
5079
} else {
51-
if (tr >= 1) lprintf("port_info cmd option not specified => using blif\n");
80+
if (tr >= 4) lprintf("port_info cmd option not specified => using blif\n");
5281
}
5382

5483
if (json_ifs.is_open()) {
@@ -80,7 +109,11 @@ bool PinPlacer::read_design_ports() {
80109
}
81110
BlifReader rd_blif;
82111
if (!rd_blif.read_blif(blif_fn)) {
112+
flush_out(true);
113+
err_puts();
83114
CERROR << err_lookup("PORT_INFO_PARSE_ERROR") << endl;
115+
OUT_ERROR << err_lookup("PORT_INFO_PARSE_ERROR") << endl;
116+
flush_out(true);
84117
return false;
85118
}
86119
raw_design_inputs_ = rd_blif.get_inputs();
@@ -95,25 +128,29 @@ bool PinPlacer::read_design_ports() {
95128
err_puts();
96129
return false;
97130
}
131+
132+
is_fabric_eblif_ = s_is_fabric_eblif(blif_fn);
98133
}
99134

100135
size_t sz = raw_design_inputs_.size();
101136
user_design_inputs_.clear();
102137
user_design_inputs_.resize(sz);
103138
for (size_t i = 0; i < sz; i++)
104-
user_design_inputs_[i].udes_pin_name_ = raw_design_inputs_[i];
139+
user_design_inputs_[i].set_udes_pin_name(raw_design_inputs_[i]);
105140

106141
sz = raw_design_outputs_.size();
107142
user_design_outputs_.clear();
108143
user_design_outputs_.resize(sz);
109144
for (size_t i = 0; i < sz; i++)
110-
user_design_outputs_[i].udes_pin_name_ = raw_design_outputs_[i];
145+
user_design_outputs_[i].set_udes_pin_name(raw_design_outputs_[i]);
111146

112147
if (tr >= 3) {
113148
flush_out(tr >= 5);
114149
lprintf(
115150
"DONE read_design_ports() #udes_inputs= %zu #udes_outputs= %zu\n",
116151
raw_design_inputs_.size(), raw_design_outputs_.size());
152+
if (tr >= 4)
153+
lprintf("is_fabric_eblif_: %s\n", is_fabric_eblif_ ? "TRUE" : "FALSE");
117154
}
118155

119156
if (tr >= 5) {

0 commit comments

Comments
 (0)