Skip to content

Commit 9a94145

Browse files
committed
pin_c: developing Q-bus support in config.json
1 parent ad47b96 commit 9a94145

File tree

3 files changed

+44
-18
lines changed

3 files changed

+44
-18
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 = "pln0208";
1+
static const char* _pln_VERSION_STR = "pln0211";
22

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

stars/src/pin_loc/pin_placer.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@ struct PinPlacer {
2222
struct EditItem {
2323
string name_; // "$iopadmap$flop2flop.dout"
2424
string module_; // "O_BUF"
25+
string js_dir_; // "OUT", "IN"
2526
string location_; // "HR_5_0_0P"
2627
string mode_; // "Mode_BP_SDR_A_TX"
2728
string oldPin_; // "dout",
28-
string newPin_; // "$iopadmap$dout"
29-
// newPin_ is always inside fabric, for both ibuf and obuf
29+
string newPin_; // newPin_ is always inside fabric, for both ibuf and obuf
30+
vector<string> Q_bus_;
3031

3132
int16_t dir_ = 0;
3233

@@ -44,9 +45,16 @@ struct PinPlacer {
4445

4546
EditItem() noexcept = default;
4647

48+
CStr c_jsdir() const noexcept { return js_dir_.c_str(); }
4749
CStr cname() const noexcept { return name_.c_str(); }
50+
CStr c_mod() const noexcept { return module_.c_str(); }
51+
CStr c_old() const noexcept { return oldPin_.c_str(); }
52+
CStr c_new() const noexcept { return newPin_.c_str(); }
53+
4854
bool isInput() const noexcept { return dir_ > 0; }
4955
bool isOutput() const noexcept { return dir_ < 0; }
56+
bool isBus() const noexcept { return Q_bus_.size(); }
57+
uint busSize() const noexcept { return Q_bus_.size(); }
5058

5159
bool hasPins() const noexcept { return !oldPin_.empty() and !newPin_.empty(); }
5260
void swapPins() noexcept { std::swap(oldPin_, newPin_); }

stars/src/pin_loc/read_ports.cpp

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -489,10 +489,13 @@ static bool s_read_json_items(const nlohmann::ordered_json& from,
489489
PinPlacer::EditItem& last = items.back();
490490
last.name_ = obj["name"];
491491

492-
// 3. read 'module'
492+
// 3. read 'module' and 'js_dir'
493493
if (obj.contains("module")) {
494494
last.module_ = obj["module"];
495495
}
496+
if (obj.contains("direction")) {
497+
last.js_dir_ = obj["direction"];
498+
}
496499

497500
if (tr >= 6) {
498501
ls << "rd_js_items --- .name_= " << last.name_
@@ -528,10 +531,17 @@ static bool s_read_json_items(const nlohmann::ordered_json& from,
528531
if (!has_new and !has_old and cont_1 and cont_2) {
529532
last.newPin_ = propObj["D"];
530533
auto Q_obj = propObj["Q"];
531-
if (Q_obj.is_array())
532-
last.oldPin_ = Q_obj[0];
533-
else
534+
if (Q_obj.is_array()) {
535+
size_t q_sz = Q_obj.size();
536+
if (q_sz) {
537+
last.oldPin_ = Q_obj[0];
538+
last.Q_bus_.resize(q_sz);
539+
for (size_t i = 0; i < q_sz; i++)
540+
last.Q_bus_[i] = Q_obj[i];
541+
}
542+
} else {
534543
last.oldPin_ = Q_obj;
544+
}
535545
has_new = true;
536546
has_old = true;
537547
}
@@ -606,34 +616,42 @@ void PinPlacer::dump_edits(const string& memo) noexcept {
606616
for (uint i = 0; i < esz; i++) {
607617
const EditItem& ed = all_edits_[i];
608618
lprintf(
609-
" |%u| name_:%s mode_:%s dir:%i old: %s new: %s\n",
610-
i+1, ed.cname(), ed.mode_.c_str(),
611-
ed.dir_, ed.oldPin_.c_str(), ed.newPin_.c_str());
619+
" |%u| %s module: %s js_dir:%s dir:%i old: %s new: %s",
620+
i+1, ed.cname(), ed.c_mod(), ed.c_jsdir(), ed.dir_, ed.c_old(), ed.c_new());
621+
if (ed.isBus())
622+
lprintf(" BUS-%u", ed.busSize());
623+
lputs();
612624
if (!ed.dir_)
613625
undefs.push_back(i);
614626
}
615627
lprintf(" ---- obufs (%zu) ----\n", obufs_.size());
616628
for (const EditItem* e : obufs_SortedByOld_) {
617629
const EditItem& ed = *e;
618-
lprintf(" name_:%s dir:%i old: %s new %s R:%i\n",
619-
ed.cname(), ed.dir_,
620-
ed.oldPin_.c_str(), ed.newPin_.c_str(), ed.isRoot());
630+
lprintf(" nm:%s module: %s js_dir:%s dir:%i old: %s new %s R:%i",
631+
ed.cname(), ed.c_mod(), ed.c_jsdir(), ed.dir_,
632+
ed.c_old(), ed.c_new(), ed.isRoot());
633+
if (ed.isBus())
634+
lprintf(" BUS-%u", ed.busSize());
635+
lputs();
621636
}
622637
lprintf(" ---- ibufs (%zu) ----\n", ibufs_.size());
623638
for (const EditItem* e : ibufs_SortedByOld_) {
624639
const EditItem& ed = *e;
625-
lprintf(" name_:%s dir:%i old %s new %s R:%i\n",
626-
ed.cname(), ed.dir_,
627-
ed.oldPin_.c_str(), ed.newPin_.c_str(), ed.isRoot());
640+
lprintf(" nm:%s module: %s js_dir:%s dir:%i old %s new %s R:%i",
641+
ed.cname(), ed.c_mod(), ed.c_jsdir(), ed.dir_,
642+
ed.c_old(), ed.c_new(), ed.isRoot());
643+
if (ed.isBus())
644+
lprintf(" BUS-%u", ed.busSize());
645+
lputs();
628646
}
629647
lputs(" ====");
630648
if (! undefs.empty()) {
631649
lprintf(" >>>==== NOTE undefs (%zu) ====\n", undefs.size());
632650
for (uint u : undefs) {
633651
const EditItem& ed = all_edits_[u];
634652
lprintf(
635-
" |u#%u| name_:%s old: %s new: %s\n",
636-
u, ed.cname(), ed.oldPin_.c_str(), ed.newPin_.c_str());
653+
" |u#%u| nm:%s module: %s js_dir:%s old: %s new: %s\n",
654+
u, ed.cname(), ed.c_mod(), ed.c_jsdir(), ed.c_old(), ed.c_new());
637655
}
638656
}
639657
lputs(" ====");

0 commit comments

Comments
 (0)