Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
BSD
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chengshuyao
BSD
Commits
65f8fbad
Commit
65f8fbad
authored
Dec 10, 2025
by
chengshuyao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Debug print char* problems
parent
9aee67a1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
61 additions
and
11 deletions
+61
-11
src/BSD.cpp
+5
-3
src/BSD.h
+2
-1
src/BSD_top.h
+46
-5
src/print_circuit.h
+6
-2
src/top.h
+2
-0
No files found.
src/BSD.cpp
View file @
65f8fbad
...
@@ -3,8 +3,10 @@
...
@@ -3,8 +3,10 @@
int
main
(
int
argc
,
char
*
argv
[]){
int
main
(
int
argc
,
char
*
argv
[]){
set_default
();
set_default
();
#ifdef SEARCH_PARTITION
//int area_a = search_order();
search_partition
();
search_partition
();
#else
search_order
();
#endif
};
};
src/BSD.h
View file @
65f8fbad
...
@@ -201,7 +201,7 @@ public:
...
@@ -201,7 +201,7 @@ public:
BDD_split_nodes_each_layer
=
new
int
[
parameter_input_bit_width
+
1
];
BDD_split_nodes_each_layer
=
new
int
[
parameter_input_bit_width
+
1
];
output_partition_set
=
new
bool
[
parameter_output_bit_width
];
output_partition_set
=
new
bool
[
parameter_output_bit_width
];
start_node_index
=
new
node_index
[
parameter_output_bit_width
];
start_node_index
=
new
node_index
[
parameter_output_bit_width
];
start_node_index_string
=
new
char
[
parameter_output_bit_width
];
start_node_index_string
=
new
char
[
parameter_output_bit_width
+
1
];
};
};
//~BDD_class(){
//~BDD_class(){
...
@@ -1270,6 +1270,7 @@ int BDD_class::BDD_FULL_PROCESS(){
...
@@ -1270,6 +1270,7 @@ int BDD_class::BDD_FULL_PROCESS(){
}
}
}
}
start_node_index_string
[
parameter_output_bit_width
]
=
'\0'
;
// for (j=0;j<parameter_max_orders;j++){
// for (j=0;j<parameter_max_orders;j++){
// BSD_variable_order[j] = new int [parameter_input_bit_width];
// BSD_variable_order[j] = new int [parameter_input_bit_width];
// }
// }
...
...
src/BSD_top.h
View file @
65f8fbad
...
@@ -86,7 +86,7 @@ public:
...
@@ -86,7 +86,7 @@ public:
}
}
};
};
int
default_start_node_number
;
int
default_start_node_number
=
parameter_output_bit_width
;
node_index
*
default_start_node_index
;
node_index
*
default_start_node_index
;
...
@@ -215,7 +215,7 @@ int search_partition(int start_node_number,int start_node_depth , node_index* st
...
@@ -215,7 +215,7 @@ int search_partition(int start_node_number,int start_node_depth , node_index* st
int
search_partition
(
int
start_node_number
=
default_start_node_number
,
int
start_node_depth
=
0
,
node_index
*
start_node_index
=
default_start_node_index
,
int
*
start_order
=
default_start_order
){
int
search_partition
(
int
start_node_number
=
default_start_node_number
,
int
start_node_depth
=
0
,
node_index
*
start_node_index
=
default_start_node_index
,
int
*
start_order
=
default_start_order
){
int
search_order_times
=
2
;
int
search_order_times
=
5
;
random_device
rd
;
random_device
rd
;
mt19937
gen
(
rd
());
mt19937
gen
(
rd
());
...
@@ -274,7 +274,7 @@ int search_partition(int start_node_number=default_start_node_number,int start_n
...
@@ -274,7 +274,7 @@ int search_partition(int start_node_number=default_start_node_number,int start_n
for
(
int
i
=
0
;
i
<
max_partition_parts
;
i
++
){
for
(
int
i
=
0
;
i
<
max_partition_parts
;
i
++
){
cout
<<
"partition "
<<
i
<<
" "
<<
area_parts
[
i
]
<<
endl
;
cout
<<
"partition "
<<
i
<<
" "
<<
area_parts
[
i
]
<<
endl
;
}
}
char
*
start_node_index_string
=
new
char
[
parameter_output_bit_width
];
char
*
start_node_index_string
=
new
char
[
parameter_output_bit_width
+
1
];
ofstream
function_top_file
(
"rtl/function_top.v"
);
ofstream
function_top_file
(
"rtl/function_top.v"
);
for
(
int
i
=
0
;
i
<
best_partition_parts
;
i
++
){
for
(
int
i
=
0
;
i
<
best_partition_parts
;
i
++
){
...
@@ -287,6 +287,7 @@ int search_partition(int start_node_number=default_start_node_number,int start_n
...
@@ -287,6 +287,7 @@ int search_partition(int start_node_number=default_start_node_number,int start_n
}
}
}
}
start_node_index_string
[
parameter_output_bit_width
]
=
'\0'
;
function_top_file
<<
"`include
\"
function_layer_"
<<
start_node_depth
<<
"_nodes_"
<<
start_node_index_string
<<
".v
\"
"
<<
endl
;
function_top_file
<<
"`include
\"
function_layer_"
<<
start_node_depth
<<
"_nodes_"
<<
start_node_index_string
<<
".v
\"
"
<<
endl
;
}
}
function_top_file
<<
endl
;
function_top_file
<<
endl
;
...
@@ -307,8 +308,20 @@ int search_partition(int start_node_number=default_start_node_number,int start_n
...
@@ -307,8 +308,20 @@ int search_partition(int start_node_number=default_start_node_number,int start_n
}
}
}
}
start_node_index_string
[
parameter_output_bit_width
]
=
'\0'
;
function_top_file
<<
"function_layer_"
<<
start_node_depth
<<
"_nodes_"
<<
start_node_index_string
<<
" part"
<<
i
<<
" (.i(i),.o_index(o_"
<<
i
<<
"));"
<<
endl
;
function_top_file
<<
"function_layer_"
<<
start_node_depth
<<
"_nodes_"
<<
start_node_index_string
<<
" part"
<<
i
<<
" (.i(i),.o_index(o_"
<<
i
<<
"));"
<<
endl
;
}
}
function_top_file
<<
endl
;
for
(
int
i
=
0
;
i
<
parameter_output_bit_width
;
i
++
){
int
position_a
=
0
;
for
(
int
j
=
0
;
j
<
best_partition_parts
;
j
++
){
if
(
best_partition_sets
[
j
][
i
]
==
1
){
position_a
=
j
;
break
;
}
}
function_top_file
<<
"assign o["
<<
i
<<
"] = o_"
<<
position_a
<<
"["
<<
i
<<
"];"
<<
endl
;
}
function_top_file
<<
"endmodule"
<<
endl
;
function_top_file
<<
"endmodule"
<<
endl
;
function_top_file
.
close
();
function_top_file
.
close
();
...
@@ -398,7 +411,7 @@ int search_partition(int start_node_number=default_start_node_number,int start_n
...
@@ -398,7 +411,7 @@ int search_partition(int start_node_number=default_start_node_number,int start_n
}
}
cout
<<
"Best Design Area: "
<<
best_area
<<
endl
;
cout
<<
"Best Design Area: "
<<
best_area
<<
endl
;
char
*
start_node_index_string
=
new
char
[
parameter_output_bit_width
];
char
*
start_node_index_string
=
new
char
[
parameter_output_bit_width
+
1
];
ofstream
function_top_file
(
"rtl/function_top.v"
);
ofstream
function_top_file
(
"rtl/function_top.v"
);
for
(
int
i
=
0
;
i
<
best_partition_parts
;
i
++
){
for
(
int
i
=
0
;
i
<
best_partition_parts
;
i
++
){
for
(
int
j
=
0
;
j
<
parameter_output_bit_width
;
j
++
){
for
(
int
j
=
0
;
j
<
parameter_output_bit_width
;
j
++
){
...
@@ -410,6 +423,7 @@ int search_partition(int start_node_number=default_start_node_number,int start_n
...
@@ -410,6 +423,7 @@ int search_partition(int start_node_number=default_start_node_number,int start_n
}
}
}
}
start_node_index_string
[
parameter_output_bit_width
]
=
'\0'
;
function_top_file
<<
"`include
\"
function_layer_"
<<
start_node_depth
<<
"_nodes_"
<<
start_node_index_string
<<
".v
\"
"
<<
endl
;
function_top_file
<<
"`include
\"
function_layer_"
<<
start_node_depth
<<
"_nodes_"
<<
start_node_index_string
<<
".v
\"
"
<<
endl
;
}
}
function_top_file
<<
endl
;
function_top_file
<<
endl
;
...
@@ -430,6 +444,7 @@ int search_partition(int start_node_number=default_start_node_number,int start_n
...
@@ -430,6 +444,7 @@ int search_partition(int start_node_number=default_start_node_number,int start_n
}
}
}
}
start_node_index_string
[
parameter_output_bit_width
]
=
'\0'
;
function_top_file
<<
"function_layer_"
<<
start_node_depth
<<
"_nodes_"
<<
start_node_index_string
<<
" part"
<<
i
<<
" (.i(i),.o_index(o_"
<<
i
<<
"));"
<<
endl
;
function_top_file
<<
"function_layer_"
<<
start_node_depth
<<
"_nodes_"
<<
start_node_index_string
<<
" part"
<<
i
<<
" (.i(i),.o_index(o_"
<<
i
<<
"));"
<<
endl
;
}
}
function_top_file
<<
endl
;
function_top_file
<<
endl
;
...
@@ -765,7 +780,32 @@ int search_order(int start_node_number = default_start_node_number, int start_no
...
@@ -765,7 +780,32 @@ int search_order(int start_node_number = default_start_node_number, int start_no
else
{
else
{
reward
=
BSD_execute
(
start_node_number
,
start_node_index
,
best_area_depth
,
multi_variable_order
[
order_num
]);
reward
=
BSD_execute
(
start_node_number
,
start_node_index
,
best_area_depth
,
multi_variable_order
[
order_num
]);
}
}
#ifdef SEARCH_PARTITION
#else
char
*
start_node_index_string
=
new
char
[
parameter_output_bit_width
+
1
];
ofstream
function_top_file
(
"rtl/function_top.v"
);
for
(
int
j
=
0
;
j
<
parameter_output_bit_width
;
j
++
){
start_node_index_string
[
j
]
=
'1'
;
}
start_node_index_string
[
parameter_output_bit_width
]
=
'\0'
;
function_top_file
<<
"`include
\"
function_layer_"
<<
start_node_depth
<<
"_nodes_"
<<
start_node_index_string
<<
".v
\"
"
<<
endl
;
function_top_file
<<
endl
;
function_top_file
<<
"module function_top (i,o);"
<<
endl
<<
endl
;
function_top_file
<<
"input ["
<<
parameter_input_bit_width
-
1
<<
":0] i;"
<<
endl
;
function_top_file
<<
"output ["
<<
parameter_output_bit_width
-
1
<<
":0] o;"
<<
endl
<<
endl
;
for
(
int
i
=
0
;
i
<
1
;
i
++
){
function_top_file
<<
"wire ["
<<
parameter_output_bit_width
-
1
<<
":0] o_"
<<
i
<<
";"
<<
endl
;
}
function_top_file
<<
endl
;
function_top_file
<<
"function_layer_"
<<
start_node_depth
<<
"_nodes_"
<<
start_node_index_string
<<
" part1 (.i(i),.o_index(o_1));"
<<
endl
;
function_top_file
<<
endl
;
for
(
int
i
=
0
;
i
<
parameter_output_bit_width
;
i
++
){
function_top_file
<<
"assign o["
<<
i
<<
"] = o_1["
<<
i
<<
"];"
<<
endl
;
}
function_top_file
<<
"endmodule"
<<
endl
;
function_top_file
.
close
();
#endif
bool
accept
=
0
;
bool
accept
=
0
;
//accept = (reward <= best_reward);
//accept = (reward <= best_reward);
...
@@ -919,6 +959,7 @@ int search_order(int start_node_number = default_start_node_number, int start_no
...
@@ -919,6 +959,7 @@ int search_order(int start_node_number = default_start_node_number, int start_no
//}
//}
//delete [] variable_order;
//delete [] variable_order;
//delete [] best_variable_order;
//delete [] best_variable_order;
return
reward
;
return
reward
;
};
};
src/print_circuit.h
View file @
65f8fbad
...
@@ -6,7 +6,7 @@ int BDD_class::print_circuit(BDD_node** BDD,int* most_influence,int node_depth,
...
@@ -6,7 +6,7 @@ int BDD_class::print_circuit(BDD_node** BDD,int* most_influence,int node_depth,
char
output_file_name
[
100
];
char
output_file_name
[
100
];
//sprintf(output_file_name,"rtl/module_output_bit_%d.v",which_bit_output);
//sprintf(output_file_name,"rtl/module_output_bit_%d.v",which_bit_output);
// sprintf(output_file_name,"rtl/function_%d_id_%d.v",circuit_index,BDD_id);
// sprintf(output_file_name,"rtl/function_%d_id_%d.v",circuit_index,BDD_id);
sprintf
(
output_file_name
,
"rtl/function_layer_%d_nodes_%s.v"
,
node_depth
,
start_node_index_string
);
sprintf
(
output_file_name
,
"rtl/function_layer_%d_nodes_%s.v"
,
node_depth
,
start_node_index_string
);
// string output_file_name << output_file_name_begin << which_bit_output << output_file_name_end;
// string output_file_name << output_file_name_begin << which_bit_output << output_file_name_end;
...
@@ -136,7 +136,11 @@ int BDD_class::print_circuit(BDD_node** BDD,int* most_influence,int node_depth,
...
@@ -136,7 +136,11 @@ int BDD_class::print_circuit(BDD_node** BDD,int* most_influence,int node_depth,
output_module_file
<<
"//total split modes recursive = "
<<
total_split_nodes_recursive
<<
endl
;
output_module_file
<<
"//total split modes recursive = "
<<
total_split_nodes_recursive
<<
endl
;
output_module_file
<<
"//train time = "
<<
train_time
<<
endl
;
output_module_file
<<
"//train time = "
<<
train_time
<<
endl
;
// output_module_file << "module function_"<<circuit_index<<"_BDD_id_"<<BDD_id<<" (i,o);"<<endl<<endl;
// output_module_file << "module function_"<<circuit_index<<"_BDD_id_"<<BDD_id<<" (i,o);"<<endl<<endl;
output_module_file
<<
"module function_layer_"
<<
node_depth
<<
"_nodes_"
<<
start_node_index_string
<<
" (i,o_index);"
<<
endl
<<
endl
;
output_module_file
<<
"module function_layer_"
<<
node_depth
<<
"_nodes_"
;
for
(
int
i
=
0
;
i
<
parameter_output_bit_width
;
i
++
){
output_module_file
<<
start_node_index_string
[
i
];
}
output_module_file
<<
" (i,o_index);"
<<
endl
<<
endl
;
output_module_file
<<
"input ["
<<
parameter_input_bit_width
-
1
<<
":0] i;"
<<
endl
;
output_module_file
<<
"input ["
<<
parameter_input_bit_width
-
1
<<
":0] i;"
<<
endl
;
output_module_file
<<
"output ["
<<
parameter_output_bit_width
-
1
<<
":0] o_index;"
<<
endl
<<
endl
;
output_module_file
<<
"output ["
<<
parameter_output_bit_width
-
1
<<
":0] o_index;"
<<
endl
<<
endl
;
...
...
src/top.h
View file @
65f8fbad
...
@@ -6,6 +6,8 @@
...
@@ -6,6 +6,8 @@
#define INPUT_AIG //io_generator是否可以用uint按位操作进行加速,也即是否包含_vec后缀的另一个io_generator
#define INPUT_AIG //io_generator是否可以用uint按位操作进行加速,也即是否包含_vec后缀的另一个io_generator
#define SINGLE_BITS //io_generator是否包含每一个bit单独的io_generator_o{x}
#define SINGLE_BITS //io_generator是否包含每一个bit单独的io_generator_o{x}
#define SEARCH_PARTITION //BSD算法搜索partition策略
extern
const
int
parameter_input_bit_width
=
PI_WIDTH
+
5
;
extern
const
int
parameter_input_bit_width
=
PI_WIDTH
+
5
;
int
parameter_output_bit_width
=
PO_WIDTH
;
int
parameter_output_bit_width
=
PO_WIDTH
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment