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
6cce9111
Commit
6cce9111
authored
Aug 27, 2025
by
chengshuyao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Debug int overflow
parent
c37f5e7c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
81 additions
and
36 deletions
+81
-36
src/BSD.cpp
+13
-9
src/BSD.h
+0
-0
src/next_layer_bit.h
+4
-4
src/tool_function.h
+47
-10
src/top.h
+5
-5
src/write_vec.sh
+12
-8
No files found.
src/BSD.cpp
View file @
6cce9111
...
...
@@ -32,14 +32,14 @@ using namespace std;
//电路的parameter Circuit_parameter
int
circuit_index
=
9999
;
//电路编号
extern
const
int
parameter_max_orders
=
8
;
extern
const
int
parameter_max_orders
=
2
;
//算法的parameter Algorithm_parameter
extern
const
int
parameter_num_threads
=
64
;
//线程数
extern
const
int
parameter_multi_output_index
=
0
;
//BSD从第几层开始化简,前面若干层展开序确定
extern
const
int
parameter_max_BDD_width
=
4
0000
;
//BSD每一层最多多少个节点
extern
const
int
parameter_max_BDD_width
=
32
0000
;
//BSD每一层最多多少个节点
int
parameter_early_stop_depth
=
parameter_input_bit_width
;
//BSD到第几层终止,输出此时的不准确BSD
int
parameter_early_stop_split_nodes
=
1000000
;
//BSD每一层最多多少个节点
...
...
@@ -84,7 +84,7 @@ public:
accuracy_layers
=
new
int
[
parameter_input_bit_width
];
BDD_width_each_layer
=
new
int
[
parameter_input_bit_width
];
}
//int nodes_for_each_start_nod
e[
parameter_max_BDD_width];
//int nodes_for_each_start_nodparameter_max_BDD_width];
};
BSD_features
BSD_features_0
;
...
...
@@ -107,7 +107,7 @@ int main(int argc,char* argv[]){
for
(
int
i
=
0
;
i
<
parameter_output_bit_width
;
i
++
)
default_partition_set
[
i
]
=
1
;
//for(int i=0;i<parameter_output_bit_width;i++)
//
default_partition_set[0] = 1;
default_partition_set
[
0
]
=
1
;
//io generator来自真值表,不来自写好的文件
...
...
@@ -140,7 +140,7 @@ int main(int argc,char* argv[]){
int
*
start_order
=
new
int
[
parameter_input_bit_width
];
int
area_a
=
search_order
(
parameter_search_iterations
,
default_partition_set
,
0
,
start_order
);
int
area_a
=
search_order
(
10
,
default_partition_set
,
0
,
start_order
);
//search_partition(parameter_input_bit_width,start_order);
};
int
search_partition
(
int
start_order_depth
,
int
*
start_order
){
...
...
@@ -157,6 +157,10 @@ int search_partition(int start_order_depth, int* start_order){
best_output_partition_set_a
[
i
]
=
0
;
best_output_partition_set_b
[
i
]
=
0
;
}
best_area
=
search_order
(
1
,
default_partition_set
,
parameter_input_bit_width
,
start_order
);
cout
<<
"###########################################################################"
<<
endl
;
cout
<<
"Best Design Area: "
<<
best_area
<<
" "
<<
best_area_a
<<
" + "
<<
best_area_b
<<
endl
;
cout
<<
"###########################################################################"
<<
endl
;
for
(
int
j
=
0
;
j
<
2
;
j
++
){
bool
*
output_partition_set_a
=
new
bool
[
parameter_output_bit_width
];
bool
*
output_partition_set_b
=
new
bool
[
parameter_output_bit_width
];
...
...
@@ -218,13 +222,13 @@ int BSD_execute(int variable_order_number,int** variable_order, int partition_de
cout
<<
"BSD execute start"
<<
endl
;
BDD_class
BDD_class_main
;
BDD_class_main
.
output_partition_set
=
output_partition_set
;
BDD_class_main
.
which_demo_function
=
GLOBAL_which_demo_function
;
cout
<<
"This variable order: "
<<
variable_order_number
<<
endl
;
for
(
int
j
=
0
;
j
<
parameter_max_orders
;
j
++
){
//cout<<"j"<<j<<endl;
BDD_class_main
.
BSD_variable_order
[
j
]
=
new
int
[
parameter_input_bit_width
];
}
cout
<<
"This variable order: "
<<
variable_order_number
<<
endl
;
BDD_class_main
.
output_partition_set
=
output_partition_set
;
BDD_class_main
.
which_demo_function
=
GLOBAL_which_demo_function
;
//for (int vi=0;vi<partition_parts;vi++){
// BDD_class_main.BSD_variable_order_number = variable_order_number;
// for(int i=0;i<variable_order_number;i++){
...
...
@@ -700,6 +704,6 @@ int search_order(int search_iterations,bool* output_partition_set,int start_orde
// }
// delete [] variable_order;
// delete [] best_variable_order;
return
area
;
return
reward
;
};
src/BSD.h
View file @
6cce9111
This diff is collapsed.
Click to expand it.
src/next_layer_bit.h
View file @
6cce9111
...
...
@@ -275,8 +275,8 @@ int BDD_class::next_bit_layer_1(int depth){
}
else
if
(
all_one_left
){
change_nodes
[
this_bit_expansion
]
+=
1
;
}
else
{
which_list_number_l
=
compare_simplify_list
(
how_many_nodes_if_expansion
[
this_bit_expansion
],
left_mask_output_data
,
simplify_list
);
which_list_number_neg_l
=
compare_simplify_list_neg
(
how_many_nodes_if_expansion
[
this_bit_expansion
],
left_mask_output_data
,
simplify_list
);
//
which_list_number_l = compare_simplify_list (how_many_nodes_if_expansion[this_bit_expansion],left_mask_output_data,simplify_list);
//
which_list_number_neg_l = compare_simplify_list_neg(how_many_nodes_if_expansion[this_bit_expansion],left_mask_output_data,simplify_list);
bool
it_cannot_simplify
=
(
which_list_number_l
<
0
)
&&
(
which_list_number_neg_l
<
0
);
bool
it_can_simplify
=
(
which_list_number_l
>=
0
);
bool
it_can_simplify_neg
=
(
which_list_number_neg_l
>=
0
);
...
...
@@ -296,8 +296,8 @@ int BDD_class::next_bit_layer_1(int depth){
}
else
if
(
all_one_right
){
change_nodes
[
this_bit_expansion
]
+=
1
;
}
else
{
which_list_number_r
=
compare_simplify_list
(
how_many_nodes_if_expansion
[
this_bit_expansion
],
right_mask_output_data
,
simplify_list
);
which_list_number_neg_r
=
compare_simplify_list_neg
(
how_many_nodes_if_expansion
[
this_bit_expansion
],
right_mask_output_data
,
simplify_list
);
//
which_list_number_r = compare_simplify_list(how_many_nodes_if_expansion[this_bit_expansion],right_mask_output_data,simplify_list);
//
which_list_number_neg_r = compare_simplify_list_neg(how_many_nodes_if_expansion[this_bit_expansion],right_mask_output_data,simplify_list);
bool
it_cannot_simplify
=
(
which_list_number_r
<
0
)
&&
(
which_list_number_neg_r
<
0
);
bool
it_can_simplify
=
(
which_list_number_r
>=
0
);
bool
it_can_simplify_neg
=
(
which_list_number_neg_r
>=
0
);
...
...
src/tool_function.h
View file @
6cce9111
...
...
@@ -30,8 +30,37 @@ int BDD_class::mask_random_input_data(int depth,bool* mask,int amount,int* most_
return
0
;
};
int
BDD_class
::
hash_simplify_list_function
(
bool
*
list
,
bool
neg
){
int
BDD_class
::
compare_simplify_list
(
int
list_line_amount
,
bool
*
this_line
,
bool
**
simplify_list
){
int
a
=
int
(
BSD_samples
/
1
);
int
b
=
int
(
BSD_samples
/
2
);
int
c
=
int
(
BSD_samples
/
3
);
int
d
=
int
(
BSD_samples
/
4
);
int
line_sum_a
=
0
;
int
line_sum_b
=
0
;
int
line_sum_c
=
0
;
int
line_sum_d
=
0
;
for
(
int
i
=
0
;
i
<
BSD_samples
;
i
++
){
if
(
i
<
d
){
if
(
list
[
i
]
==!
neg
)
line_sum_d
+=
1
;
}
else
if
(
i
<
c
){
if
(
list
[
i
]
==!
neg
)
line_sum_c
+=
1
;
}
else
if
(
i
<
b
){
if
(
list
[
i
]
==!
neg
)
line_sum_b
+=
1
;
}
else
if
(
i
<
a
){
if
(
list
[
i
]
==!
neg
)
line_sum_a
+=
1
;
}
}
int
line_sum
=
line_sum_d
*
3
+
line_sum_c
*
5
+
line_sum_b
*
7
+
line_sum_a
;
return
line_sum
;
}
int
BDD_class
::
compare_simplify_list
(
int
list_line_amount
,
bool
*
this_line
,
bool
**
simplify_list
,
int
*
hash_simplify_list
,
int
hash_number
){
int
which_list_number
=
-
1
;
bool
it_can_simplify
=
0
;
int
i
,
j
;
...
...
@@ -40,10 +69,14 @@ int BDD_class::compare_simplify_list(int list_line_amount,bool* this_line,bool**
if
(
1
){
for
(
int
i
=
list_line_amount
-
1
;
i
>=
0
;
i
--
){
it_can_simplify_here
=
1
;
for
(
int
j
=
0
;
j
<
BSD_samples
;
j
++
){
if
(
simplify_list
[
i
][
j
]
!=
this_line
[
j
]){
it_can_simplify_here
=
0
;
break
;
if
(
hash_number
!=
hash_simplify_list
[
i
]){
it_can_simplify_here
=
0
;
}
else
{
for
(
int
j
=
0
;
j
<
BSD_samples
;
j
++
){
if
(
simplify_list
[
i
][
j
]
!=
this_line
[
j
]){
it_can_simplify_here
=
0
;
break
;
}
}
}
if
(
it_can_simplify_here
){
...
...
@@ -55,7 +88,7 @@ int BDD_class::compare_simplify_list(int list_line_amount,bool* this_line,bool**
}
return
which_list_number
;
};
int
BDD_class
::
compare_simplify_list_neg
(
int
list_line_amount
,
bool
*
this_line
,
bool
**
simplify_list
){
int
BDD_class
::
compare_simplify_list_neg
(
int
list_line_amount
,
bool
*
this_line
,
bool
**
simplify_list
,
int
*
hash_simplify_list
,
int
hash_neg_number
){
int
which_list_number
=
-
1
;
//return which_list_number;
bool
it_can_simplify
=
0
;
...
...
@@ -65,10 +98,14 @@ int BDD_class::compare_simplify_list_neg(int list_line_amount,bool* this_line,bo
if
(
1
){
for
(
i
=
list_line_amount
-
1
;
i
>=
0
;
i
--
){
it_can_simplify_here
=
1
;
for
(
int
j
=
0
;
j
<
BSD_samples
;
j
++
){
if
(
simplify_list
[
i
][
j
]
==
this_line
[
j
]){
it_can_simplify_here
=
0
;
break
;
if
(
hash_neg_number
!=
hash_simplify_list
[
i
]){
it_can_simplify_here
=
0
;
}
else
{
for
(
int
j
=
0
;
j
<
BSD_samples
;
j
++
){
if
(
simplify_list
[
i
][
j
]
==
this_line
[
j
]){
it_can_simplify_here
=
0
;
break
;
}
}
}
if
(
it_can_simplify_here
){
...
...
src/top.h
View file @
6cce9111
#define INPUT_AIG
#include
"io_generator/c1908
.h"
#include
"c1908
_vec.h"
#include
"usb1_crc16
.h"
#include
"usb1_crc16
_vec.h"
extern
const
int
parameter_input_bit_width
=
PI_WIDTH
+
5
;
extern
const
int
parameter_output_bit_width
=
PO_WIDTH
;
extern
const
int
parameter_train_output_bit_width
=
1
;
//
extern const int parameter_train_output_bit_width = 1 ;
//int parameter_input_bit_width = 80+5; //输入bit有几位,写在+6前面。+6是为了防止一些bug的冗余设计。
...
...
@@ -15,9 +15,9 @@ extern const int parameter_train_output_bit_width = 1 ;
//#include"io_generator_tmp.h"
extern
const
int
parameter_search_iterations
=
400
;
//最大设计次数
extern
const
int
parameter_search_iterations
=
1
;
//最大设计次数
extern
const
int
parameter_test_ios
=
1000
;
//测试要求多少样本
extern
const
int
parameter_max_samples
=
int
(
parameter_test_ios
*
10
/
32
)
*
32
;
//BSD每一个节点最多进行多少次采样
extern
const
int
parameter_max_samples
=
int
(
parameter_test_ios
*
10
0
/
32
)
*
32
;
//BSD每一个节点最多进行多少次采样
bool
*
io_generator_function
(
bool
*
input_data
,
bool
*
output_data
)
{
...
...
src/write_vec.sh
View file @
6cce9111
module_name
=
"
dalu
"
vim
-c
"open io_generator/
${
module_name
}
.h"
\
-c
"1d"
\
-c
"1d"
\
-c
":$"
\
-c
"d"
module_name
=
"
usb1_crc16
"
#@
vim -c "open io_generator/${module_name}.h" \
#@
-c "1d"\
#@
-c "1d"\
#@
-c ":$"\
#@
-c "d"
cp io_generator/
${
module_name
}
.h
${
module_name
}
_vec.h
vim
-c
"open
${
module_name
}
_vec.h"
\
-c
"1d"
\
-c
"1d"
\
-c
"1d"
\
-c
"1d"
\
-c
"1,
$
s/io_generator_outer/io_generator_outer_vec"
vim
-c
"open
${
module_name
}
_vec.h"
\
-c
"1,
$
s/vec_vec/vec"
\
-c
"1,
$
s/bool/
in
t/g"
\
-c
"1,
$
s/bool/
uint32_
t/g"
\
-c
"1,
$
s/!/
\~
/g"
\
-c
"1,
$
s/&&/and/g"
\
-c
"1,
$
s/and/
\&
/g"
\
-c
"1,
$
s/false/0/g"
\
-c
"1,
$
s/true/-1/g"
\
-c
"1,
$
s/true/32'hffffffff/g"
\
-c
":$"
\
-c
"d"
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