// multi_test3.cpp
// 2018/01/30 by marsee
//
#include <ap_fixed.h>
#include "multi_test3.h"
#include "conv1_weight.h"
int multi_test3(ap_ufixed_in in[25], ap_fixed_add &out){
#pragma HLS ARRAY_PARTITION variable=in complete dim=1
#pragma HLS PIPELINE II=1
ap_fixed_madd out_temp = 0.0;
#pragma HLS RESOURCE variable=out_temp core=AddSub
conv1: for(int m=0; m<5; m++){
#pragma HLS UNROLL
conv2: for(int n=0; n<5; n++){
out_temp += in[m*5+n] * conv1_weight[0][0][m][n];
}
}
out = out_temp;
return(0);
}
// multi_test3.h
// 2018/01/30 by marsee
//
#ifndef __multi_test_H__
#define __multi_test_H__
#include <ap_fixed.h>
typedef ap_ufixed<8, 0, AP_TRN, AP_WRAP> ap_ufixed_in;
typedef ap_fixed<9, 1, AP_TRN, AP_WRAP> ap_fixed_weight;
typedef ap_fixed<22, 6, AP_TRN, AP_WRAP> ap_fixed_madd;
typedef ap_fixed<16, 6, AP_TRN_ZERO, AP_SAT> ap_fixed_add;
#endif
// conv1_weight.h
// 2017/12/06 10:54:11 by marsee
const float conv1_fweight[2][1][5][5] =
{
{
{
{0.764403421227,0.658424746889,0.595604201652,0.554044871161,0.367767232883},
{0.582414155838,0.413274869036,0.31659268154,0.3508390519,0.331194144626},
{0.589182274309,0.462105790282,-0.241299390378,-0.10093021104,0.233291757594},
{0.792411286764,0.315893121865,0.0397628864727,0.356726636694,0.426826537165},
{0.634481192118,0.651475977113,0.688949928547,0.707285991358,0.681420943406}
}
}
,
{
{
{0.00564732125401,-0.012955272371,-0.0231571581103,-0.00289983746176,0.0281080593816},
{-0.0115360072012,0.00253310449813,-0.00860163957467,0.00112793810127,-0.01455040341},
{-0.00881717612899,-0.00902248113722,0.0004194288468,0.00110240651437,-0.0140454059394},
{0.00271556513713,-0.00307791921855,0.000117170379207,-0.00891721414879,0.0173026634286},
{0.000808453898046,0.000116327205532,-0.00275343050716,-0.00683461392689,-0.0169130858704}
}
}
};
const ap_fixed<9, 1, AP_TRN, AP_WRAP> conv1_weight[2][1][5][5] =
{
{
{
{0.765625,0.66015625,0.59375,0.5546875,0.3671875},
{0.58203125,0.4140625,0.31640625,0.3515625,0.33203125},
{0.58984375,0.4609375,-0.23828125,-0.09765625,0.234375},
{0.79296875,0.31640625,0.0390625,0.35546875,0.42578125},
{0.6328125,0.65234375,0.6875,0.70703125,0.6796875}
}
}
,
{
{
{0.00390625,-0.0078125,-0.01953125,0.0,0.02734375},
{-0.0078125,0.00390625,-0.00390625,0.0,-0.01171875},
{-0.00390625,-0.00390625,0.0,0.0,-0.01171875},
{0.00390625,0.0,0.0,-0.00390625,0.015625},
{0.0,0.0,0.0,-0.00390625,-0.01171875}
}
}
};
// multi_test3_tb.h
// 2018/01/30 by marsee
//
#include "multi_test3.h"
int multi_test3(ap_ufixed_in in[25], ap_fixed_add &out);
int main(void){
ap_ufixed_in in[25];
ap_fixed_add out;
ap_ufixed_in v = 0.5;
for(int i=0; i<25; i=i++){
in[i] = (ap_ufixed_in)v;
v += (ap_ufixed_in)0.00390625;
printf("in[%d] = %f\n", i, (float)v);
}
multi_test3(in, out);
printf("out = %f\n", (float)out);
return(0);
}
日 | 月 | 火 | 水 | 木 | 金 | 土 |
---|---|---|---|---|---|---|
- | - | - | - | - | 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 | - | - | - | - | - | - |