Skip to content

Commit 065b5c4

Browse files
authored
Merge pull request #906 from os-fpga/checker_handle_disabled_RAM_clock_inputs_E3235
checker: handle disabled RAM clock-inputs EDA-3235
2 parents 409e4a4 + 7751dfd commit 065b5c4

File tree

4 files changed

+83
-5
lines changed

4 files changed

+83
-5
lines changed

planning/src/RS/rsCheck.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ bool do_check_blif(CStr cfn,
125125
if (numWarn)
126126
lprintf(" # WARNINGS= %u", numWarn);
127127
lputs();
128-
if (numWarn or ::getenv("pln_always_write_blif")) {
128+
if (0&& (numWarn or ::getenv("pln_always_write_blif"))) {
129129
std::filesystem::path full_path{bfile.fnm_};
130130
std::filesystem::path base_path = full_path.filename();
131131
std::string base = base_path.string();
@@ -221,9 +221,13 @@ bool do_cleanup_blif(CStr cfn, vector<uspair>& corrected) {
221221

222222
// -- 1. add prefix 'orig_' to the original BLIF
223223
{
224-
string newName = str::concat("orig_", cfn);
225-
filesystem::path newPath{newName};
224+
// string newName = str::concat("orig_", cfn);
226225
filesystem::path oldPath{cfn};
226+
filesystem::path newPath = oldPath.lexically_normal();
227+
assert(newPath.has_filename());
228+
string path_fn = newPath.filename().string();
229+
string new_fn = str::concat("orig_", path_fn);
230+
newPath.replace_filename(new_fn);
227231
error_code ec;
228232
filesystem::rename(oldPath, newPath, ec);
229233
if (ec) {
@@ -234,6 +238,7 @@ bool do_cleanup_blif(CStr cfn, vector<uspair>& corrected) {
234238
<< " ERROR: " << ec.message() << '\n' << endl;
235239
}
236240
else if (tr >= 3) {
241+
string newName = newPath.string();
237242
lprintf("[PLANNER BLIF-CLEANER] : original BLIF saved as '%s'\n",
238243
newName.c_str());
239244
}

planning/src/file_io/pln_blif_file.cpp

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1506,6 +1506,55 @@ bool BLIF_file::createNodes() noexcept {
15061506
nd.id_ = i;
15071507
}
15081508

1509+
// possibly adjust "clockness" flag of some RAM18KX2 clock inputs.
1510+
// RAM18KX2 instances may have unused halves with clock inputs
1511+
// (CLK_A1/2, CLK_B1/2) connected to $false.
1512+
// This seems to be allowed. EDA-3235.
1513+
uint RAM18KX2_cnt_total = 0, RAM18KX2_cnt_disabled = 0;
1514+
for (BNode* x : fabricRealNodes_) {
1515+
BNode& nd = *x;
1516+
assert(not nd.isTopPort());
1517+
assert(not nd.isVirtualMog());
1518+
if (nd.ptype_ != prim::TDP_RAM18KX2)
1519+
continue;
1520+
RAM18KX2_cnt_total++;
1521+
if (trace_ >= 5) {
1522+
lprintf("\nRAM18KX2 instance #%u L=%u dat_sz= %zu\n",
1523+
nd.id_, nd.lnum_, nd.realData_.size());
1524+
if (trace_ >= 6)
1525+
logVec(nd.realData_, " dat ");
1526+
}
1527+
for (const string& term : nd.realData_) {
1528+
if (term == "CLK_A1=$false") {
1529+
nd.disabledClocks_.emplace_back("CLK_A1");
1530+
continue;
1531+
}
1532+
if (term == "CLK_B1=$false") {
1533+
nd.disabledClocks_.emplace_back("CLK_B1");
1534+
continue;
1535+
}
1536+
if (term == "CLK_A2=$false") {
1537+
nd.disabledClocks_.emplace_back("CLK_A2");
1538+
continue;
1539+
}
1540+
if (term == "CLK_B2=$false") {
1541+
nd.disabledClocks_.emplace_back("CLK_B2");
1542+
}
1543+
}
1544+
if (not nd.disabledClocks_.empty())
1545+
RAM18KX2_cnt_disabled++;
1546+
}
1547+
1548+
if (trace_ >= 4) {
1549+
lprintf("DONE BLIF_file::createNodes()");
1550+
lprintf(" total #RAM18KX2 instances = %u", RAM18KX2_cnt_total);
1551+
if (RAM18KX2_cnt_total) {
1552+
lprintf(" #RAM18KX2 instances w disabled clocks = %u",
1553+
RAM18KX2_cnt_disabled);
1554+
}
1555+
flush_out(true);
1556+
}
1557+
15091558
return true;
15101559
}
15111560

@@ -2117,7 +2166,8 @@ bool BLIF_file::createPinGraph() noexcept {
21172166
pr_get_inputs(par.ptype_, INP);
21182167

21192168
const string& pinName = par.getInPin(pinIndex);
2120-
bool is_clock = pr_pin_is_clock(par.ptype_, pinName);
2169+
bool is_clock = pr_pin_is_clock(par.ptype_, pinName)
2170+
and not par.isDisabledClock(pinName, *this);
21212171

21222172
if (trace_ >= 5) {
21232173
lprintf(" FabricParent par: lnum_= %u kw_= %s ptype_= %s pin[%u nm= %s%s]\n",
@@ -2218,6 +2268,12 @@ bool BLIF_file::createPinGraph() noexcept {
22182268
assert(not inp.empty());
22192269
if (not pr_pin_is_clock(cn.ptype_, inp))
22202270
continue;
2271+
if (cn.isDisabledClock(inp, *this)) {
2272+
if (trace_ >= 6)
2273+
lprintf(" createPinGraph: skipping disabled clock-input-pin %s\n",
2274+
inp.c_str());
2275+
continue;
2276+
}
22212277

22222278
uint cn_realId = cn.realId(*this);
22232279
key = hashCantor(cn_realId, i + 1) + max_key1;

planning/src/file_io/pln_blif_file.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ struct BLIF_file : public fio::MMapReader
5555
vector<string> inPins_; // input pins from Prim-DB
5656
vector<string> inSigs_; // input signals from blif-file
5757

58+
vector<string> disabledClocks_; // clock input pins of RAM18KX2 that are connected to $false
59+
// and should not participate in pinGraph
60+
5861
string out_; // SOG output net (=signal) (real or virtual)
5962

6063
uint virtualOrigin_ = 0; // node-ID from which this virtual MOG is created
@@ -215,6 +218,20 @@ struct BLIF_file : public fio::MMapReader
215218

216219
bool isDanglingTerm(uint term) const noexcept;
217220

221+
bool isDisabledClock(const string& pinName, const BLIF_file& bf) const noexcept {
222+
assert(not pinName.empty());
223+
if (pinName.empty())
224+
return false;
225+
if (ptype_ != prim::TDP_RAM18KX2)
226+
return false;
227+
const BNode* base = isVirtualMog() ? &bf.bnodeRef(virtualOrigin_) : this;
228+
for (const string& x : base->disabledClocks_) {
229+
if (x == pinName)
230+
return true;
231+
}
232+
return false;
233+
}
234+
218235
struct CmpOut {
219236
bool operator()(const BNode* a, const BNode* b) const noexcept {
220237
return a->out_ < b->out_;

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 = "pln0359";
1+
static const char* _pln_VERSION_STR = "pln0360";
22

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

0 commit comments

Comments
 (0)