Skip to content

Commit 25460d0

Browse files
authored
Merge pull request #1850 from verilog-to-routing/reorganizing_vqm2blif_source_code
Reorganizing vqm2blif source code
2 parents 616b31f + 37d2e42 commit 25460d0

File tree

10 files changed

+1062249
-30
lines changed

10 files changed

+1062249
-30
lines changed

.github/workflows/test.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,25 @@ jobs:
185185
./.github/scripts/build.sh
186186
./run_reg_test.py odin_reg_basic -show_failures -j2
187187
188+
189+
VQM2BLIF:
190+
name: 'VQM2BLIF Basic Tests'
191+
runs-on: ubuntu-18.04
192+
steps:
193+
194+
- uses: actions/setup-python@v2
195+
with:
196+
python-version: 3.6
197+
- uses: actions/checkout@v2
198+
- run: ./.github/scripts/install_dependencies.sh
199+
200+
- name: Test
201+
env:
202+
BUILD_TYPE: release
203+
run: |
204+
./.github/scripts/build.sh
205+
./utils/vqm2blif/test/scripts/test_vqm2blif.sh
206+
188207
189208
YOSYSODINII:
190209
runs-on: ubuntu-18.04
@@ -256,6 +275,7 @@ jobs:
256275
- Regression
257276
- Sanitized
258277
- ODINII
278+
- VQM2BLIF
259279
- YOSYSODINII
260280
- Compatibility
261281
runs-on: ubuntu-18.04

utils/vqm2blif/src/base/cleanup.cpp

Lines changed: 82 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ void build_netlist (t_module* module, busvec* buses, s_hash** hash_table);
1212
void init_nets (t_pin_def** pins, int num_pins, busvec* buses, struct s_hash** hash_table);
1313
void set_net_assigns (t_assign** assignments, int num_assigns, busvec* buses, struct s_hash** hash_table);
1414
void add_subckts (t_node** nodes, int num_nodes, busvec* buses, struct s_hash** hash_table);
15-
void remove_one_lut_nodes ( busvec* buses, struct s_hash** hash_table, t_node** nodes, int original_num_nodes, t_module* module );
15+
void remove_one_lut_nodes ( busvec* buses, struct s_hash** hash_table, t_module* module );
1616
void clean_netlist ( busvec* buses, struct s_hash** hash_table, t_node** nodes, int num_nodes );
1717
void reassign_net_source (t_net* net);
1818
void print_to_module ( t_module* module, busvec* buses, struct s_hash** hash_table );
@@ -23,7 +23,6 @@ void verify_netlist ( t_node** nodes, int num_nodes, busvec* buses, struct s_has
2323
void print_all_nets ( busvec* buses, const char* filename );
2424

2525
bool is_feeder_onelut ( t_node* node );
26-
void remove_node ( t_node* node, t_node** nodes, int original_num_nodes );
2726

2827
//============================================================================================
2928
//============================================================================================
@@ -50,7 +49,7 @@ void netlist_cleanup (t_module* module){
5049

5150
cout << "\t>> Removing One-LUTs" << "...\n";
5251

53-
remove_one_lut_nodes ( &buses, hash_table, module->array_of_nodes, module->number_of_nodes, module );
52+
remove_one_lut_nodes ( &buses, hash_table, module );
5453

5554
cout << "\t>> Removing buffered nets" << ((clean_mode == CL_BUFF)? "":" and inverted subckt inputs") << "...\n";
5655

@@ -238,7 +237,7 @@ void add_subckts (t_node** nodes, int num_nodes, busvec* buses, struct s_hash**
238237
//============================================================================================
239238
//============================================================================================
240239

241-
void remove_one_lut_nodes ( busvec* buses, struct s_hash** hash_table, t_node** nodes, int original_num_nodes, t_module* module ){
240+
void remove_one_lut_nodes ( busvec* buses, struct s_hash** hash_table, t_module* module ){
242241
/*
243242
Quartus fitter may have introduced some one-LUTs in the post-fit netlist that makes it harder for VPR to place and route.
244243
Generally, these one-LUTs are inserted by the Quartus router in order to pass a signal through a LUT to the FF in the same
@@ -278,9 +277,18 @@ void remove_one_lut_nodes ( busvec* buses, struct s_hash** hash_table, t_node**
278277
---->
279278
|
280279
---->
280+
Change Log:
281+
- Srivatsan Srinivasan, September 2021:
282+
- removed the function parameters "original_num_nodes" and "nodes". These values can be from the "module" parameter and are now assigned internally within this function.
283+
- Srivatsan Srinivasan, August 2021:
284+
- Moved the incrementing of the "oneluts_elim" variable to this fuction from the "remove_node" function. The purpose of this change was to localise any vairable attached to removing one lut nodes within this function. Additionally, now the "remove_node" function is generalized and is not limited to be only used by "remove_one_lut_nodes".
281285
*/
282286
oneluts_elim = 0;
283287

288+
// parameters related to the module
289+
int original_num_nodes = module->number_of_nodes;
290+
t_node** nodes = module->array_of_nodes;
291+
284292
t_node* temp_node;
285293
t_node_port_association* temp_port;
286294
netvec* temp_bus;
@@ -344,37 +352,17 @@ void remove_one_lut_nodes ( busvec* buses, struct s_hash** hash_table, t_node**
344352

345353
//Free the LUT
346354
remove_node(source_node, nodes, original_num_nodes);
355+
356+
// increment the count of the number of one lut nodes we eliminiated
357+
oneluts_elim++;
347358

348359
}
349360
}
350361
}
351362
}
352363

353-
//Regorganize nodes array by filling in gaps with the last available elements in the array to save CPU time
354-
int new_array_size = original_num_nodes - oneluts_elim;
355-
int curr_node_index = 0;
356-
int replacement_node_index = original_num_nodes - 1;
357-
while (curr_node_index < replacement_node_index) {
358-
if (nodes[curr_node_index] == NULL) {
359-
if (nodes[replacement_node_index] != NULL) {
360-
//Replace gap with node
361-
nodes[curr_node_index] = nodes[replacement_node_index];
362-
nodes[replacement_node_index] = NULL;
363-
curr_node_index++;
364-
}
365-
replacement_node_index--;
366-
} else {
367-
curr_node_index++;
368-
}
369-
}
370-
if (nodes[curr_node_index] == NULL) {
371-
VTR_ASSERT(curr_node_index == new_array_size); //check array size
372-
} else {
373-
VTR_ASSERT(curr_node_index == new_array_size - 1); //check array size
374-
}
375-
376-
//Update array bounds
377-
module -> number_of_nodes = new_array_size;
364+
// fix the module nodes list (node array) by filling in the gaps where the one-lut nodes have been removed above
365+
reorganize_module_node_list(module);
378366

379367
//Reduce run-time by only verifying at the end
380368
//verify_netlist (nodes, module->number_of_nodes, buses, hash_table);
@@ -829,6 +817,12 @@ bool is_feeder_onelut ( t_node* node ) {
829817
void remove_node ( t_node* node, t_node** nodes, int original_num_nodes ) {
830818
//Free node and assign it to NULL on the spot
831819
//Array will be re-organized to fill in the gaps later
820+
/*
821+
Change Log:
822+
- Srivatsan Srinivasan, August 2021:
823+
- Orirignally, the "oneluts_elim" variable (which is used to keep track of the number of one lut nodes removed from the node list) was incremented here. This incrementation has been moved to the "remove_one_lut_nodes" function.
824+
- This purpose of this change is that now this function is not limited to just be used by "remove_one_lut_nodes".
825+
*/
832826

833827
VTR_ASSERT(node != NULL);
834828
VTR_ASSERT(nodes != NULL);
@@ -848,8 +842,66 @@ void remove_node ( t_node* node, t_node** nodes, int original_num_nodes ) {
848842
}
849843

850844
VTR_ASSERT(found);
851-
oneluts_elim++;
852845
}
853846

854847
//============================================================================================
855848
//============================================================================================
849+
850+
void reorganize_module_node_list(t_module* module)
851+
{
852+
/*
853+
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.
854+
855+
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.
856+
857+
Please refer to the example below:
858+
859+
Inital Node array:
860+
------ ------ ------ ------
861+
|LUT 1| --> |LUT 2| --> --> |LUT 3| --> |LUT 4|
862+
------ ------ ------ ------
863+
864+
After reorganization and filling gaps:
865+
866+
------ ------ ------ ------
867+
|LUT 1| --> |LUT 2| --> |LUT 4| --> |LUT 3| -->
868+
------ ------ ------ ------
869+
870+
The function fills in the gaps with the last available node in the list (as shown in the example above).
871+
872+
Change Log:
873+
- Srivatsan Srinivasan, August 2021:
874+
- created this function to reorganize node arrays with gaps inside of them.
875+
- 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.
876+
- Now we can remove any types of nodes and then run this function to reorganize the node array.
877+
*/
878+
// assign module related parameters
879+
int original_number_of_nodes = module->number_of_nodes;
880+
t_node** module_node_list = module->array_of_nodes;
881+
882+
int curr_node_index = 0;
883+
int replacement_node_index = original_number_of_nodes - 1;
884+
while (curr_node_index <= replacement_node_index) {
885+
if (module_node_list[curr_node_index] == NULL) {
886+
if (module_node_list[replacement_node_index] != NULL) {
887+
//Replace gap with node
888+
module_node_list[curr_node_index] = module_node_list[replacement_node_index];
889+
module_node_list[replacement_node_index] = NULL;
890+
curr_node_index++;
891+
}
892+
replacement_node_index--;
893+
} else {
894+
curr_node_index++;
895+
}
896+
}
897+
898+
//Update array bounds
899+
// curr_node_index keeps track of the number of non-removed nodes within the node array.
900+
// So we can use it directly to indicate the new size of the array.
901+
module -> number_of_nodes = curr_node_index;
902+
903+
return;
904+
}
905+
906+
//============================================================================================
907+
//============================================================================================

utils/vqm2blif/src/base/cleanup.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,35 @@ extern int buffers_elim, inverts_elim, oneluts_elim;
1919

2020
void netlist_cleanup (t_module* module);
2121

22+
/*
23+
* Function: remove_node
24+
*
25+
* Removes a specific node within a modules node list (node array)
26+
*
27+
* Parameters:
28+
* node - a pointer to the node to remove from the module node list (node array)
29+
* nodes - The module node list containing all nodes (node array)
30+
* original_num_nodes - an integer that represents the total number of nodes within the module node list (node array)
31+
*
32+
* returns: If successful, then nothing is returned.
33+
* If the node to remove was not found, and assertion is raised.
34+
*
35+
*/
36+
void remove_node ( t_node* node, t_node** nodes, int original_num_nodes );
37+
38+
/*
39+
* Function: reorganize_module_node_list
40+
*
41+
* This function fixes a module node list (node array) that has elements
42+
* within it removed. THe removed elements create gaps within the array and
43+
* this function fills in those gaps so that the array is continuous.
44+
*
45+
* Parameters:
46+
* module - the module that contains a node list with elemets within it deleted
47+
*
48+
*/
49+
void reorganize_module_node_list(t_module* module);
50+
2251
//============================================================================================
2352
// STRUCTURES & TYPEDEFS
2453
//============================================================================================

0 commit comments

Comments
 (0)