Skip to content

Commit 415d2ce

Browse files
committed
pln/pinc: prepare for fabric eblif (2)
1 parent 0c17906 commit 415d2ce

File tree

5 files changed

+135
-31
lines changed

5 files changed

+135
-31
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 = "pln0191";
1+
static const char* _pln_VERSION_STR = "pln0193";
22

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

stars/src/pin_loc/pcf_place.cpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,50 @@ bool PinPlacer::read_pcf(const RapidCsvReader& csv) {
445445

446446
pcf_pin_cmds_ = std::move(rd_pcf.commands_);
447447

448+
// translate pin-references in cmds_
449+
if (pcf_pin_cmds_.size() and
450+
pin_names_translated_ and is_fabric_eblif_ and all_edits_.size()) {
451+
452+
if (tr >= 6) {
453+
lprintf(" ---- pcf_pin_cmds_ before translation (%zu):\n",
454+
pcf_pin_cmds_.size());
455+
for (const auto& cmd : pcf_pin_cmds_)
456+
logVec(cmd, " ");
457+
lprintf(" ---- \n");
458+
}
459+
460+
uint numInpTr = 0, numOutTr = 0;
461+
string was;
462+
for (auto& cmd : pcf_pin_cmds_) {
463+
if (cmd.size() < 2)
464+
continue;
465+
string& pinName = cmd[1];
466+
was = pinName;
467+
if (findIbufByOldPin(was)) {
468+
// input
469+
pinName = translatePinName(was, true);
470+
if (pinName != was) numInpTr++;
471+
} else if (findObufByOldPin(was)) {
472+
// output
473+
pinName = translatePinName(was, false);
474+
if (pinName != was) numOutTr++;
475+
}
476+
}
477+
478+
if (tr >= 3) {
479+
lprintf("PCF command translation: #input translations= %u #output translations= %u\n",
480+
numInpTr, numOutTr);
481+
}
482+
483+
if (tr >= 6) {
484+
lprintf(" ++++ pcf_pin_cmds_ after translation (%zu):\n",
485+
pcf_pin_cmds_.size());
486+
for (const auto& cmd : pcf_pin_cmds_)
487+
logVec(cmd, " ");
488+
lprintf(" ++++ \n");
489+
}
490+
}
491+
448492
if (tr >= 3) {
449493
flush_out(true);
450494
lputs("\t *** pin_c read_pcf SUCCEEDED ***");

stars/src/pin_loc/pin_placer.cpp

Lines changed: 54 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,7 @@ static string USAGE_MSG_2 =
129129
PinPlacer::PinPlacer(const cmd_line& cl)
130130
: cl_(cl) {
131131
pin_assign_def_order_ = true;
132-
auto_pcf_created_ = false;
133-
min_pt_row_ = UINT_MAX;
134-
max_pt_row_ = 0;
132+
resetState();
135133
}
136134

137135
PinPlacer::~PinPlacer() {
@@ -157,10 +155,22 @@ PinPlacer::~PinPlacer() {
157155
}
158156
}
159157

160-
bool PinPlacer::read_and_write() {
161-
flush_out(false);
158+
void PinPlacer::resetState() noexcept {
159+
auto_pcf_created_ = false;
160+
min_pt_row_ = UINT_MAX;
161+
max_pt_row_ = 0;
162+
no_more_inp_bumps_ = false;
163+
no_more_out_bumps_ = false;
164+
is_fabric_eblif_ = false;
165+
pin_names_translated_ = false;
162166
num_warnings_ = 0;
167+
num_critical_warnings_ = 0;
163168
clear_err_code();
169+
}
170+
171+
bool PinPlacer::read_and_write() {
172+
flush_out(false);
173+
resetState();
164174

165175
string xml_name = cl_.get_param("--xml");
166176
string csv_name = cl_.get_param("--csv");
@@ -307,29 +317,11 @@ bool PinPlacer::read_and_write() {
307317
if (has_edits) {
308318
// if auto-PCF and has_edits, translate and de-duplicate
309319
// user-design ports now, since edits.json could remove some design ports.
310-
for (Pin& pin : user_design_inputs_) {
311-
pin.trans_pin_name_ = translatePinName(pin.udes_pin_name_, true);
312-
if (pin.udes_pin_name_ == pin.trans_pin_name_)
313-
continue;
314-
if (tr >= 3) {
315-
lprintf("design input pin TRANSLATED for auto-PCF: %s --> %s\n",
316-
pin.udes_pin_name_.c_str(), pin.trans_pin_name_.c_str());
317-
}
318-
pin.udes_pin_name_ = pin.trans_pin_name_;
319-
}
320-
flush_out(true);
321-
for (Pin& pin : user_design_outputs_) {
322-
pin.trans_pin_name_ = translatePinName(pin.udes_pin_name_, false);
323-
if (pin.udes_pin_name_ == pin.trans_pin_name_)
324-
continue;
325-
if (tr >= 3) {
326-
lprintf("design output pin TRANSLATED for auto-PCF: %s --> %s\n",
327-
pin.udes_pin_name_.c_str(), pin.trans_pin_name_.c_str());
328-
}
329-
pin.udes_pin_name_ = pin.trans_pin_name_;
330-
}
331-
vector<string> dups;
320+
if (not pin_names_translated_)
321+
translatePinNames("(auto-PCF)");
322+
//
332323
// de-duplicate inputs
324+
vector<string> dups;
333325
if (user_design_inputs_.size() > 1) {
334326
bool done = false;
335327
while (not done) {
@@ -491,5 +483,40 @@ bool PinPlacer::read_and_write() {
491483
return true;
492484
}
493485

486+
uint PinPlacer::translatePinNames(const string& memo) noexcept {
487+
flush_out(false);
488+
uint16_t tr = ltrace();
489+
uint cnt = 0;
490+
CStr mem = memo.c_str();
491+
492+
for (Pin& pin : user_design_inputs_) {
493+
pin.trans_pin_name_ = translatePinName(pin.udes_pin_name_, true);
494+
if (pin.udes_pin_name_ == pin.trans_pin_name_)
495+
continue;
496+
if (tr >= 3) {
497+
lprintf("design input pin TRANSLATED %s: %s --> %s\n", mem,
498+
pin.udes_pin_name_.c_str(), pin.trans_pin_name_.c_str());
499+
}
500+
pin.udes_pin_name_ = pin.trans_pin_name_;
501+
cnt++;
502+
}
503+
504+
flush_out(true);
505+
for (Pin& pin : user_design_outputs_) {
506+
pin.trans_pin_name_ = translatePinName(pin.udes_pin_name_, false);
507+
if (pin.udes_pin_name_ == pin.trans_pin_name_)
508+
continue;
509+
if (tr >= 3) {
510+
lprintf("design output pin TRANSLATED %s: %s --> %s\n", mem,
511+
pin.udes_pin_name_.c_str(), pin.trans_pin_name_.c_str());
512+
}
513+
pin.udes_pin_name_ = pin.trans_pin_name_;
514+
cnt++;
515+
}
516+
517+
pin_names_translated_ = true;
518+
return cnt;
519+
}
520+
494521
} // namespace pln
495522

stars/src/pin_loc/pin_placer.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ struct PinPlacer {
135135

136136
PinPlacer(const cmd_line& cl);
137137
~PinPlacer();
138+
void resetState() noexcept;
138139

139140
bool read_and_write();
140141

@@ -207,6 +208,7 @@ struct PinPlacer {
207208
bool no_more_out_bumps_ = false; //
208209

209210
bool is_fabric_eblif_ = false;
211+
bool pin_names_translated_ = false;
210212

211213
mutable uint num_warnings_ = 0, num_critical_warnings_ = 0;
212214
void incrCriticalWarnings() const noexcept { num_critical_warnings_++; }
@@ -235,6 +237,7 @@ struct PinPlacer {
235237
EditItem* findIbufByOldPin(const string& old_pin) const noexcept;
236238

237239
string translatePinName(const string& pinName, bool is_input) const noexcept;
240+
uint translatePinNames(const string& memo) noexcept;
238241
};
239242

240243
}

stars/src/pin_loc/read_ports.cpp

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ using fio::Fio;
1313
#define CERROR std::cerr << "[Error] "
1414
#define OUT_ERROR lout() << "[Error] "
1515

16-
bool s_is_fabric_eblif(const string& fn) noexcept {
16+
static bool s_is_fabric_eblif(const string& fn) noexcept {
1717
size_t len = fn.length();
1818
if (len < 12 or len > 5000)
1919
return false;
@@ -157,13 +157,13 @@ bool PinPlacer::read_design_ports() {
157157
flush_out(true);
158158

159159
sz = user_design_inputs_.size();
160-
lprintf(" ---- dumping user_design_inputs_ (%zu) ----\n", sz);
160+
lprintf(" ---- dumping user_design_inputs_ (before translation) (%zu) ----\n", sz);
161161
for (uint i = 0; i < sz; i++)
162162
lprintf(" inp-%u %s\n", i, user_design_input(i).c_str());
163163
lprintf(" ----\n");
164164

165165
sz = user_design_outputs_.size();
166-
lprintf(" ---- dumping user_design_outputs_ (%zu) ----\n", sz);
166+
lprintf(" ---- dumping user_design_outputs_ (before translation) (%zu) ----\n", sz);
167167
for (uint i = 0; i < sz; i++)
168168
lprintf(" out-%u %s\n", i, user_design_output(i).c_str());
169169
lprintf(" ----\n");
@@ -173,6 +173,36 @@ bool PinPlacer::read_design_ports() {
173173
raw_design_inputs_.size(), raw_design_outputs_.size());
174174
}
175175

176+
if (1) {
177+
translatePinNames("(read_design_ports)");
178+
179+
if (tr >= 5) {
180+
flush_out(true);
181+
182+
sz = user_design_inputs_.size();
183+
lprintf(" ---- dumping user_design_inputs_ (after translation) (%zu) ----\n", sz);
184+
for (uint i = 0; i < sz; i++) {
185+
const Pin& pin = user_design_inputs_[i];
186+
lprintf(" inp-%u %s (was %s)\n", i,
187+
pin.udes_pin_name_.c_str(), pin.orig_pin_name_.c_str());
188+
}
189+
lprintf(" --------\n");
190+
191+
sz = user_design_outputs_.size();
192+
lprintf(" ---- dumping user_design_outputs_ (after translation) (%zu) ----\n", sz);
193+
for (uint i = 0; i < sz; i++) {
194+
const Pin& pin = user_design_outputs_[i];
195+
lprintf(" out-%u %s (was %s)\n", i,
196+
pin.udes_pin_name_.c_str(), pin.orig_pin_name_.c_str());
197+
}
198+
lprintf(" --------\n");
199+
200+
lprintf(
201+
"DONE read-and-translate-design-ports #udes_inputs= %zu #udes_outputs= %zu\n",
202+
raw_design_inputs_.size(), raw_design_outputs_.size());
203+
}
204+
}
205+
176206
flush_out(true);
177207
return true;
178208
}

0 commit comments

Comments
 (0)