Skip to content

Commit 47cdddd

Browse files
committed
checker: report stats about clocked instances
1 parent 8da26af commit 47cdddd

File tree

4 files changed

+65
-15
lines changed

4 files changed

+65
-15
lines changed

planning/src/RS/rsCheck.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ bool do_check(const rsOpts& opts, bool blif_vs_csv) {
154154
CStr fileType = blif_vs_csv ? "BLIF" : "CSV";
155155
CStr cfn = blif_vs_csv ? opts.input_ : opts.csvFile_;
156156
assert(cfn);
157+
flush_out(true);
157158
lprintf(" checking %s file: %s\n", fileType, cfn);
158159

159160
bool status;

planning/src/file_readers/pln_blif_file.cpp

Lines changed: 60 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ bool BLIF_file::checkBlif() noexcept {
366366
createNodes();
367367

368368
if (trace_ >= 4) {
369-
printPrimitives(ls);
369+
printPrimitives(ls, false);
370370
if (trace_ >= 5) {
371371
printNodes(ls);
372372
flush_out(true);
@@ -403,6 +403,8 @@ bool BLIF_file::checkBlif() noexcept {
403403
ls << " #constantNodes_= " << constantNodes_.size() << '\n';
404404
flush_out(true);
405405
}
406+
printPrimitives(ls, true);
407+
flush_out(true);
406408
}
407409

408410
// 5. no undriven output ports
@@ -508,29 +510,74 @@ uint BLIF_file::printNodes(std::ostream& os) const noexcept {
508510
return n;
509511
}
510512

511-
uint BLIF_file::printPrimitives(std::ostream& os) const noexcept {
513+
uint BLIF_file::printPrimitives(std::ostream& os, bool instCounts) const noexcept {
512514
os << endl;
513515
os_printf(os, "======== primitive types (%u) :\n", Prim_MAX_ID - 1);
514516
char ncs_buf[80] = {};
515-
for (uint t = 1; t < Prim_MAX_ID; t++) {
516-
Prim_t pt = Prim_t(t);
517-
CStr pn = pr_enum2str(pt);
518-
assert(pn and pn[0]);
519-
uint n_outputs = pr_num_outputs(pt);
520-
uint n_clocks = pr_num_clocks(pt);
521-
ncs_buf[0] = 0;
522-
if (n_clocks) {
523-
::sprintf(ncs_buf, " #clock_pins= %u", n_clocks);
517+
518+
if (instCounts) {
519+
char ic_buf[80] = {};
520+
uint n_clock_inst = 0;
521+
std::array<uint, Prim_MAX_ID> IC = countTypes();
522+
for (uint t = 1; t < Prim_MAX_ID; t++) {
523+
Prim_t pt = Prim_t(t);
524+
CStr pn = pr_enum2str(pt);
525+
assert(pn and pn[0]);
526+
uint n_clocks = pr_num_clocks(pt);
527+
ncs_buf[0] = 0;
528+
ic_buf[0] = 0;
529+
if (IC[t]) {
530+
::sprintf(ic_buf, " inst-count= %u", IC[t]);
531+
}
532+
if (n_clocks and IC[t]) {
533+
::sprintf(ncs_buf, " #clock_pins= %u", n_clocks);
534+
n_clock_inst++;
535+
}
536+
os_printf(os, " [%u] %s %s%s\n",
537+
t, pn, ic_buf, ncs_buf);
538+
}
539+
flush_out(true);
540+
lprintf("==== number of instances with clock pins = %u\n", n_clock_inst);
541+
}
542+
else {
543+
for (uint t = 1; t < Prim_MAX_ID; t++) {
544+
Prim_t pt = Prim_t(t);
545+
CStr pn = pr_enum2str(pt);
546+
assert(pn and pn[0]);
547+
uint n_outputs = pr_num_outputs(pt);
548+
uint n_clocks = pr_num_clocks(pt);
549+
ncs_buf[0] = 0;
550+
if (n_clocks) {
551+
::sprintf(ncs_buf, " #clock_pins= %u", n_clocks);
552+
}
553+
os_printf(os, " [%u] %s #outputs= %u%s\n",
554+
t, pn, n_outputs, ncs_buf);
524555
}
525-
os_printf(os, " [%u] %s #outputs= %u%s\n",
526-
t, pn, n_outputs, ncs_buf);
527556
}
528557

529558
os << endl;
530559
os.flush();
531560
return Prim_MAX_ID;
532561
}
533562

563+
std::array<uint, Prim_MAX_ID> BLIF_file::countTypes() const noexcept {
564+
std::array<uint, Prim_MAX_ID> A;
565+
for (uint t = 0; t < Prim_MAX_ID; t++)
566+
A[t] = 0;
567+
uint nn = numNodes();
568+
if (nn == 0)
569+
return A;
570+
571+
for (uint i = 1; i <= nn; i++) {
572+
const Node& nd = nodePool_[i];
573+
uint t = nd.ptype_;
574+
if (t > 0 and t < Prim_MAX_ID)
575+
A[t]++;
576+
}
577+
578+
return A;
579+
}
580+
534581
uint BLIF_file::countCarryNodes() const noexcept {
535582
uint nn = numNodes();
536583
if (nn == 0)

planning/src/file_readers/pln_blif_file.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,12 @@ struct BLIF_file : public fio::MMapReader
178178
uint numOutputs() const noexcept { return outputs_.size(); }
179179
uint numNodes() const noexcept { return nodePool_.empty() ? 0 : nodePool_.size() - 1; }
180180

181+
std::array<uint, prim::Prim_MAX_ID> countTypes() const noexcept;
182+
181183
uint printInputs(std::ostream& os, CStr spacer = nullptr) const noexcept;
182184
uint printOutputs(std::ostream& os, CStr spacer = nullptr) const noexcept;
183185
uint printNodes(std::ostream& os) const noexcept;
184-
uint printPrimitives(std::ostream& os) const noexcept;
186+
uint printPrimitives(std::ostream& os, bool instCounts) const noexcept;
185187

186188
uint countCarryNodes() const noexcept;
187189
uint printCarryNodes(std::ostream& os) const noexcept;

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

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

0 commit comments

Comments
 (0)