Skip to content

Commit d2d4254

Browse files
[LOGGING] Fixed LUT Sizing Issue
The size of the LUTs were being calculated incorrectly by using the width of the port instead of the actual number of pins in the port. The parsing scripts for the golden results were also incorrect since they were using the number of 6-LUTs as the total number of LUTs.
1 parent d02b3bc commit d2d4254

File tree

2 files changed

+29
-23
lines changed

2 files changed

+29
-23
lines changed

vpr/src/base/read_circuit.cpp

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44
#include "atom_netlist.h"
55
#include "atom_netlist_utils.h"
66
#include "echo_files.h"
7-
87
#include "vtr_assert.h"
98
#include "vtr_log.h"
10-
#include "vtr_util.h"
119
#include "vtr_path.h"
1210
#include "vtr_time.h"
1311

@@ -145,34 +143,31 @@ static void process_circuit(AtomNetlist& netlist,
145143
}
146144

147145
static void show_circuit_stats(const AtomNetlist& netlist) {
146+
// Count the block statistics
148147
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;
151149
for (auto blk_id : netlist.blocks()) {
150+
// For each model, count the number of occurrences in the netlist.
152151
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.
153155
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
156157
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;
159160
if (in_ports.size() == 1) {
161+
// Use the number of pins in the input port to determine the
162+
// size of the LUT.
160163
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();
167165
}
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"];
173167
}
174168
}
175-
//Count the net statistics
169+
170+
// Count the net statistics
176171
std::map<std::string, double> net_stats;
177172
for (auto net_id : netlist.nets()) {
178173
double fanout = netlist.net_sinks(net_id).size();
@@ -189,21 +184,32 @@ static void show_circuit_stats(const AtomNetlist& netlist) {
189184
}
190185
net_stats["Avg Fanout"] /= netlist.nets().size();
191186

192-
//Determine the maximum length of a type name for nice formatting
187+
// Determine the maximum length of a type name for nice formatting
193188
size_t max_block_type_len = 0;
194189
for (const auto& kv : block_type_counts) {
195190
max_block_type_len = std::max(max_block_type_len, kv.first.size());
196191
}
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+
}
197196
size_t max_net_type_len = 0;
198197
for (const auto& kv : net_stats) {
199198
max_net_type_len = std::max(max_net_type_len, kv.first.size());
200199
}
201200

202-
//Print the statistics
201+
// Print the statistics
203202
VTR_LOG("Circuit Statistics:\n");
204203
VTR_LOG(" Blocks: %zu\n", netlist.blocks().size());
205204
for (const auto& kv : block_type_counts) {
206205
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+
}
207213
}
208214
VTR_LOG(" Nets : %zu\n", netlist.nets().size());
209215
for (const auto& kv : net_stats) {

vtr_flow/parse/parse_config/vpr_chain.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
%include "vpr_standard.txt"
22

33
num_le;vpr.out;\s*Total number of Logic Elements used\s*:\s*(\d+)
4-
num_luts;vpr.out;\s*6-LUT\s*:\s*(\d+)
4+
num_luts;vpr.out;\s*.names\s*:\s*(\d+)
55
num_add_blocks;odin.out;The Total Number of Hard Block adders: (\d+)
66
max_add_chain_length;odin.out;The Number of Hard Block adders in the Longest Chain: (\d+)
77
num_sub_blocks;odin.out;The Total Number of Hard Block subs: (\d+)

0 commit comments

Comments
 (0)