-
Notifications
You must be signed in to change notification settings - Fork 0
/
examples.c
98 lines (78 loc) · 1.75 KB
/
examples.c
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include <MKL25Z4.h>
#include "CNNCortex.h"
void gating_LED(){
SystemCoreClockUpdate();
SIM_SCGC5 |= 1<<10;
PORTB_PCR18 |= 1<<8;
GPIOB_PDDR |=1<<18;
GPIOB_PSOR |= 1<<18;
}
void glow_LED(){
GPIOB_PCOR |= 1<<18; //Resetting the Pin to 0 to switch on the LED
}
void switchoff_LED(){
GPIOB_PSOR |= 1<<18;
}
int main(){
int Array1[1][2][2];
int Array2[1][2][2];
int Answer[1][2][2];
int i,j,k;
int * packedArray1;
int * packedArray2;
int Array1Length;
int Array2Length;
int Array1Sum;
int Array2Sum;
int * myArrayElementWiseProduct;
int * shapeOfMyMatrix;
gating_LED();
for( i=0;i<1;i++){
for(j=0;j<2;j++){
for(k=0;k<2;k++){
Array1[i][j][k]=i;
Array2[i][j][k]=j;
Answer[i][j][k]=i*j;
}
}
}
packedArray1 = matrixPacker((int *)Array1,1,2,2);
packedArray2 = matrixPacker((int *)Array2,1,2,2);
matrixShape(Array1,shapeOfMyMatrix);
matrixShape(Array2,shapeOfMyMatrix);
//myArrayLength=matrixLength(packedMyArray);
Array1Length=matrixLength(Array1);
Array2Length=matrixLength(Array2);
//myArraySum=matrixSum(packedMyArray);
Array1Sum=matrixSum(packedArray1);
Array2Sum=matrixSum(packedArray2);
matrixElementwiseMul(myArrayElementWiseProduct,packedArray1,packedArray2);
//int base = &myArrayElementWiseProduct;
int flag = 1;
for( i=0;i<1;i++){
for(j=0;j<2;j++){
for(k=0;k<2;k++){
//Address = Base + ((rowindex*col_size+colindex) * depth_size + depthindex) * Element_Size
int val =* (myArrayElementWiseProduct+((2*2*i + 2*j + k)+3));
//int val = (base+3)+((k*2+j)*1+i)*4;
if(Answer[i][j][k]!=val){
flag = 0;
break;
}
}
}
}
if(flag==0){
glow_LED();
__asm{
movs r0,0x045
}
}
else{
switchoff_LED();
__asm{
movs r0,0x050
}
}
return 1;
}