4
4
#include " atom_netlist.h"
5
5
#include " atom_netlist_utils.h"
6
6
#include " echo_files.h"
7
-
8
7
#include " vtr_assert.h"
9
8
#include " vtr_log.h"
10
- #include " vtr_util.h"
11
9
#include " vtr_path.h"
12
10
#include " vtr_time.h"
13
11
@@ -145,34 +143,31 @@ static void process_circuit(AtomNetlist& netlist,
145
143
}
146
144
147
145
static void show_circuit_stats (const AtomNetlist& netlist) {
146
+ // Count the block statistics
148
147
std::map<std::string, size_t > block_type_counts;
149
-
150
- // Count the block statistics
148
+ std::map<std::string, size_t > lut_size_counts;
151
149
for (auto blk_id : netlist.blocks ()) {
150
+ // For each model, count the number of occurrences in the netlist.
152
151
const t_model* blk_model = netlist.block_model (blk_id);
152
+ ++block_type_counts[blk_model->name ];
153
+ // If this block is a LUT, also count the occurences of this size of LUT
154
+ // for more logging information.
153
155
if (blk_model->name == std::string (MODEL_NAMES)) {
154
- // LUT
155
- size_t lut_size = 0 ;
156
+ // May have zero (no input LUT) or one input port
156
157
auto in_ports = netlist.block_input_ports (blk_id);
157
-
158
- // May have zero (no input LUT) or one input port
158
+ VTR_ASSERT (in_ports. size () <= 1 && " Expected number of input ports for LUT to be 0 or 1 " );
159
+ size_t lut_size = 0 ;
159
160
if (in_ports.size () == 1 ) {
161
+ // Use the number of pins in the input port to determine the
162
+ // size of the LUT.
160
163
auto port_id = *in_ports.begin ();
161
-
162
- // Figure out the LUT size
163
- lut_size = netlist.port_width (port_id);
164
-
165
- } else {
166
- VTR_ASSERT (in_ports.size () == 0 );
164
+ lut_size = netlist.port_pins (port_id).size ();
167
165
}
168
-
169
- ++block_type_counts[std::to_string (lut_size) + " -LUT" ];
170
- } else {
171
- // Other types
172
- ++block_type_counts[blk_model->name ];
166
+ ++lut_size_counts[std::to_string (lut_size) + " -LUT" ];
173
167
}
174
168
}
175
- // Count the net statistics
169
+
170
+ // Count the net statistics
176
171
std::map<std::string, double > net_stats;
177
172
for (auto net_id : netlist.nets ()) {
178
173
double fanout = netlist.net_sinks (net_id).size ();
@@ -189,21 +184,32 @@ static void show_circuit_stats(const AtomNetlist& netlist) {
189
184
}
190
185
net_stats[" Avg Fanout" ] /= netlist.nets ().size ();
191
186
192
- // Determine the maximum length of a type name for nice formatting
187
+ // Determine the maximum length of a type name for nice formatting
193
188
size_t max_block_type_len = 0 ;
194
189
for (const auto & kv : block_type_counts) {
195
190
max_block_type_len = std::max (max_block_type_len, kv.first .size ());
196
191
}
192
+ size_t max_lut_size_len = 0 ;
193
+ for (const auto & kv : lut_size_counts) {
194
+ max_lut_size_len = std::max (max_lut_size_len, kv.first .size ());
195
+ }
197
196
size_t max_net_type_len = 0 ;
198
197
for (const auto & kv : net_stats) {
199
198
max_net_type_len = std::max (max_net_type_len, kv.first .size ());
200
199
}
201
200
202
- // Print the statistics
201
+ // Print the statistics
203
202
VTR_LOG (" Circuit Statistics:\n " );
204
203
VTR_LOG (" Blocks: %zu\n " , netlist.blocks ().size ());
205
204
for (const auto & kv : block_type_counts) {
206
205
VTR_LOG (" %-*s: %7zu\n " , max_block_type_len, kv.first .c_str (), kv.second );
206
+ // If this block is a LUT, print the different sizes of LUTs in the
207
+ // design.
208
+ if (kv.first == std::string (MODEL_NAMES)) {
209
+ for (const auto & lut_kv : lut_size_counts) {
210
+ VTR_LOG (" %-*s: %7zu\n " , max_lut_size_len, lut_kv.first .c_str (), lut_kv.second );
211
+ }
212
+ }
207
213
}
208
214
VTR_LOG (" Nets : %zu\n " , netlist.nets ().size ());
209
215
for (const auto & kv : net_stats) {
0 commit comments