@@ -366,7 +366,7 @@ bool BLIF_file::checkBlif() noexcept {
366
366
createNodes ();
367
367
368
368
if (trace_ >= 4 ) {
369
- printPrimitives (ls);
369
+ printPrimitives (ls, false );
370
370
if (trace_ >= 5 ) {
371
371
printNodes (ls);
372
372
flush_out (true );
@@ -403,6 +403,8 @@ bool BLIF_file::checkBlif() noexcept {
403
403
ls << " #constantNodes_= " << constantNodes_.size () << ' \n ' ;
404
404
flush_out (true );
405
405
}
406
+ printPrimitives (ls, true );
407
+ flush_out (true );
406
408
}
407
409
408
410
// 5. no undriven output ports
@@ -508,29 +510,74 @@ uint BLIF_file::printNodes(std::ostream& os) const noexcept {
508
510
return n;
509
511
}
510
512
511
- uint BLIF_file::printPrimitives (std::ostream& os) const noexcept {
513
+ uint BLIF_file::printPrimitives (std::ostream& os, bool instCounts ) const noexcept {
512
514
os << endl;
513
515
os_printf (os, " ======== primitive types (%u) :\n " , Prim_MAX_ID - 1 );
514
516
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);
524
555
}
525
- os_printf (os, " [%u] %s #outputs= %u%s\n " ,
526
- t, pn, n_outputs, ncs_buf);
527
556
}
528
557
529
558
os << endl;
530
559
os.flush ();
531
560
return Prim_MAX_ID;
532
561
}
533
562
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
+
534
581
uint BLIF_file::countCarryNodes () const noexcept {
535
582
uint nn = numNodes ();
536
583
if (nn == 0 )
0 commit comments