Skip to content

Commit 0c11cd4

Browse files
sdamghanalirezazd
authored andcommitted
[Odin]: - replacing literals in netlist_cleanup with a global constant variable as UNUSED_NODE_TYPE
- add more comments and fix code style Signed-off-by: Seyed Alireza Damghani <sdamghan@unb.ca>
1 parent 36c74a6 commit 0c11cd4

File tree

3 files changed

+37
-31
lines changed

3 files changed

+37
-31
lines changed

ODIN_II/SRC/include/odin_globals.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@
88
#include "read_xml_arch_file.h"
99
#include "HardSoftLogicMixer.hpp"
1010

11+
/**
12+
* The cutoff for the number of netlist nodes.
13+
* Technically, Odin-II prints statistics for
14+
* netlist nodes that the total number of them
15+
* is greater than this value.
16+
*/
17+
constexpr long long UNUSED_NODE_TYPE = 0;
18+
1119
extern t_logical_block_type* type_descriptors;
1220

1321
/* VERILOG SYNTHESIS GLOBALS */

ODIN_II/SRC/netlist_cleanup.cpp

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
*/
2323
#include <stdio.h>
2424
#include <stdlib.h>
25+
#include <algorithm> // std::fill
2526
#include <math.h>
2627
#include "odin_types.h"
2728
#include "odin_globals.h"
@@ -244,50 +245,50 @@ void calculate_addsub_statistics(node_list_t* addsub) {
244245
}
245246
void count_node_type(nnode_t* node) {
246247
switch (node->type) {
247-
case LOGICAL_OR:
248-
case LOGICAL_AND:
249-
case LOGICAL_NOR:
250-
case LOGICAL_NAND:
251-
case LOGICAL_XOR:
252-
case LOGICAL_XNOR:
253-
case LOGICAL_NOT:
248+
case LOGICAL_OR: //fallthrough
249+
case LOGICAL_AND: //fallthrough
250+
case LOGICAL_NOR: //fallthrough
251+
case LOGICAL_NAND: //fallthrough
252+
case LOGICAL_XOR: //fallthrough
253+
case LOGICAL_XNOR: //fallthrough
254+
case LOGICAL_NOT: //fallthrough
254255
num_removed_nodes[node->type]++;
255256
num_removed_nodes[GENERIC]++;
256257
break;
257258

258-
case MUX_2: //fallthrough
259-
case SMUX_2:
259+
case MUX_2: //fallthrough
260+
case SMUX_2: //fallthrough
260261
num_removed_nodes[MUX_2]++;
261262
num_removed_nodes[GENERIC]++;
262263
break;
263264

264-
case GENERIC:
265+
case GENERIC: //fallthrough
265266
num_removed_nodes[node->type]++;
266267
break;
267268

268-
case MINUS:
269+
case MINUS: //fallthrough
269270
/* Minus nodes are built of Add nodes */
270271
num_removed_nodes[ADD]++;
271272
break;
272273

273274
case PAD_NODE: //fallthrough
274-
case GND_NODE:
275-
case VCC_NODE:
275+
case GND_NODE: //fallthrough
276+
case VCC_NODE: //fallthrough
276277
/* These are irrelevent so we dont output */
277278
break;
278279

279-
case INPUT_NODE: //fallthrough
280-
case OUTPUT_NODE:
280+
case INPUT_NODE: //fallthrough
281+
case OUTPUT_NODE: //fallthrough
281282
/* these stay untouched but are not added to the total*/
282283
num_removed_nodes[node->type]++;
283284
break;
284285

285286
case CLOCK_NODE: //fallthrough
286-
case FF_NODE:
287-
case MULTIPLY:
288-
case ADD:
289-
case MEMORY:
290-
case HARD_IP:
287+
case FF_NODE: //fallthrough
288+
case MULTIPLY: //fallthrough
289+
case ADD: //fallthrough
290+
case MEMORY: //fallthrough
291+
case HARD_IP: //fallthrough
291292
/* these stay untouched */
292293
num_removed_nodes[node->type]++;
293294
break;
@@ -300,11 +301,16 @@ void count_node_type(nnode_t* node) {
300301
}
301302

302303
void report_removed_nodes(long long* node_list) {
303-
if (!useless_nodes.node) return;
304+
// return if there is no removed logic
305+
if (!useless_nodes.node)
306+
return;
307+
304308
warning_message(NETLIST, unknown_location, "%s", "Following unused node(s) removed from the netlist:\n");
305309
for (int i = 0; i < operation_list_END; i++) {
306-
if (node_list[i] > 0) {
307-
std::string msg = std::string("Number of removed <") + operation_list_STR[i][ODIN_LONG_STRING] + "> node(s): ";
310+
if (node_list[i] > UNUSED_NODE_TYPE) {
311+
std::string msg = std::string("Number of removed <")
312+
+ operation_list_STR[i][ODIN_LONG_STRING]
313+
+ "> node(s): ";
308314
printf("%-42s%lld\n", msg.c_str(), node_list[i]);
309315
}
310316
}

ODIN_II/SRC/netlist_statistic.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,6 @@
1212
#include "odin_util.h"
1313
#include "vtr_memory.h"
1414

15-
/**
16-
* The cutoff for the number of netlist nodes.
17-
* Technically, Odin-II prints statistics for
18-
* netlist nodes that the total number of them
19-
* is greater than this value.
20-
*/
21-
#define UNUSED_NODE_TYPE 0
22-
2315
static void init(metric_t* m);
2416
static void print_stats(metric_t* m);
2517
static void copy(metric_t* dest, metric_t* src);

0 commit comments

Comments
 (0)