Skip to content

Commit 75fd3db

Browse files
committed
pin_c: dont translate top-output to input EDA-3040
1 parent 8f76c95 commit 75fd3db

File tree

5 files changed

+102
-20
lines changed

5 files changed

+102
-20
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 = "pln0270";
1+
static const char* _pln_VERSION_STR = "pln0273";
22

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

planning/src/pin_loc/map_clocks.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,15 @@ int PinPlacer::write_clocks_logical_to_physical() {
201201
ls << " in_fn (--read_repack): " << in_fn << endl;
202202
lprintf("pin_c: current directory= %s\n", cur_dir.c_str());
203203
}
204-
if (not Fio::regularFileExists(in_fn)) {
205-
CERROR << " no such file (--read_repack): " << in_fn << endl;
206-
ls << " no such file (--read_repack): " << in_fn << endl;
204+
CStr in_fnc = in_fn.c_str();
205+
if (not Fio::regularFileExists(in_fnc)) {
206+
flush_out(true); err_puts();
207+
CStr m = "specified fpga_repack_constraints.xml (--read_repack) file does not exist";
208+
lprintf2("[Error] %s: %s\n", m, in_fnc);
209+
err_puts(); flush_out(true);
207210
return -1;
208211
}
212+
209213
fio::MMapReader reReader(in_fn);
210214
rd_ok = reReader.read();
211215
if (not rd_ok) {

planning/src/pin_loc/pcf_place.cpp

Lines changed: 65 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -509,19 +509,57 @@ uint PinPlacer::translate_PCF_names() noexcept {
509509
continue;
510510
string& pinName = cmd.cmd_[1];
511511
was = pinName;
512+
bool topInp1 = isTopDesInput(was), topInp2 = false;
513+
bool topOut1 = isTopDesOutput(was), topOut2 = false;
514+
515+
if (tr >= 7) {
516+
flush_out((tr >= 8));
517+
lprintf("\t translating PCF pin '%s'\n", was.c_str());
518+
lprintf("\t\t topInp:%i topOut:%i (%s)\n",
519+
topInp1, topOut1, (topInp1 or topOut1) ? "TOP" : "n");
520+
}
521+
512522
if (findIbufByOldPin(was)) {
513523
// input
514524
pinName = translatePinName(was, true);
515-
if (pinName != was) numInpTr++;
525+
if (pinName != was) {
526+
topInp2 = isTopDesInput(pinName);
527+
topOut2 = isTopDesOutput(pinName);
528+
bool changedSide = (topOut1 and topInp2) or (topInp1 and topOut2);
529+
if (tr >= 7) {
530+
lprintf("\t\t became '%s' topInp:%i topOut:%i (%s)\n",
531+
pinName.c_str(),
532+
topInp2, topOut2, (topInp2 or topOut2) ? "TOP" : "n");
533+
if (changedSide)
534+
lprintf("\t\t\t !!! CHANGED_SIDE !!!\n");
535+
}
536+
numInpTr++;
537+
}
516538
} else if (findObufByOldPin(was)) {
517539
// output
518540
pinName = translatePinName(was, false);
519-
if (pinName != was) numOutTr++;
541+
if (pinName != was) {
542+
topInp2 = isTopDesInput(pinName);
543+
topOut2 = isTopDesOutput(pinName);
544+
bool changedSide = (topOut1 and topInp2) or (topInp1 and topOut2);
545+
if (tr >= 7) {
546+
lprintf("\t\t became '%s' topInp:%i topOut:%i (%s)\n",
547+
pinName.c_str(),
548+
topInp2, topOut2, (topInp2 or topOut2) ? "TOP" : "n");
549+
if (changedSide)
550+
lprintf("\t\t\t !!! CHANGED_SIDE !!!\n");
551+
}
552+
if (changedSide) {
553+
pinName = was; // cancel translation
554+
continue;
555+
}
556+
numOutTr++;
557+
}
520558
}
521559
}
522560

523-
flush_out(tr >= 6);
524561
if (tr >= 3) {
562+
flush_out((tr >= 6));
525563
lprintf("PCF command translation: #input translations= %u #output translations= %u\n",
526564
numInpTr, numOutTr);
527565
}
@@ -664,8 +702,6 @@ bool PinPlacer::write_dot_place(const PcCsvReader& csv) {
664702
string internalPin;
665703
vector<uint> gbox_rows;
666704

667-
string udes_pn2; // translated according to --edits <config.json>
668-
669705
string row_str;
670706
int row_num = -1;
671707

@@ -676,24 +712,33 @@ bool PinPlacer::write_dot_place(const PcCsvReader& csv) {
676712

677713
const PcfReader::Cmd& cmdObj = *P[cmd_i];
678714
const vector<string>& pcf_cmd = cmdObj.cmd_;
715+
const string& op_code = pcf_cmd[0];
679716

680717
// only support io and clock for now
681-
if (pcf_cmd[0] != "set_io" && pcf_cmd[0] != "set_clk") continue;
718+
if (op_code != "set_io" && op_code != "set_clk") {
719+
if (tr >= 4) {
720+
lprintf("\t ignoring PCF cmd op_code= %s only {set_io, set_clk} are used\n",
721+
op_code.c_str());
722+
}
723+
continue;
724+
}
682725

683726
const string& udes_pn1 = pcf_cmd[1];
727+
const string& udes_pn2 = udes_pn1;
684728

685729
bool is_in_pin = (find_udes_input(udes_pn1) >= 0);
686730

687731
bool is_out_pin =
688732
is_in_pin ? false : (find_udes_output(udes_pn1) >= 0);
689733

690-
udes_pn2 = translatePinName(udes_pn1, is_in_pin);
691-
if (udes_pn2 != udes_pn1) {
692-
if (tr >= 3) {
693-
lprintf(" %s pin TRANSLATED: %s --> %s\n",
694-
is_in_pin ? "input" : "output", udes_pn1.c_str(), udes_pn2.c_str());
695-
}
696-
}
734+
////// OBSOLETE CODE: translation is done in translate_PCF_names()
735+
// udes_pn2 = translatePinName(udes_pn1, is_in_pin);
736+
// if (udes_pn2 != udes_pn1) {
737+
// if (tr >= 3) {
738+
// lprintf(" %s pin TRANSLATED: %s --> %s\n",
739+
// is_in_pin ? "input" : "output", udes_pn1.c_str(), udes_pn2.c_str());
740+
// }
741+
// }
697742

698743
const string& udes_pin_name = udes_pn2;
699744
const string& device_pin_name = pcf_cmd[2]; // bump or ball
@@ -721,9 +766,16 @@ bool PinPlacer::write_dot_place(const PcCsvReader& csv) {
721766

722767
flush_out(true);
723768
flush_out(true);
769+
err_puts();
724770
CERROR << err_lookup("CONSTRAINED_PORT_NOT_FOUND") << ": <"
725771
<< udes_pin_name << ">" << endl;
772+
err_puts();
773+
flush_out(true);
774+
lprintf("[Error] === user-design top-port not found: %s\n", udes_pin_name.c_str());
726775
flush_out(true);
776+
// if (tr >= 6) { // dump all design ports for diagnostics
777+
// flush_out(true);
778+
// }
727779

728780
out_file << "\n=== Error happened, .place file is incomplete\n"
729781
<< "=== ERROR:" << err_lookup("CONSTRAINED_PORT_NOT_FOUND")

planning/src/pin_loc/pin_placer.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class PcCsvReader;
1616

1717
using std::string;
1818
using std::vector;
19+
using std::unordered_set;
1920
using StringPair = std::pair<std::string, std::string>;
2021

2122
struct PinPlacer {
@@ -96,6 +97,7 @@ struct PinPlacer {
9697

9798
vector<string> raw_design_inputs_;
9899
vector<string> raw_design_outputs_;
100+
unordered_set<string> raw_inputSet_, raw_outputSet_;
99101

100102
vector<Pin> user_design_inputs_;
101103
vector<Pin> user_design_outputs_;
@@ -112,7 +114,7 @@ struct PinPlacer {
112114
std::set<XY> used_XYs_;
113115
std::set<XYZ> used_oxyz_; // used output XYZ
114116
std::set<XYZ> used_ixyz_; // used input XYZ
115-
std::unordered_set<uint> used_tiles_;
117+
unordered_set<uint> used_tiles_;
116118

117119
uint otile_overlap_level_ = 1, itile_overlap_level_ = 1;
118120

@@ -210,6 +212,17 @@ struct PinPlacer {
210212
return -1;
211213
}
212214

215+
bool isTopDesInput(const string& pinName) const noexcept {
216+
assert(!pinName.empty());
217+
assert(raw_inputSet_.size() == raw_design_inputs_.size());
218+
return raw_inputSet_.count(pinName);
219+
}
220+
bool isTopDesOutput(const string& pinName) const noexcept {
221+
assert(!pinName.empty());
222+
assert(raw_outputSet_.size() == raw_design_outputs_.size());
223+
return raw_outputSet_.count(pinName);
224+
}
225+
213226
bool read_PT_CSV(PcCsvReader&);
214227
bool read_design_ports();
215228
string read_edits();

planning/src/pin_loc/read_ports.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,22 @@ bool PinPlacer::read_design_ports() {
136136
size_t sz = raw_design_inputs_.size();
137137
user_design_inputs_.clear();
138138
user_design_inputs_.resize(sz);
139-
for (size_t i = 0; i < sz; i++)
139+
raw_inputSet_.clear();
140+
raw_inputSet_.reserve(2*sz + 1);
141+
for (size_t i = 0; i < sz; i++) {
140142
user_design_inputs_[i].set_udes_pin_name(raw_design_inputs_[i]);
143+
}
144+
raw_inputSet_.insert( raw_design_inputs_.cbegin(), raw_design_inputs_.cend() );
141145

142146
sz = raw_design_outputs_.size();
143147
user_design_outputs_.clear();
144148
user_design_outputs_.resize(sz);
145-
for (size_t i = 0; i < sz; i++)
149+
raw_outputSet_.clear();
150+
raw_outputSet_.reserve(2*sz + 1);
151+
for (size_t i = 0; i < sz; i++) {
146152
user_design_outputs_[i].set_udes_pin_name(raw_design_outputs_[i]);
153+
}
154+
raw_outputSet_.insert( raw_design_outputs_.cbegin(), raw_design_outputs_.cend() );
147155

148156
if (tr >= 3) {
149157
flush_out(tr >= 5);
@@ -1042,6 +1050,7 @@ PinPlacer::EditItem* PinPlacer::findIbufByOldPin(const string& old_pin) const no
10421050

10431051
string PinPlacer::translatePinName(const string& pinName, bool is_input) const noexcept {
10441052
assert(not pinName.empty());
1053+
10451054
if (is_input) {
10461055
EditItem* buf = findIbufByOldPin(pinName);
10471056
if (buf) {
@@ -1061,6 +1070,10 @@ string PinPlacer::translatePinName(const string& pinName, bool is_input) const n
10611070
EditItem* root = buf->getRoot();
10621071
assert(root);
10631072
assert(not root->newPin_.empty());
1073+
if (isTopDesInput(root->newPin_)) {
1074+
// never translate an output to top-input. EDA-3040
1075+
return pinName;
1076+
}
10641077
return root->newPin_;
10651078
} else {
10661079
return pinName;

0 commit comments

Comments
 (0)