-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdense.h
60 lines (50 loc) · 1.53 KB
/
dense.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <systemc.h>
#include <macro.h>
#define DENSE_KER2 10 //âûõîäíàÿ äëèíà âåêòîðà
SC_MODULE(dense) {
sc_in<bool> clk, rst_n;
sc_in<double> dense_input[POOL_ED];
sc_out<double> dense_output[DENSE_KER2];
SC_CTOR(dense) {
SC_METHOD(dense_func);
sensitive_pos << clk; // ïîçèòèâíûé clock
sensitive_neg << rst_n; // íåãàòèâíûé ñáðîñ
}
void dense_func(void) {
double input[POOL_ED];
for (int i = 0; i < POOL_ED; i++) {
input[i] = dense_input[i].read();
}
for (int i = 0; i < DENSE_KER1; i++) {
cout << input[i] << " ";
}
cout << endl;
double kernel[DENSE_KER1][DENSE_KER2];
for (int i = 0; i < DENSE_KER2; i++) {
for (int j = 0; j < DENSE_KER1; j++) {
kernel[i][j] = 1;//rand() % 2;/// ÈÇ-ÇÀ ÝÒÎÃÎ ÇÍÀ×ÅÍÈß Â ÏÎÑËÅÄÍÅÌ ÑËÎÅ ÂÑÅÃÄÀ ÐÀÇÍÛÅ!
}
}
cout << "[debugging output][dense] kernel size:" << " DENSE_KER1 = " << DENSE_KER1 << " DENSE_KER2 = " << DENSE_KER2 << endl;
/*cout << "[debugging output][dense] kernel: " << endl;
for (int i = 0; i < DENSE_KER2; i++) {
for (int j = 0; j < DENSE_KER1; j++) {
cout << kernel[i][j] << " ";
}
cout << endl;
}*/
cout << endl;
double biases[BIASES] = { 2 };
double result[DENSE_KER2];
for(int i = 0; i < DENSE_KER1; i++) {
for (int j = 0; j < DENSE_KER2; j++) {
result[j] += kernel[i][j] * input[i];
}
}
for (int i = 0; i < DENSE_KER2; i++) {
cout << result[i] << " ";
}
cout << endl;
//cout<<"@" << sc_time_stamp() <<" dense layer calculated"<<endl;
}
};