Skip to content

Commit 5eb31d9

Browse files
committed
pin_c: support D-bus reading in config.json, fixes GJC-46
1 parent ccda79b commit 5eb31d9

File tree

3 files changed

+32
-11
lines changed

3 files changed

+32
-11
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 = "pln0211";
1+
static const char* _pln_VERSION_STR = "pln0212";
22

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

stars/src/pin_loc/pin_placer.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ struct PinPlacer {
2727
string mode_; // "Mode_BP_SDR_A_TX"
2828
string oldPin_; // "dout",
2929
string newPin_; // newPin_ is always inside fabric, for both ibuf and obuf
30-
vector<string> Q_bus_;
30+
31+
vector<string> Q_bus_, D_bus_;
3132

3233
int16_t dir_ = 0;
3334

@@ -53,8 +54,11 @@ struct PinPlacer {
5354

5455
bool isInput() const noexcept { return dir_ > 0; }
5556
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(); }
57+
58+
bool isQBus() const noexcept { return Q_bus_.size(); }
59+
uint qbusSize() const noexcept { return Q_bus_.size(); }
60+
bool isDBus() const noexcept { return D_bus_.size(); }
61+
uint dbusSize() const noexcept { return D_bus_.size(); }
5862

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

stars/src/pin_loc/read_ports.cpp

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -526,10 +526,26 @@ static bool s_read_json_items(const nlohmann::ordered_json& from,
526526
last.oldPin_ = propObj["O"];
527527
has_old = true;
528528
}
529+
529530
bool cont_1 = propObj.contains("D");
530531
bool cont_2 = propObj.contains("Q");
531532
if (!has_new and !has_old and cont_1 and cont_2) {
532-
last.newPin_ = propObj["D"];
533+
534+
// read "D", can be array
535+
auto D_obj = propObj["D"];
536+
if (D_obj.is_array()) {
537+
size_t q_sz = D_obj.size();
538+
if (q_sz) {
539+
last.newPin_ = D_obj[0];
540+
last.D_bus_.resize(q_sz);
541+
for (size_t i = 0; i < q_sz; i++)
542+
last.D_bus_[i] = D_obj[i];
543+
}
544+
} else {
545+
last.newPin_ = D_obj;
546+
}
547+
548+
// read "Q", can be array
533549
auto Q_obj = propObj["Q"];
534550
if (Q_obj.is_array()) {
535551
size_t q_sz = Q_obj.size();
@@ -545,6 +561,7 @@ static bool s_read_json_items(const nlohmann::ordered_json& from,
545561
has_new = true;
546562
has_old = true;
547563
}
564+
548565
cont_1 = propObj.contains("I_P");
549566
cont_2 = propObj.contains("O");
550567
if ((!has_new or !has_old) and cont_1 and cont_2) {
@@ -618,8 +635,8 @@ void PinPlacer::dump_edits(const string& memo) noexcept {
618635
lprintf(
619636
" |%u| %s module: %s js_dir:%s dir:%i old: %s new: %s",
620637
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());
638+
if (ed.isQBus())
639+
lprintf(" QBUS-%u", ed.qbusSize());
623640
lputs();
624641
if (!ed.dir_)
625642
undefs.push_back(i);
@@ -630,8 +647,8 @@ void PinPlacer::dump_edits(const string& memo) noexcept {
630647
lprintf(" nm:%s module: %s js_dir:%s dir:%i old: %s new %s R:%i",
631648
ed.cname(), ed.c_mod(), ed.c_jsdir(), ed.dir_,
632649
ed.c_old(), ed.c_new(), ed.isRoot());
633-
if (ed.isBus())
634-
lprintf(" BUS-%u", ed.busSize());
650+
if (ed.isQBus())
651+
lprintf(" QBUS-%u", ed.qbusSize());
635652
lputs();
636653
}
637654
lprintf(" ---- ibufs (%zu) ----\n", ibufs_.size());
@@ -640,8 +657,8 @@ void PinPlacer::dump_edits(const string& memo) noexcept {
640657
lprintf(" nm:%s module: %s js_dir:%s dir:%i old %s new %s R:%i",
641658
ed.cname(), ed.c_mod(), ed.c_jsdir(), ed.dir_,
642659
ed.c_old(), ed.c_new(), ed.isRoot());
643-
if (ed.isBus())
644-
lprintf(" BUS-%u", ed.busSize());
660+
if (ed.isQBus())
661+
lprintf(" QBUS-%u", ed.qbusSize());
645662
lputs();
646663
}
647664
lputs(" ====");

0 commit comments

Comments
 (0)