Skip to content

Commit 5f98b6b

Browse files
committed
removed unnecessary parameters from the reorganize_module_node_list function and updated commenting to improve clarity of the function.
1 parent 25dfbd7 commit 5f98b6b

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

utils/vqm2blif/src/base/cleanup.cpp

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,8 @@ void remove_one_lut_nodes ( busvec* buses, struct s_hash** hash_table, t_node**
355355
}
356356
}
357357

358-
// reorganize the node array after removing all the one lut nodes previously
359-
reorganize_module_node_list(original_num_nodes, oneluts_elim, nodes, module);
358+
// fix the module nodes list (node array) by filling in the gaps where the one-lut nodes have been removed above
359+
reorganize_module_node_list(module);
360360

361361
//Reduce run-time by only verifying at the end
362362
//verify_netlist (nodes, module->number_of_nodes, buses, hash_table);
@@ -841,12 +841,12 @@ void remove_node ( t_node* node, t_node** nodes, int original_num_nodes ) {
841841
//============================================================================================
842842
//============================================================================================
843843

844-
void reorganize_module_node_list(int original_number_of_nodes, int number_of_nodes_eliminated, t_node** module_node_list, t_module* module)
844+
void reorganize_module_node_list(t_module* module)
845845
{
846846
/*
847-
The purpose of this function is to regorganize the nodes array by filling in gaps with the last available elements in the array to save CPU time.
847+
The purpose of this function is to regorganize the module node list (node array) by filling in gaps with the last available elements in the array to save CPU time.
848848
849-
The node array provided to this function is expected to have elements deleted within. THis essentially creates gaps in the array. So we fill in the gaps of this array and ensure it is a continuous list of nodes.
849+
The module provided to this function is expected to have nodes deleted within its nodes list (array). This essentially creates gaps in the array. So we fill in the gaps of this array and ensure it is a continuous list of nodes.
850850
851851
Please refer to the example below:
852852
@@ -858,19 +858,24 @@ void reorganize_module_node_list(int original_number_of_nodes, int number_of_nod
858858
After reorganization and filling gaps:
859859
860860
------ ------ ------ ------
861-
|LUT 1| --> |LUT 2| --> |LUT 3| --> |LUT 4| -->
861+
|LUT 1| --> |LUT 2| --> |LUT 4| --> |LUT 3| -->
862862
------ ------ ------ ------
863863
864+
The function fills in the gaps with the last available node in the list (as shown in the example above).
865+
864866
Change Log:
865867
- Srivatsan Srinivasan, August 2021:
866868
- created this function to reorganize node arrays with gaps inside of them.
867869
- Initially the feature provided by this function was embedded indide the "remove_one_lut_nodes" function. By creating a seperate function, we are now not restricted to only removing one-lut nodes.
868870
- Now we can remove any types of nodes and then run this function to reorganize the node array.
869871
*/
870-
int new_array_size = original_number_of_nodes - number_of_nodes_eliminated;
872+
// assign module related parameters
873+
int original_number_of_nodes = module->number_of_nodes;
874+
t_node** module_node_list = module->array_of_nodes;
875+
871876
int curr_node_index = 0;
872877
int replacement_node_index = original_number_of_nodes - 1;
873-
while (curr_node_index < replacement_node_index) {
878+
while (curr_node_index <= replacement_node_index) {
874879
if (module_node_list[curr_node_index] == NULL) {
875880
if (module_node_list[replacement_node_index] != NULL) {
876881
//Replace gap with node
@@ -883,14 +888,11 @@ void reorganize_module_node_list(int original_number_of_nodes, int number_of_nod
883888
curr_node_index++;
884889
}
885890
}
886-
if (module_node_list[curr_node_index] == NULL) {
887-
VTR_ASSERT(curr_node_index == new_array_size); //check array size
888-
} else {
889-
VTR_ASSERT(curr_node_index == new_array_size - 1); //check array size
890-
}
891-
891+
892892
//Update array bounds
893-
module -> number_of_nodes = new_array_size;
893+
// curr_node_index keeps track of the number of non-removed nodes within the node array.
894+
// So we can use it directly to indicate the new size of the array.
895+
module -> number_of_nodes = curr_node_index;
894896

895897
return;
896898
}

utils/vqm2blif/src/base/cleanup.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ void netlist_cleanup (t_module* module);
2121

2222
void remove_node ( t_node* node, t_node** nodes, int original_num_nodes );
2323

24-
void reorganize_module_node_list(int original_number_of_nodes, int number_of_nodes_eliminated, t_node** module_node_list, t_module* module);
24+
void reorganize_module_node_list(t_module* module);
2525

2626
//============================================================================================
2727
// STRUCTURES & TYPEDEFS

0 commit comments

Comments
 (0)