Skip to content

Commit 332649c

Browse files
authored
Merge pull request #878 from os-fpga/checker_handle_wire_nodes_E3235
checker: handle wire nodes EDA-3235
2 parents c8ea195 + 0296812 commit 332649c

File tree

3 files changed

+58
-6
lines changed

3 files changed

+58
-6
lines changed

planning/src/file_io/pln_blif_file.cpp

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,14 @@ void BLIF_file::BNode::place_output_at_back(vector<string>& dat) noexcept {
187187
}
188188
}
189189

190+
CStr BLIF_file::BNode::cPrimType() const noexcept {
191+
if (is_wire_)
192+
return "WIRE";
193+
if (is_const_)
194+
return "CONST";
195+
return ptype_ == prim::A_ZERO ? "{e}" : pr_enum2str(ptype_);
196+
}
197+
190198
bool BLIF_file::readBlif() noexcept {
191199
inputs_.clear();
192200
outputs_.clear();
@@ -558,7 +566,9 @@ uint BLIF_file::printNodes(std::ostream& os) const noexcept {
558566
os << " #fabricNodes_= " << fabricNodes_.size() << '\n';
559567
os << " #fabricRealNodes_= " << fabricRealNodes_.size() << '\n';
560568
os << " #latches_= " << latches_.size() << '\n';
561-
os << " #constantNodes_= " << constantNodes_.size() << '\n';
569+
os << " #constantNodes_= " << constantNodes_.size()
570+
<< " cnt " << countConstNodes() << '\n';
571+
os << " #wireNodes_= " << countWireNodes() << '\n';
562572
os << endl;
563573

564574
if (trace_ < 4) {
@@ -817,6 +827,36 @@ uint BLIF_file::countCarryNodes() const noexcept {
817827
return cnt;
818828
}
819829

830+
uint BLIF_file::countWireNodes() const noexcept {
831+
uint nn = numNodes();
832+
if (nn == 0)
833+
return 0;
834+
835+
uint cnt = 0;
836+
for (uint i = 1; i <= nn; i++) {
837+
const BNode& nd = nodePool_[i];
838+
if (nd.is_wire_)
839+
cnt++;
840+
}
841+
842+
return cnt;
843+
}
844+
845+
uint BLIF_file::countConstNodes() const noexcept {
846+
uint nn = numNodes();
847+
if (nn == 0)
848+
return 0;
849+
850+
uint cnt = 0;
851+
for (uint i = 1; i <= nn; i++) {
852+
const BNode& nd = nodePool_[i];
853+
if (nd.is_const_)
854+
cnt++;
855+
}
856+
857+
return cnt;
858+
}
859+
820860
uint BLIF_file::printCarryNodes(std::ostream& os) const noexcept {
821861
uint nn = numNodes();
822862
if (!nn) {
@@ -1120,9 +1160,18 @@ bool BLIF_file::createNodes() noexcept {
11201160
if (starts_w_names(cs + 1, len - 1)) {
11211161
Fio::split_spa(lines_[L], V);
11221162
if (V.size() > 1 and V.front() == ".names") {
1163+
//lputs9();
11231164
nodePool_.emplace_back(".names", L);
11241165
BNode& nd = nodePool_.back();
11251166
nd.data_.assign(V.begin() + 1, V.end());
1167+
nd.out_ = nd.data_.back();
1168+
if (V.size() == 2) {
1169+
nd.is_const_ = true;
1170+
} else if (V.size() == 3) {
1171+
nd.is_wire_ = true;
1172+
nd.inSigs_.push_back(V[1]);
1173+
nd.inPins_.push_back("wire_in");
1174+
}
11261175
}
11271176
continue;
11281177
}

planning/src/file_io/pln_blif_file.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ struct BLIF_file : public fio::MMapReader
4646
bool is_mog_ = false;
4747
bool isClockLess_ = false;
4848

49+
bool is_wire_ = false, is_const_ = false; // .names
50+
4951
public:
5052
BNode() noexcept = default;
5153
BNode(CStr keyword, uint L) noexcept : lnum_(L) {
@@ -188,9 +190,7 @@ struct BLIF_file : public fio::MMapReader
188190

189191
CStr cOut() const noexcept { return out_.empty() ? "{e}" : out_.c_str(); }
190192

191-
CStr cPrimType() const noexcept {
192-
return ptype_ == prim::A_ZERO ? "{e}" : pr_enum2str(ptype_);
193-
}
193+
CStr cPrimType() const noexcept;
194194

195195
struct CmpOut {
196196
bool operator()(const BNode* a, const BNode* b) const noexcept {
@@ -284,12 +284,15 @@ struct BLIF_file : public fio::MMapReader
284284
void collectClockedNodes(vector<BNode*>& V) noexcept;
285285
std::array<uint, prim::Prim_MAX_ID> countTypes() const noexcept;
286286

287+
uint countCarryNodes() const noexcept;
288+
uint countWireNodes() const noexcept;
289+
uint countConstNodes() const noexcept;
290+
287291
uint printInputs(std::ostream& os, CStr spacer = nullptr) const noexcept;
288292
uint printOutputs(std::ostream& os, CStr spacer = nullptr) const noexcept;
289293
uint printNodes(std::ostream& os) const noexcept;
290294
uint printPrimitives(std::ostream& os, bool instCounts) const noexcept;
291295

292-
uint countCarryNodes() const noexcept;
293296
uint printCarryNodes(std::ostream& os) const noexcept;
294297

295298
private:

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

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

0 commit comments

Comments
 (0)