PandA-2024.02
diff_sq_acc.cpp
Go to the documentation of this file.
1 /************************************************
2 Copyright (c) 2016, Xilinx, Inc.
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without modification,
6 are permitted provided that the following conditions are met:
7 
8 1. Redistributions of source code must retain the above copyright notice,
9 this list of conditions and the following disclaimer.
10 
11 2. Redistributions in binary form must reproduce the above copyright notice,
12 this list of conditions and the following disclaimer in the documentation
13 and/or other materials provided with the distribution.
14 
15 3. Neither the name of the copyright holder nor the names of its contributors
16 may be used to endorse or promote products derived from this software
17 without specific prior written permission.
18 
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
27 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.// Copyright (c) 2016 Xilinx, Inc.
28 ************************************************/
29 
30 #include "../src/diff_sq_acc.h"
31 
32 void diff_sq_acc(din_t a[N], din_t b[N], dout_t *dout)
33 {
34  int i;
35  int acc= 0;
36  int a_reg, b_reg, sub, sub2;
37 
38  for(i=0; i<N; i++)
39  {
40  #pragma HLS PIPELINE II=1
41 
42  a_reg = a[i];
43  b_reg = b[i];
44  sub = a_reg - b_reg;
45  sub2 = sub*sub;
46  acc += sub2;
47  }
48 
49  *dout = acc;
50 }
51 
ap_int< 16 > din_t
Definition: diff_sq_acc.h:36
void diff_sq_acc(din_t a[N], din_t b[N], dout_t *dout)
Definition: diff_sq_acc.cpp:32
ap_int< 48 > dout_t
Definition: diff_sq_acc.h:37
#define N
Definition: dfdiv.c:60

Generated on Mon Feb 12 2024 13:02:49 for PandA-2024.02 by doxygen 1.8.13