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
SunMaple
BSD
Commits
5df737e0
Commit
5df737e0
authored
Jun 26, 2025
by
chengshuyao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
heuristic search the variable order
parent
f6a8ddff
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
276 additions
and
201 deletions
+276
-201
src/BSD.cpp
+202
-85
src/BSD.h
+33
-13
src/io_generator_function.h
+2
-74
src/next_layer_bit.h
+11
-11
src/readme.md
+8
-17
src/top.h
+19
-0
src/zstart.sh
+1
-1
No files found.
src/BSD.cpp
View file @
5df737e0
...
@@ -19,19 +19,24 @@
...
@@ -19,19 +19,24 @@
using
namespace
std
;
using
namespace
std
;
#include"cvt.h"
#include"top.h"
//电路的parameter Circuit_parameter
//电路的parameter Circuit_parameter
int
circuit_index
=
9999
;
//电路编号
int
circuit_index
=
9999
;
//电路编号
extern
const
int
parameter_input_bit_width
=
48
;
//输入bit有几位
int
parameter_search_iterations
=
1000
;
extern
const
int
parameter_output_bit_width
=
23
;
//输出bit有几位
int
parameter_test_ios
=
100
;
//测试要求多少样本
int
parameter_test_ios
=
10000
;
//测试要求多少样本
extern
const
int
parameter_max_partition_parts
=
2
;
//算法的parameter Algorithm_parameter
//算法的parameter Algorithm_parameter
extern
const
int
parameter_num_threads
=
100
;
//线程数
extern
const
int
parameter_num_threads
=
100
;
//线程数
extern
const
int
parameter_multi_output_index
=
0
;
//BSD从第几层开始化简,前面若干层展开序确定
extern
const
int
parameter_multi_output_index
=
0
;
//BSD从第几层开始化简,前面若干层展开序确定
int
parameter_early_stop_depth
=
parameter_input_bit_width
;
//BSD到第几层终止,输出此时的不准确BSD
int
parameter_early_stop_depth
=
parameter_input_bit_width
;
//BSD到第几层终止,输出此时的不准确BSD
extern
const
int
parameter_max_samples
=
4000
;
//BSD每一个节点最多进行多少次采样
extern
const
int
parameter_max_samples
=
4000
;
//BSD每一个节点最多进行多少次采样
int
parameter_max_BDD_width
=
1
0000
;
//BSD每一层最多多少个节点
int
parameter_max_BDD_width
=
4
0000
;
//BSD每一层最多多少个节点
int
parameter_early_stop_split_nodes
=
10000
;
//BSD每一层最多多少个节点
int
parameter_early_stop_split_nodes
=
10000
00
;
//BSD每一层最多多少个节点
//全局变量
//全局变量
int
GLOBAL_which_demo_function
;
int
GLOBAL_which_demo_function
;
...
@@ -42,14 +47,12 @@ int GLOBAL_train_time;
...
@@ -42,14 +47,12 @@ int GLOBAL_train_time;
int
GLOBAL_program_time
;
int
GLOBAL_program_time
;
//待优化变量
//待优化变量
int
variable_order
[
parameter_input_bit_width
]
;
int
**
variable_order
;
int
variable_order_number
;
int
variable_order_number
;
int
BSD_execute
(
int
variable_order_number
,
int
*
variable_order
);
int
BSD_execute
(
int
variable_order_number
,
int
*
*
variable_order
,
int
partition_depth
,
int
partition_parts
);
bool
truth_table
[
1024
*
1024
];
bool
truth_table
[
1024
*
1024
];
#include"cvt.h"
#include"io_generator_function.h"
#include"BSD.h"
#include"BSD.h"
#include"next_layer_bit.h"
#include"next_layer_bit.h"
#include"tool_function.h"
#include"tool_function.h"
...
@@ -65,13 +68,23 @@ public:
...
@@ -65,13 +68,23 @@ public:
int
BSD_area
;
int
BSD_area
;
double
accuracy
;
double
accuracy
;
int
BSD_area_layers
[
parameter_input_bit_width
];
int
*
BSD_area_layers
;
int
accuracy_layers
[
parameter_input_bit_width
];
int
*
accuracy_layers
;
int
*
BDD_width_each_layer
;
int
feature_area
;
BSD_features
(){
BSD_area_layers
=
new
int
[
parameter_input_bit_width
];
accuracy_layers
=
new
int
[
parameter_input_bit_width
];
BDD_width_each_layer
=
new
int
[
parameter_input_bit_width
];
}
//int nodes_for_each_start_node[parameter_max_BDD_width];
//int nodes_for_each_start_node[parameter_max_BDD_width];
};
};
BSD_features
BSD_features_0
;
BSD_features
BSD_features_0
;
void
search_order
();
//double variable_features[parameter_input_bit_width];
void
search_order
(
int
search_iterations
,
bool
allow_partition
);
int
search_reward
(
BSD_features
BSD_features_0
);
int
search_reward
(
BSD_features
BSD_features_0
);
int
main
(
int
argc
,
char
*
argv
[]){
int
main
(
int
argc
,
char
*
argv
[]){
...
@@ -81,7 +94,6 @@ int main(int argc,char* argv[]){
...
@@ -81,7 +94,6 @@ int main(int argc,char* argv[]){
GLOBAL_BDD_nodes
=
0
;
GLOBAL_BDD_nodes
=
0
;
GLOBAL_BDD_split_nodes
=
0
;
GLOBAL_BDD_split_nodes
=
0
;
//io generator来自真值表,不来自写好的文件
//io generator来自真值表,不来自写好的文件
//char* truth_table_name = new char [100];
//char* truth_table_name = new char [100];
//int truth_table_input_width;
//int truth_table_input_width;
...
@@ -107,18 +119,22 @@ int main(int argc,char* argv[]){
...
@@ -107,18 +119,22 @@ int main(int argc,char* argv[]){
// }
// }
search_order
();
search_order
(
parameter_search_iterations
,
false
);
};
};
int
BSD_execute
(
int
variable_order_number
,
int
*
variable_order
){
int
BSD_execute
(
int
variable_order_number
,
int
*
*
variable_order
,
int
partition_depth
,
int
partition_parts
){
BDD_class
BDD_class_main
;
BDD_class
BDD_class_main
;
BDD_class_main
.
which_demo_function
=
GLOBAL_which_demo_function
;
BDD_class_main
.
which_demo_function
=
GLOBAL_which_demo_function
;
BDD_class_main
.
BSD_variable_order_number
=
variable_order_number
;
cout
<<
"This variable order: "
<<
endl
;
for
(
int
i
=
0
;
i
<
variable_order_number
;
i
++
){
for
(
int
vi
=
0
;
vi
<
parameter_max_partition_parts
;
vi
++
){
BDD_class_main
.
BSD_variable_order
[
i
]
=
variable_order
[
i
];
BDD_class_main
.
BSD_variable_order_number
=
variable_order_number
;
cout
<<
BDD_class_main
.
BSD_variable_order
[
i
]
<<
" "
;
for
(
int
i
=
0
;
i
<
variable_order_number
;
i
++
){
BDD_class_main
.
BSD_variable_order
[
vi
][
i
]
=
variable_order
[
vi
][
i
];
cout
<<
BDD_class_main
.
BSD_variable_order
[
vi
][
i
]
<<
" "
;
}
cout
<<
endl
;
}
}
cout
<<
endl
;
cout
<<
endl
;
...
@@ -137,17 +153,36 @@ int BSD_execute(int variable_order_number,int* variable_order){
...
@@ -137,17 +153,36 @@ int BSD_execute(int variable_order_number,int* variable_order){
BDD_class_main
.
most_influence
[
zi
]
=
0
;
BDD_class_main
.
most_influence
[
zi
]
=
0
;
BDD_class_main
.
BDD_width_each_layer
[
zi
]
=
0
;
BDD_class_main
.
BDD_width_each_layer
[
zi
]
=
0
;
}
}
BDD_class_main
.
partition_depth
=
partition_depth
;
BDD_class_main
.
partition_parts
=
partition_parts
;
BDD_class_main
.
BDD_FULL_PROCESS
();
BDD_class_main
.
BDD_FULL_PROCESS
();
for
(
int
zi
=
0
;
zi
<
parameter_input_bit_width
;
zi
++
){
for
(
int
zi
=
0
;
zi
<
parameter_input_bit_width
;
zi
++
){
variable_order
[
zi
]
=
BDD_class_main
.
most_influence
[
zi
];
BSD_features_0
.
BSD_area_layers
[
zi
]
=
BDD_class_main
.
split_nodes_each_layer
[
zi
];
BSD_features_0
.
BSD_area_layers
[
zi
]
=
BDD_class_main
.
split_nodes_each_layer
[
zi
];
BSD_features_0
.
accuracy_layers
[
zi
]
=
BDD_class_main
.
accuracy_each_layer
[
zi
];
BSD_features_0
.
accuracy_layers
[
zi
]
=
BDD_class_main
.
accuracy_each_layer
[
zi
];
BSD_features_0
.
BDD_width_each_layer
[
zi
]
=
BDD_class_main
.
BDD_width_each_layer
[
zi
];
}
if
(
partition_depth
>
parameter_input_bit_width
){
for
(
int
zj
=
0
;
zj
<
parameter_max_partition_parts
;
zj
++
){
for
(
int
zi
=
0
;
zi
<
parameter_input_bit_width
;
zi
++
){
variable_order
[
zj
][
zi
]
=
BDD_class_main
.
most_influence
[
zi
];
}
}
}
else
{
for
(
int
zj
=
0
;
zj
<
parameter_max_partition_parts
;
zj
++
){
for
(
int
zi
=
0
;
zi
<
parameter_input_bit_width
;
zi
++
){
variable_order
[
zj
][
zi
]
=
BDD_class_main
.
BSD_variable_order
[
zj
][
zi
];
}
}
}
}
BSD_features_0
.
BSD_depth
=
BDD_class_main
.
total_BDD_depth
+
1
;
BSD_features_0
.
BSD_depth
=
BDD_class_main
.
total_BDD_depth
+
1
;
BSD_features_0
.
BSD_area
=
BDD_class_main
.
total_split_nodes
;
BSD_features_0
.
BSD_area
=
BDD_class_main
.
total_split_nodes
_recursive
;
BSD_features_0
.
accuracy
=
BDD_class_main
.
circuit_accuracy
;
BSD_features_0
.
accuracy
=
BDD_class_main
.
circuit_accuracy
;
BSD_features_0
.
feature_area
=
BDD_class_main
.
feature_area
;
int
reward
=
search_reward
(
BSD_features_0
);
int
reward
=
search_reward
(
BSD_features_0
);
...
@@ -156,27 +191,41 @@ int BSD_execute(int variable_order_number,int* variable_order){
...
@@ -156,27 +191,41 @@ int BSD_execute(int variable_order_number,int* variable_order){
};
};
int
search_reward
(
BSD_features
BSD_features_0
){
int
search_reward
(
BSD_features
BSD_features_0
){
int
reward
=
(
1000000
*
(
1
-
BSD_features_0
.
accuracy
));
int
reward
=
(
1000000
*
double
(
1
-
BSD_features_0
.
accuracy
));
if
(
BSD_features_0
.
accuracy
<
1
)
if
(
BSD_features_0
.
accuracy
<
1
)
reward
+=
1000
*
(
parameter_input_bit_width
-
BSD_features_0
.
BSD_depth
);
reward
+=
1000
*
(
parameter_input_bit_width
-
BSD_features_0
.
BSD_depth
);
reward
+=
BSD_features_0
.
BSD_area
;
reward
+=
BSD_features_0
.
BSD_area
;
reward
+=
int
(
BSD_features_0
.
feature_area
/
100
)
;
return
reward
;
return
reward
;
};
};
void
search_order
(){
void
search_order
(
int
search_iterations
,
bool
allow_partition
){
ofstream
result_0
(
"result_0_20bit"
,
ios
::
app
);
ofstream
result_0
(
"result_0_20bit"
,
ios
::
app
);
ofstream
result_10
(
"result_10_20bit"
,
ios
::
app
);
ofstream
result_10
(
"result_10_20bit"
,
ios
::
app
);
ofstream
result_100
(
"result_100_20bit"
,
ios
::
app
);
ofstream
result_100
(
"result_100_20bit"
,
ios
::
app
);
ofstream
result_1000
(
"result_1000_20bit"
,
ios
::
app
);
ofstream
result_1000
(
"result_1000_20bit"
,
ios
::
app
);
variable_order
=
new
int
*
[
parameter_max_partition_parts
];
for
(
int
vi
=
0
;
vi
<
parameter_max_partition_parts
;
vi
++
){
variable_order
[
vi
]
=
new
int
[
parameter_input_bit_width
];
}
int
best_area
=
9999999
;
int
best_area
=
9999999
;
int
best_area_depth
=
0
;
int
best_reward
=
9999999
;
int
best_area_depth
=
2
;
int
best_BDD_split_nodes
[
parameter_input_bit_width
];
int
best_BDD_split_nodes
[
parameter_input_bit_width
];
int
best_variable_order
[
parameter_input_bit_width
]
;
int
**
best_variable_order
;
best_variable_order
=
new
int
*
[
parameter_max_partition_parts
];
for
(
int
vi
=
0
;
vi
<
parameter_max_partition_parts
;
vi
++
){
best_variable_order
[
vi
]
=
new
int
[
parameter_input_bit_width
];
}
int
area
;
int
area
;
int
reward
;
int
mutation_depth
;
int
mutation_depth
;
random_device
rd
;
random_device
rd
;
mt19937
gen
(
rd
());
mt19937
gen
(
rd
());
...
@@ -188,8 +237,15 @@ void search_order(){
...
@@ -188,8 +237,15 @@ void search_order(){
int
best_area_100
;
int
best_area_100
;
int
best_area_1000
;
int
best_area_1000
;
for
(
int
i
=
0
;
i
<
10
;
i
++
){
int
best_iteration
=
0
;
int
partition_depth
=
1000
;
int
partition_parts
=
2
;
int
best_partition_depth
=
10000
;
int
best_partition_parts
=
2
;
int
learning_rate
;
for
(
int
i
=
0
;
i
<
search_iterations
;
i
++
){
GLOBAL_BDD_id_number
+=
1
;
if
(
i
==
1
){
if
(
i
==
1
){
result_0
<<
best_area
<<
endl
;
result_0
<<
best_area
<<
endl
;
...
@@ -198,68 +254,89 @@ void search_order(){
...
@@ -198,68 +254,89 @@ void search_order(){
else
if
(
i
==
11
){
else
if
(
i
==
11
){
result_10
<<
best_area
<<
endl
;
result_10
<<
best_area
<<
endl
;
best_area_10
=
best_area
;
best_area_10
=
best_area
;
if
(
best_area_10
==
best_area_0
){
i
=
90
;
}
}
}
else
if
(
i
==
101
){
else
if
(
i
==
101
){
result_100
<<
best_area
<<
endl
;
result_100
<<
best_area
<<
endl
;
best_area_100
=
best_area
;
best_area_100
=
best_area
;
if
(
best_area_100
==
best_area_10
){
i
=
990
;
}
}
}
else
if
(
i
==
999
){
else
if
(
i
==
999
){
result_1000
<<
best_area
<<
endl
;
result_1000
<<
best_area
<<
endl
;
}
}
parameter_max_BDD_width
=
4000
;
int
parameter_learning_rate
=
1
;
mutation_depth
=
int
(
best_area_depth
);
if
(
best_area
>
10000
){
parameter_learning_rate
=
5
;
}
else
if
(
best_area
>
6000
)
parameter_learning_rate
=
4
;
else
if
(
i
-
best_iteration
>
2000
)
parameter_learning_rate
=
3
;
else
if
(
i
-
best_iteration
>
800
)
parameter_learning_rate
=
2
;
learning_rate
=
1
+
gen
()
%
parameter_learning_rate
;
mutation_depth
=
int
(
best_area_depth
/
2
);
if
(
mutation_depth
>
best_area_depth
)
mutation_depth
=
best_area_depth
;
int
min_feature
=
9999999
;
int
min_feature
=
9999999
;
cout
<<
"Current best variable order: "
<<
endl
;
cout
<<
"Mutation Depth:"
<<
mutation_depth
<<
endl
;
for
(
int
vj
=
0
;
vj
<
parameter_max_partition_parts
;
vj
++
){
for
(
int
vi
=
0
;
vi
<
mutation_depth
;
vi
++
){
for
(
int
vi
=
0
;
vi
<
best_area_depth
;
vi
++
){
variable_order
[
vi
]
=
best_variable_order
[
vi
];
variable_order
[
vj
][
vi
]
=
best_variable_order
[
vj
][
vi
];
feature_variable
[
variable_order
[
vi
]]
=
9999999
;
cout
<<
variable_order
[
vj
][
vi
]
<<
" "
;
cout
<<
variable_order
[
vi
]
<<
" "
;
}
cout
<<
endl
;
}
}
cout
<<
endl
;
cout
<<
endl
;
int
learning_rate
;
//if(i<100)
if
(
i
<
10000
)
// learning_rate= int((100-i)/10);
learning_rate
=
int
((
10000
-
i
)
/
1000
);
//else
else
// learning_rate= 2;
learning_rate
=
1
;
for
(
int
zi
=
0
;
zi
<
learning_rate
;
zi
++
){
for
(
int
vv
=
0
;
vv
<
parameter_max_partition_parts
;
vv
++
){
for
(
int
vi
=
1
;
vi
<
best_area_depth
;
vi
++
){
if
(
(
gen
()
%
int
(
1
+
best_area_depth
)
==
0
)){
int
vii
=
vi
-
1
;
int
x
=
variable_order
[
vv
][
vi
];
variable_order
[
vv
][
vi
]
=
variable_order
[
vv
][
vii
];
variable_order
[
vv
][
vii
]
=
x
;
//double y = variable_features[vi];
//variable_features[vi] = variable_features[vii];
//variable_features[vii] = y;
break
;
}
}
int
num_a
=
gen
()
%
int
(
1
+
best_area_depth
);
int
num_b
=
gen
()
%
int
(
1
+
best_area_depth
/
4
);
int
num_c
=
gen
()
%
int
(
1
+
best_area_depth
/
2
);
for
(
int
vc
=
0
;
vc
<
num_c
;
vc
++
){
int
x
=
variable_order
[
vv
][
num_a
];
for
(
int
vj
=
0
;
vj
<
num_b
;
vj
++
){
if
(
(
vj
==
(
num_b
-
1
))){
variable_order
[
vv
][(
num_a
+
vj
)
%
int
(
best_area_depth
)]
=
x
;
}
else
variable_order
[
vv
][(
num_a
+
vj
)
%
int
(
best_area_depth
)]
=
variable_order
[
vv
][(
num_a
+
vj
+
1
)
%
int
(
best_area_depth
)];
}
}
if
(
mutation_depth
>
learning_rate
){
for
(
int
vi
=
0
;
vi
<
best_area_depth
;
vi
++
){
if
(
i
%
2
==
0
){
for
(
int
vj
=
0
;
vj
<
vi
;
vj
++
){
for
(
int
vi
=
0
;
vi
<
learning_rate
;
vi
++
){
if
(
variable_order
[
vv
][
vi
]
==
variable_order
[
vv
][
vj
]){
int
num_a
=
gen
()
%
int
(
mutation_depth
);
for
(
int
vk
=
0
;
vk
<
best_area_depth
-
vi
-
1
;
vk
++
)
int
num_b
=
gen
()
%
int
(
mutation_depth
);
variable_order
[
vv
][
vi
+
vk
]
=
variable_order
[
vv
][
vi
+
vk
+
1
];
int
x
=
variable_order
[
num_a
];
}
variable_order
[
num_a
]
=
variable_order
[
num_b
];
}
variable_order
[
num_b
]
=
x
;
}
}
}
else
{
for
(
int
vi
=
0
;
vi
<
learning_rate
;
vi
++
){
int
num_a
=
gen
()
%
int
(
mutation_depth
);
int
num_b
=
(
num_a
!=
mutation_depth
-
1
)
?
(
num_a
+
1
)
:
(
num_a
-
1
);
int
x
=
variable_order
[
num_a
];
variable_order
[
num_a
]
=
variable_order
[
num_b
];
variable_order
[
num_b
]
=
x
;
}
}
}
}
else
{
}
for
(
int
vi
=
0
;
vi
<
mutation_depth
;
vi
++
){
int
num_a
=
gen
()
%
int
(
mutation_depth
);
int
num_b
=
gen
()
%
int
(
mutation_depth
);
int
x
=
variable_order
[
num_a
];
variable_order
[
num_a
]
=
variable_order
[
num_b
];
variable_order
[
num_b
]
=
x
;
}
}
//for(int j=mutation_depth;j<parameter_input_bit_width;j++){
//for(int j=mutation_depth;j<parameter_input_bit_width;j++){
// for (int vi=0;vi<parameter_input_bit_width;vi++){
// for (int vi=0;vi<parameter_input_bit_width;vi++){
// if(feature_variable[vi]<min_feature){
// if(feature_variable[vi]<min_feature){
...
@@ -271,32 +348,72 @@ void search_order(){
...
@@ -271,32 +348,72 @@ void search_order(){
// feature_variable[variable_order[j]] = 9999999;
// feature_variable[variable_order[j]] = 9999999;
//}
//}
if
(
i
==
0
){
area
=
BSD_execute
(
0
,
variable_order
);
if
(
i
<
10
){
reward
=
BSD_execute
(
0
,
variable_order
,
partition_depth
,
partition_parts
);
}
}
else
{
else
{
area
=
BSD_execute
(
mutation_depth
,
variable_order
);
reward
=
BSD_execute
(
best_area_depth
,
variable_order
,
partition_depth
,
partition_parts
);
if
(
allow_partition
){
partition_depth
=
4
;
}
}
}
bool
accept
;
//accept = (reward <= best_reward);
double
accept_ratio
=
double
(
reward
)
/
double
(
best_reward
);
if
(
accept_ratio
<
1
)
accept
=
1
;
else
if
(
accept_ratio
==
1
){
if
(
gen
()
%
2
==
0
)
accept
=
1
;
else
accept
=
0
;
}
else
if
(
accept_ratio
>
1.05
)
accept
=
0
;
else
{
int
k
=
(
1.05
-
accept_ratio
)
*
100
;
if
(
gen
()
%
100
<
k
)
accept
=
1
;
else
accept
=
0
;
}
if
(
area
<
best_area
){
if
(
accept
){
best_area
=
area
;
best_iteration
=
i
;
best_reward
=
reward
;
best_area
=
BSD_features_0
.
BSD_area
;
best_area_depth
=
BSD_features_0
.
BSD_depth
;
best_area_depth
=
BSD_features_0
.
BSD_depth
;
for
(
int
vi
=
0
;
vi
<
BSD_features_0
.
BSD_depth
;
vi
++
){
best_partition_depth
=
partition_depth
;
best_variable_order
[
vi
]
=
variable_order
[
vi
];
best_partition_parts
=
partition_parts
;
for
(
int
vi
=
0
;
vi
<
parameter_input_bit_width
;
vi
++
){
for
(
int
vj
=
0
;
vj
<
parameter_max_partition_parts
;
vj
++
){
best_variable_order
[
vj
][
vi
]
=
variable_order
[
vj
][
vi
];
}
best_BDD_split_nodes
[
vi
]
=
BSD_features_0
.
BSD_area_layers
[
vi
];
best_BDD_split_nodes
[
vi
]
=
BSD_features_0
.
BSD_area_layers
[
vi
];
//variable_features[vi] = double(BSD_features_0.BDD_width_each_layer[vi+1]) / double(BSD_features_0.BDD_width_each_layer[vi]);
//cout<<variable_features[vi]<<" ";
}
}
parameter_early_stop_split_nodes
=
best_area
+
10
;
cout
<<
"#############################"
<<
endl
;
cout
<<
"## This order accept #"
<<
endl
;
cout
<<
"#############################"
<<
endl
;
parameter_early_stop_split_nodes
=
int
(
reward
*
1.05
);
}
}
cout
<<
endl
;
cout
<<
endl
;
cout
<<
"Design Area: "
<<
area
<<
endl
;
cout
<<
"Best Iteration: "
<<
best_iteration
<<
endl
;
cout
<<
"Best Design Area: "
<<
best_area
<<
endl
;
cout
<<
"This Iteration: "
<<
i
<<
endl
;
cout
<<
"Reward: "
<<
reward
<<
endl
;
cout
<<
"Best Reward: "
<<
best_reward
<<
endl
;
cout
<<
"Area: "
<<
BSD_features_0
.
BSD_area
<<
endl
;
cout
<<
"Best Area: "
<<
best_area
<<
endl
;
//cout<<"Best Design Area: "<<BSD_features_0.BSD_area<<endl;
cout
<<
endl
;
cout
<<
endl
;
}
}
parameter_early_stop_split_nodes
=
999999
;
parameter_early_stop_split_nodes
=
999999
99
;
area
=
BSD_execute
(
parameter_input_bit_width
,
best_variable_order
);
area
=
BSD_execute
(
parameter_input_bit_width
,
best_variable_order
,
best_partition_depth
,
best_partition_parts
);
};
};
src/BSD.h
View file @
5df737e0
...
@@ -10,7 +10,7 @@ public:
...
@@ -10,7 +10,7 @@ public:
bool
right_node_neg
=
0
;
bool
right_node_neg
=
0
;
int
non_equal_number
=
0
;
int
non_equal_number
=
0
;
bool
has_equal_father
=
0
;
bool
has_equal_father
=
0
;
bool
which_root_node_all
[
1
00
1
]
=
{
0
};
bool
which_root_node_all
[
1
1
1
]
=
{
0
};
int
which_root_node
=
0
;
int
which_root_node
=
0
;
int
which_bit_output
=
0
;
int
which_bit_output
=
0
;
...
@@ -121,7 +121,8 @@ public:
...
@@ -121,7 +121,8 @@ public:
bool
*
left_mask_output_data_all
;
bool
*
left_mask_output_data_all
;
bool
*
right_mask_output_data_all
;
bool
*
right_mask_output_data_all
;
int
partition_depth
=
1000
;
int
partition_depth
=
10
;
int
partition_parts
=
2
;
int
partition_into_how_many_parts
=
2
;
int
partition_into_how_many_parts
=
2
;
int
*
partition_start_node_numbers
;
int
*
partition_start_node_numbers
;
int
**
partition_index
;
int
**
partition_index
;
...
@@ -132,12 +133,12 @@ public:
...
@@ -132,12 +133,12 @@ public:
int
BSD_samples_train_each_layer
();
int
BSD_samples_train_each_layer
();
int
BSD_samples_sort_each_layer
();
int
BSD_samples_sort_each_layer
();
int
BSD_variable_order
[
parameter_input_bit_width
]
;
int
**
BSD_variable_order
;
int
BSD_variable_order_number
;
int
BSD_variable_order_number
;
int
feature_area
;
int
*
split_nodes_each_layer
;
int
split_nodes_each_layer
[
parameter_input_bit_width
+
1
];
int
*
accuracy_each_layer
;
int
accuracy_each_layer
[
parameter_input_bit_width
+
1
];
BDD_class
(){
BDD_class
(){
most_influence
=
new
int
[
parameter_input_bit_width
];
most_influence
=
new
int
[
parameter_input_bit_width
];
...
@@ -159,7 +160,9 @@ public:
...
@@ -159,7 +160,9 @@ public:
left_mask_output_data_all
=
new
bool
[
long
(
parameter_max_BDD_width
)
*
long
(
parameter_max_samples
)];
left_mask_output_data_all
=
new
bool
[
long
(
parameter_max_BDD_width
)
*
long
(
parameter_max_samples
)];
right_mask_output_data_all
=
new
bool
[
long
(
parameter_max_BDD_width
)
*
long
(
parameter_max_samples
)];
right_mask_output_data_all
=
new
bool
[
long
(
parameter_max_BDD_width
)
*
long
(
parameter_max_samples
)];
split_nodes_each_layer
=
new
int
[
parameter_input_bit_width
+
1
];
accuracy_each_layer
=
new
int
[
parameter_input_bit_width
+
1
];
BSD_variable_order
=
new
int
*
[
parameter_max_partition_parts
];
};
};
...
@@ -233,6 +236,8 @@ int BDD_class::train_BDD(BDD_node** BDD,int* most_influence,int start_depth, int
...
@@ -233,6 +236,8 @@ int BDD_class::train_BDD(BDD_node** BDD,int* most_influence,int start_depth, int
int
root_nodes_leafs
[
how_many_start_nodes
];
int
root_nodes_leafs
[
how_many_start_nodes
];
int
leaf_nodes_roots
[
how_many_start_nodes
];
int
leaf_nodes_roots
[
how_many_start_nodes
];
feature_area
=
0
;
for
(
i
=
0
;
i
<
start_depth
+
1
;
i
++
)
for
(
i
=
0
;
i
<
start_depth
+
1
;
i
++
)
BDD
[
i
]
=
new
BDD_node
[
how_many_start_nodes
];
BDD
[
i
]
=
new
BDD_node
[
how_many_start_nodes
];
for
(
i
=
0
;
i
<
how_many_start_nodes
;
i
++
){
for
(
i
=
0
;
i
<
how_many_start_nodes
;
i
++
){
...
@@ -271,10 +276,11 @@ int BDD_class::train_BDD(BDD_node** BDD,int* most_influence,int start_depth, int
...
@@ -271,10 +276,11 @@ int BDD_class::train_BDD(BDD_node** BDD,int* most_influence,int start_depth, int
}
}
total_nodes_amount_recursive
=
total_nodes_amount
;
total_nodes_amount_recursive
=
total_nodes_amount
;
total_split_nodes_recursive
=
total_split_nodes
;
total_split_nodes_recursive
=
total_split_nodes
;
bool
this_layer_need_partition
=
(
i
==
partition_depth
)
&&
(
BDD_width_each_layer
[
i
]
>
100
);
feature_area
+=
total_nodes_amount
;
bool
this_layer_need_partition
=
(
i
==
partition_depth
);
if
(
this_layer_need_partition
){
if
(
this_layer_need_partition
){
cout
<<
"go for partition"
<<
endl
;
cout
<<
"go for partition"
<<
endl
;
partition_into_how_many_parts
=
m
ax
(
2
,
int
(
BDD_width_each_layer
[
i
]
/
100
));
partition_into_how_many_parts
=
m
in
(
2
,
int
(
partition_parts
));
BDD_partition
=
new
BDD_class
[
partition_into_how_many_parts
];
BDD_partition
=
new
BDD_class
[
partition_into_how_many_parts
];
partition_start_node_numbers
=
new
int
[
partition_into_how_many_parts
];
partition_start_node_numbers
=
new
int
[
partition_into_how_many_parts
];
partition_index
=
new
int
*
[
partition_into_how_many_parts
];
partition_index
=
new
int
*
[
partition_into_how_many_parts
];
...
@@ -309,6 +315,7 @@ int BDD_class::train_BDD(BDD_node** BDD,int* most_influence,int start_depth, int
...
@@ -309,6 +315,7 @@ int BDD_class::train_BDD(BDD_node** BDD,int* most_influence,int start_depth, int
for
(
int
zj
=
0
;
zj
<
parameter_input_bit_width
+
1
;
zj
++
){
for
(
int
zj
=
0
;
zj
<
parameter_input_bit_width
+
1
;
zj
++
){
BDD_partition
[
zi
].
has_been_unfold
[
zj
]
=
has_been_unfold
[
zj
];
BDD_partition
[
zi
].
has_been_unfold
[
zj
]
=
has_been_unfold
[
zj
];
BDD_partition
[
zi
].
most_influence
[
zj
]
=
most_influence
[
zj
];
BDD_partition
[
zi
].
most_influence
[
zj
]
=
most_influence
[
zj
];
BDD_partition
[
zi
].
BSD_variable_order
[
0
][
zj
]
=
BSD_variable_order
[
zi
+
1
][
zj
];
}
}
for
(
int
zj
=
0
;
zj
<
BDD_partition
[
zi
].
how_many_start_nodes
;
zj
++
){
for
(
int
zj
=
0
;
zj
<
BDD_partition
[
zi
].
how_many_start_nodes
;
zj
++
){
if
(
partition_index
[
zi
][
zj
]
<
BDD_width_each_layer
[
i
]){
if
(
partition_index
[
zi
][
zj
]
<
BDD_width_each_layer
[
i
]){
...
@@ -372,12 +379,20 @@ int BDD_class::train_BDD(BDD_node** BDD,int* most_influence,int start_depth, int
...
@@ -372,12 +379,20 @@ int BDD_class::train_BDD(BDD_node** BDD,int* most_influence,int start_depth, int
delete
[]
simplify_list
;
delete
[]
simplify_list
;
delete
[]
mask_input_data
;
delete
[]
mask_input_data
;
delete
[]
split_nodes_each_layer
;
delete
[]
accuracy_each_layer
;
for
(
int
zj
=
0
;
zj
<
parameter_max_partition_parts
;
zj
++
){
delete
[]
BSD_variable_order
[
zj
]
;
}
delete
[]
BSD_variable_order
;
for
(
zi
=
0
;
zi
<
partition_into_how_many_parts
;
zi
++
){
for
(
zi
=
0
;
zi
<
partition_into_how_many_parts
;
zi
++
){
BDD_partition
[
zi
].
BDD_FULL_PROCESS
();
BDD_partition
[
zi
].
BDD_FULL_PROCESS
();
total_nodes_amount_recursive
+=
BDD_partition
[
zi
].
total_nodes_amount_recursive
;
total_nodes_amount_recursive
+=
BDD_partition
[
zi
].
total_nodes_amount_recursive
;
total_split_nodes_recursive
+=
BDD_partition
[
zi
].
total_split_nodes_recursive
;
total_split_nodes_recursive
+=
BDD_partition
[
zi
].
total_split_nodes_recursive
;
//}
//}
}
}
cout
<<
"BSD total split nodes recursive = "
<<
total_split_nodes_recursive
<<
endl
;
break
;
break
;
}
}
...
@@ -480,7 +495,7 @@ int BDD_class::train_BDD(BDD_node** BDD,int* most_influence,int start_depth, int
...
@@ -480,7 +495,7 @@ int BDD_class::train_BDD(BDD_node** BDD,int* most_influence,int start_depth, int
break
;
break
;
}
}
}
}
if
((
i
==
(
parameter_early_stop_depth
-
1
))
&&
(
which_BDD
==
0
)
||
((
i
==
(
parameter_early_stop_depth
-
1
))
&&
(
which_BDD
==
1
))
||
(
total_split_nodes
>
parameter_early_stop_split_nodes
)){
if
((
i
==
(
parameter_early_stop_depth
-
1
))
&&
(
which_BDD
==
0
)
||
((
i
==
(
parameter_early_stop_depth
-
1
))
&&
(
which_BDD
==
1
))
||
(
(
total_split_nodes_recursive
+
feature_area
/
100
)
>
parameter_early_stop_split_nodes
)){
if
(
left_mask_output_data_sum
>
(
BSD_samples
/
2
)){
if
(
left_mask_output_data_sum
>
(
BSD_samples
/
2
)){
all_one_left
=
1
;
all_one_left
=
1
;
all_zero_left
=
0
;
all_zero_left
=
0
;
...
@@ -708,9 +723,12 @@ int BDD_class::train_BDD(BDD_node** BDD,int* most_influence,int start_depth, int
...
@@ -708,9 +723,12 @@ int BDD_class::train_BDD(BDD_node** BDD,int* most_influence,int start_depth, int
split_nodes_each_layer
[
i
]
=
total_split_nodes
;
split_nodes_each_layer
[
i
]
=
total_split_nodes
;
accuracy_each_layer
[
i
]
=
((
total_finish_weight
)
/
pow
(
2
.
0
,
20
))
/
double
(
parameter_output_bit_width
);
accuracy_each_layer
[
i
]
=
((
total_finish_weight
)
/
pow
(
2
.
0
,
20
))
/
double
(
parameter_output_bit_width
);
total_nodes_amount_recursive
=
total_nodes_amount
;
total_split_nodes_recursive
=
total_split_nodes
;
cout
<<
"BSD "
<<
BDD_id
<<
" nodes = "
<<
total_nodes_amount
<<
endl
;
cout
<<
"BSD "
<<
BDD_id
<<
" nodes = "
<<
total_nodes_amount
<<
endl
;
cout
<<
"BSD "
<<
BDD_id
<<
" split nodes = "
<<
total_split_nodes
;
cout
<<
"BSD "
<<
BDD_id
<<
" split nodes = "
<<
total_split_nodes
<<
endl
;
cout
<<
"BSD "
<<
BDD_id
<<
" feature area = "
<<
feature_area
;
cout
<<
" Finish trained weight = "
<<
setprecision
(
12
)
<<
(
total_finish_weight
)
/
pow
(
2
.
0
,
20
)
<<
endl
;
cout
<<
" Finish trained weight = "
<<
setprecision
(
12
)
<<
(
total_finish_weight
)
/
pow
(
2
.
0
,
20
)
<<
endl
;
gettimeofday
(
&
finish_time
,
NULL
);
gettimeofday
(
&
finish_time
,
NULL
);
train_time
=
double
(
finish_time
.
tv_usec
-
start_time
.
tv_usec
+
1000000
*
(
finish_time
.
tv_sec
-
start_time
.
tv_sec
))
/
1000000
;
train_time
=
double
(
finish_time
.
tv_usec
-
start_time
.
tv_usec
+
1000000
*
(
finish_time
.
tv_sec
-
start_time
.
tv_sec
))
/
1000000
;
...
@@ -849,7 +867,6 @@ int BDD_class::BDD_FULL_PROCESS(){
...
@@ -849,7 +867,6 @@ int BDD_class::BDD_FULL_PROCESS(){
gettimeofday
(
&
initial_start_time
,
NULL
);
gettimeofday
(
&
initial_start_time
,
NULL
);
gettimeofday
(
&
start_time
,
NULL
);
gettimeofday
(
&
start_time
,
NULL
);
BDD_id
=
GLOBAL_BDD_id_number
;
BDD_id
=
GLOBAL_BDD_id_number
;
GLOBAL_BDD_id_number
+=
1
;
cout
<<
"switch_BDD: "
<<
BDD_id
<<
endl
;
cout
<<
"switch_BDD: "
<<
BDD_id
<<
endl
;
cout
<<
"######################################################################"
<<
endl
;
cout
<<
"######################################################################"
<<
endl
;
...
@@ -867,12 +884,15 @@ int BDD_class::BDD_FULL_PROCESS(){
...
@@ -867,12 +884,15 @@ int BDD_class::BDD_FULL_PROCESS(){
for
(
j
=
0
;
j
<
parameter_max_samples
;
j
++
){
for
(
j
=
0
;
j
<
parameter_max_samples
;
j
++
){
mask_input_data
[
j
]
=
new
bool
[
parameter_input_bit_width
*
2
];
mask_input_data
[
j
]
=
new
bool
[
parameter_input_bit_width
*
2
];
}
}
for
(
j
=
0
;
j
<
parameter_max_partition_parts
;
j
++
){
BSD_variable_order
[
j
]
=
new
int
[
parameter_input_bit_width
];
}
for
(
int
zi
=
0
;
zi
<
parameter_max_BDD_width
;
zi
++
){
for
(
int
zi
=
0
;
zi
<
parameter_max_BDD_width
;
zi
++
){
simplify_list
[
zi
]
=
new
bool
[
parameter_max_samples
];
simplify_list
[
zi
]
=
new
bool
[
parameter_max_samples
];
}
}
train_BDD
(
BDD
,
most_influence
,
start_depth
,
how_many_start_nodes
,
start_nodes
);
train_BDD
(
BDD
,
most_influence
,
start_depth
,
how_many_start_nodes
,
start_nodes
);
BDD_infer
(
BDD
,
most_influence
);
BDD_infer
(
BDD
,
most_influence
);
print_circuit
(
BDD
,
most_influence
);
//
print_circuit(BDD,most_influence);
delete
[]
test_input_data
;
delete
[]
test_input_data
;
//GLOBAL_BDD_nodes += total_nodes_amount;
//GLOBAL_BDD_nodes += total_nodes_amount;
...
...
src/io_generator_function.h
View file @
5df737e0
...
@@ -28,82 +28,10 @@ bool* io_generator_alu_function_5(bool* input_data,bool* output_data);
...
@@ -28,82 +28,10 @@ bool* io_generator_alu_function_5(bool* input_data,bool* output_data);
bool
*
io_generator_cpu_function_1
(
bool
*
input_data
,
bool
*
output_data
);
//add_shift
bool
*
io_generator_cpu_function_1
(
bool
*
input_data
,
bool
*
output_data
);
//add_shift
#include"io_generator/cpp_comb/parallel_serial_16.h"
//#include"io_generator/cpp_comb/parallel_serial_16.h"
//#include"patch.h"
bool
*
io_generator_function
(
bool
input_data
[
parameter_input_bit_width
],
int
which_demo_function
,
bool
*
output_data
)
{
//bool* output_data = new bool [parameter_input_bit_width*2];
int
i
,
j
;
for
(
i
=
0
;
i
<
parameter_output_bit_width
;
i
++
){
output_data
[
i
]
=
0
;
}
///if(which_demo_function!=9999){
/// switch(which_demo_function){
/// case 0: io_generator_single_function_0 (input_data,output_data);break;
/// case 1: io_generator_single_function_1 (input_data,output_data);break;
/// case 2: io_generator_single_function_2 (input_data,output_data);break;
/// case 3: io_generator_single_function_3 (input_data,output_data);break;
/// case 4: io_generator_single_function_4 (input_data,output_data);break;
/// case 5: io_generator_single_function_5 (input_data,output_data);break;
/// case 6: io_generator_single_function_6 (input_data,output_data);break;
/// case 7: io_generator_single_function_7 (input_data,output_data);break;
/// case 8: io_generator_single_function_8 (input_data,output_data);break;
/// case 9: io_generator_single_function_9 (input_data,output_data);break;
/// case 10: io_generator_single_function_10(input_data,output_data);break;
/// case 11: io_generator_single_function_11(input_data,output_data);break;
/// case 12: io_generator_single_function_12(input_data,output_data);break;
/// case 13: io_generator_single_function_13(input_data,output_data);break;
/// case 14: io_generator_single_function_14(input_data,output_data);break;
/// case 15: io_generator_single_function_15(input_data,output_data);break;
/// case 16: io_generator_alu_function_1 (input_data,output_data);break;
/// case 17: io_generator_alu_function_2 (input_data,output_data);break;
/// case 18: io_generator_alu_function_3 (input_data,output_data);break;
/// case 19: io_generator_alu_function_4 (input_data,output_data);break;
/// case 20: io_generator_alu_function_5 (input_data,output_data);break;
/// case 21: io_generator_single_function_mul(input_data,output_data);break;
/// case 22: io_generator_single_function_fp32_add(input_data,output_data);break;
/// }
///}
///else{
/// io_generator_outer(input_data,output_data);
/// //long data = cvt_bit_to_number_unsigned(input_data,parameter_input_bit_width);
/// //for(i=0;i<parameter_output_bit_width;i++){
/// // output_data[i] = truth_table[data];
/// //}
///}
io_generator_outer
(
input_data
,
output_data
);
//long data = cvt_bit_to_number_unsigned(input_data,parameter_input_bit_width);
// for(i=0;i<parameter_output_bit_width;i++){
// output_data[i] = truth_table[data];
// }
//bool* reg_data_a = new bool [parameter_CPU_data_width];
//bool* reg_data_b = new bool [parameter_CPU_data_width];
//
//bool* op_code = new bool[5];
//bool* reg_data_a_index = new bool[5];
//bool* reg_data_b_index = new bool[5];
//int number_reg_data_a_index;
//int number_reg_data_b_index;
//int number_op_code;
//int i,j,zi,zj;
//for(i=0;i<5;i++){
// reg_data_a_index[i] = input_data[128+i];
// reg_data_b_index[i] = input_data[133+i];
// op_code[i] = input_data[138+i];
//}
//number_reg_data_a_index = cvt_bit_to_number(reg_data_a_index,5)%4;
//number_reg_data_b_index = cvt_bit_to_number(reg_data_b_index,5)%4;
//number_op_code = cvt_bit_to_number(op_code,5);
//for(i=0;i<parameter_CPU_data_width;i++){
// reg_data_a[i] = input_data[32*number_reg_data_a_index+i];
// reg_data_b[i] = input_data[32*number_reg_data_b_index+i];
//}
return
output_data
;
}
bool
*
io_generator_single_function_0
(
bool
*
input_data
,
bool
*
output_data
){
//==
bool
*
io_generator_single_function_0
(
bool
*
input_data
,
bool
*
output_data
){
//==
int
i
,
j
;
int
i
,
j
;
...
...
src/next_layer_bit.h
View file @
5df737e0
...
@@ -117,14 +117,14 @@ int BDD_class::next_bit_layer_single(int depth,int which_node_this_layer){
...
@@ -117,14 +117,14 @@ int BDD_class::next_bit_layer_single(int depth,int which_node_this_layer){
int
BDD_class
::
next_bit_layer
(
int
depth
){
int
BDD_class
::
next_bit_layer
(
int
depth
){
cout
<<
depth
<<
" "
<<
BSD_variable_order_number
<<
endl
;
cout
<<
depth
<<
" "
<<
BSD_variable_order_number
<<
endl
;
if
(
depth
<
BSD_variable_order_number
){
if
(
(
depth
<
BSD_variable_order_number
)
){
most_influence
[
depth
]
=
BSD_variable_order
[
depth
];
most_influence
[
depth
]
=
BSD_variable_order
[
0
][
depth
];
has_been_unfold
[
most_influence
[
depth
]]
=
1
;
has_been_unfold
[
most_influence
[
depth
]]
=
1
;
cout
<<
most_influence
[
depth
]
<<
endl
;
cout
<<
most_influence
[
depth
]
<<
endl
;
return
BSD_variable_order
[
depth
];
return
BSD_variable_order
[
0
][
depth
];
}
}
else
else
return
next_bit_layer_
0
(
depth
);
return
next_bit_layer_
1
(
depth
);
}
}
int
BDD_class
::
next_bit_layer_1
(
int
depth
){
int
BDD_class
::
next_bit_layer_1
(
int
depth
){
...
@@ -357,7 +357,7 @@ int BDD_class::next_bit_layer_0(int depth){
...
@@ -357,7 +357,7 @@ int BDD_class::next_bit_layer_0(int depth){
}
}
}
}
int
BSD_samples_influence
=
BSD_samples_influence_max
;
int
BSD_samples_influence
=
BSD_samples_influence_max
;
for
(
zz
=
0
;
zz
<
10
0
;
zz
++
){
for
(
zz
=
0
;
zz
<
10
;
zz
++
){
if
(
depth
<
parameter_multi_output_index
){
if
(
depth
<
parameter_multi_output_index
){
break
;
break
;
}
}
...
@@ -465,12 +465,12 @@ int BDD_class::next_bit_layer_0(int depth){
...
@@ -465,12 +465,12 @@ int BDD_class::next_bit_layer_0(int depth){
double
amount_turn_max_divide_average
=
amount_turn_static
[
most_influence_next
]
/
amount_turn_average
;
double
amount_turn_max_divide_average
=
amount_turn_static
[
most_influence_next
]
/
amount_turn_average
;
double
amount_turn_max_ratio
=
amount_turn
[
most_influence_next
]
/
(
zz
+
1
);
double
amount_turn_max_ratio
=
amount_turn
[
most_influence_next
]
/
(
zz
+
1
);
//USE_THIS:BEST
//USE_THIS:BEST
//
if((depth<parameter_input_bit_width-2) ){
if
((
depth
<
parameter_input_bit_width
-
2
)
){
//
if((amount_turn_max_divide_average < 4) || (amount_turn_max_ratio < 0.3) || ((amount_turn_max_ratio>0.8)&&((amount_turn_max_ratio<0.999)))){
if
((
amount_turn_max_divide_average
<
4
)
||
(
amount_turn_max_ratio
<
0
.
3
)
||
((
amount_turn_max_ratio
>
0
.
8
)
&&
((
amount_turn_max_ratio
<
0
.
999
)))){
//
has_been_unfold[most_influence_next] = 0;
has_been_unfold
[
most_influence_next
]
=
0
;
//
most_influence_next = 999999;
most_influence_next
=
999999
;
//
}
}
//
}
}
//delete[]amount_turn;
//delete[]amount_turn;
return
most_influence_next
;
return
most_influence_next
;
};
};
src/readme.md
View file @
5df737e0
src/
src/
The latest version of the BSD Learner.
Still working for the first released version on Github.
The latest version of the BSD Learner.
BSD.cpp main code of our algorithm
1.
Use BSD_Learner to design your own circuit.
cvt.h head and some tool functions
print_circuit.h turn the graph into verilog
1.
When we want more accurate/complex circuit:
Edit top.h:
BSD.cpp line 20: This parameter "bit_width" means total input bit amounts.
Line 1: modify input bitwidth;
line 21: If accuracy is not enough, get this parameter larger. In CPU tapeout task, it is set from 200k to 1M.
Line 2: modify output bitwidth;
line 24: This paramter means how many root nodes of one BSD.
Line 3: include your own io_generator file.
line 29: If BSD is not efficient enough in merging nodes together, get this parameter larger may help.
Note that this parameter should not be larger than line 21
line 32: How many samples are there in the test set. Should be larger if we want more accurate circuits.
line 41: The biggest BDD width. Could be smaller in the demo case, but should be large if we are facing more complex circuit.
2.
When we are doing ablation study/tradeoff:
BSD.cpp line 22: Set to a larger number than "bit_width", this program produces a decision tree.
line 31: A tradeoff between time/area, set to 1 (default) is the slowest but most area effient. Set to other N+ is quicker.
line 34: Until XX depth to stop expansion. It is a time/accuracy tradeoff. Default is the most accurate.
src/top.h
0 → 100644
View file @
5df737e0
extern
const
int
parameter_input_bit_width
=
33
+
6
;
//输入bit有几位,写在+6前面。+6是为了防止一些bug的冗余设计。
extern
const
int
parameter_output_bit_width
=
1
;
//输出bit有几位
#include"io_generator/c1908.h"
bool
*
io_generator_function
(
bool
input_data
[
parameter_input_bit_width
],
int
which_demo_function
,
bool
*
output_data
)
{
int
i
,
j
;
for
(
i
=
0
;
i
<
parameter_output_bit_width
;
i
++
){
output_data
[
i
]
=
0
;
}
io_generator_outer
(
input_data
,
output_data
);
output_data
[
0
]
=
output_data
[
12
];
return
output_data
;
}
src/zstart.sh
View file @
5df737e0
...
@@ -2,5 +2,5 @@ export PATH=/lustre/S/chengshuyao/haoshiming/anaconda3/envs/BSD/bin:/bin:/lustre
...
@@ -2,5 +2,5 @@ export PATH=/lustre/S/chengshuyao/haoshiming/anaconda3/envs/BSD/bin:/bin:/lustre
export
LIBRARY_PATH
=
/lustre/S/chengshuyao/haoshiming/anaconda3/envs/BSD/bin:/lustre/S/chengshuyao/haoshiming/anaconda3/envs/BSD/lib
export
LIBRARY_PATH
=
/lustre/S/chengshuyao/haoshiming/anaconda3/envs/BSD/bin:/lustre/S/chengshuyao/haoshiming/anaconda3/envs/BSD/lib
export
LD_LIBRARY_PATH
=
/lustre/S/chengshuyao/haoshiming/anaconda3/envs/BSD/bin:/lustre/S/chengshuyao/haoshiming/anaconda3/envs/BSD/lib
export
LD_LIBRARY_PATH
=
/lustre/S/chengshuyao/haoshiming/anaconda3/envs/BSD/bin:/lustre/S/chengshuyao/haoshiming/anaconda3/envs/BSD/lib
rm rtl/
*
rm rtl/
*
g++ BSD.cpp
-O
3
-std
=
c++11
-fopenmp
-pg
g++ BSD.cpp
-O
0
-std
=
c++11
-fopenmp
-pg
./a.out
./a.out
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