Skip to content

Commit

Permalink
Merge pull request #762 from os-fpga/pinc_trans_clock_debug_print
Browse files Browse the repository at this point in the history
pin_c: translateClockName debug print. EDA-3041
  • Loading branch information
serge-dsa committed Jul 16, 2024
2 parents eacd26a + 3e29c93 commit 4c47317
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 10 deletions.
3 changes: 0 additions & 3 deletions planning/src/RS/rsEnv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,6 @@ void rsEnv::listDevEnv() const noexcept {
#ifdef PINC_DEVEL_MODE
lprintf("\t PINC_DEVEL_MODE :\t (defined)\n");
#endif
#ifdef RSBE_PLANNER_MODE
lprintf("\t RSBE_PLANNER_MODE :\t (defined)\n");
#endif
#ifdef NN_FAST_BUILD
lprintf("\t NN_FAST_BUILD :\t (defined)\n");
#endif
Expand Down
2 changes: 1 addition & 1 deletion planning/src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
static const char* _pln_VERSION_STR = "pln0259";
static const char* _pln_VERSION_STR = "pln0261";

#include "RS/rsEnv.h"
#include "util/pln_log.h"
Expand Down
32 changes: 31 additions & 1 deletion planning/src/pin_loc/map_clocks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,22 @@ int PinPlacer::map_clocks() {
return 1;
}

static bool is_post_edit_clock(CStr cs, size_t len) noexcept {
if (!cs or !cs[0])
return false;
if (len < 18)
return false;
if (cs[0] != '$')
return false;
if (cs[1] != 'a')
return false;

// len("$auto$clkbufmap") == 15
if (::strncmp(cs, "$auto$clkbufmap", 15) == 0)
return true;
return false;
}

int PinPlacer::write_clocks_logical_to_physical() {
flush_out(false);
uint16_t tr = ltrace();
Expand Down Expand Up @@ -183,10 +199,13 @@ int PinPlacer::write_clocks_logical_to_physical() {
udes_clocks.reserve(tokenized_cmds.size());
pdev_clocks.reserve(tokenized_cmds.size());

string uclk, postEdit_uclk;
for (const auto& tcmd : tokenized_cmds) {
uclk.clear();
postEdit_uclk.clear();
assert(tcmd.size() < USHRT_MAX);
uint sz = tcmd.size();
if (tr >= 6) {
if (tr >= 7) {
logVec(tcmd, " tcmd: ");
lprintf("\t tcmd.size()= %u\n", sz);
}
Expand All @@ -201,6 +220,17 @@ int PinPlacer::write_clocks_logical_to_physical() {
}
if (tk == "-design_clock") {
udes_clocks.push_back(tcmd[j + 1]);
uclk = udes_clocks.back();
postEdit_uclk.clear();
CStr cs = uclk.c_str();
bool is_post_edit = is_post_edit_clock(cs, uclk.length());
if (tr >= 6)
lprintf("\t uclk: %s is_post_edit:%i\n", cs, is_post_edit);
if (not is_post_edit) {
postEdit_uclk = translateClockName(uclk);
if (tr >= 6)
lprintf("\t\t ..... postEdit_uclk: %s\n", postEdit_uclk.c_str());
}
j++;
continue;
}
Expand Down
9 changes: 8 additions & 1 deletion planning/src/pin_loc/pin_placer.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ struct PinPlacer {

EditItem() noexcept = default;

CStr c_jsdir() const noexcept { return js_dir_.c_str(); }
CStr cname() const noexcept { return name_.c_str(); }
size_t nameHash() const noexcept { return str::hashf(name_.c_str()); }

CStr c_jsdir() const noexcept { return js_dir_.c_str(); }
CStr c_mod() const noexcept { return module_.c_str(); }
CStr c_old() const noexcept { return oldPin_.c_str(); }
CStr c_new() const noexcept { return newPin_.c_str(); }
Expand Down Expand Up @@ -268,6 +270,11 @@ struct PinPlacer {

string translatePinName(const string& pinName, bool is_input) const noexcept;
uint translatePinNames(const string& memo) noexcept;

string translateClockName(const string& clkName) const noexcept {
assert(not clkName.empty());
return translatePinName(clkName, true);
}
};

}
Expand Down
12 changes: 10 additions & 2 deletions planning/src/pin_loc/read_ports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -639,8 +639,8 @@ void PinPlacer::dump_edits(const string& memo) noexcept {
for (uint i = 0; i < esz; i++) {
const EditItem& ed = all_edits_[i];
lprintf(
" |%u| %s module: %s js_dir:%s dir:%i old: %s new: %s",
i+1, ed.cname(), ed.c_mod(), ed.c_jsdir(), ed.dir_, ed.c_old(), ed.c_new());
" |%u| %zu module: %s js_dir:%s dir:%i old: %s new: %s",
i+1, ed.nameHash(), ed.c_mod(), ed.c_jsdir(), ed.dir_, ed.c_old(), ed.c_new());
if (ed.isQBus())
lprintf(" QBUS-%u", ed.qbusSize());
lputs();
Expand Down Expand Up @@ -861,6 +861,14 @@ void PinPlacer::set_edit_dirs(bool initial) noexcept {
for (uint i = 0; i < sz; i++) {
EditItem& item = all_edits_[i];
assert(item.dir_ == 0);
if (item.js_dir_ == "IN") {
item.dir_ = 1;
continue;
}
if (item.js_dir_ == "OUT") {
item.dir_ = -1;
continue;
}
const string& mod = item.module_;
if (mod == "I_BUF" or mod == "CLK_BUF" or mod == "I_DELAY" or mod == "I_SERDES")
item.dir_ = 1;
Expand Down
10 changes: 8 additions & 2 deletions planning/src/util/pln_log.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,13 @@
#include <memory>
#include <numeric>
#include <string>
#include <string_view>
#include <functional>
#include <stdexcept>
#include <utility>
#include <vector>
#include <array>

#define RSBE_PLANNER_MODE 1

namespace pln {

using CStr = const char*;
Expand Down Expand Up @@ -252,6 +251,13 @@ inline CStr trimFront(CStr z) noexcept {
return z;
}

inline size_t hashf(CStr z) noexcept {
if (!z) return 0;
if (!z[0]) return 1;
std::hash<std::string_view> h;
return h(std::string_view{z});
}

} // NS str

template <typename T>
Expand Down

0 comments on commit 4c47317

Please sign in to comment.