From 515ca52cc95470aee38d3badc91fa7f053938ab6 Mon Sep 17 00:00:00 2001 From: Gianluca Brilli Date: Thu, 13 May 2021 22:03:14 +0200 Subject: [PATCH] HLS lab 1 --- hls/lab1/exercise_0.hpp | 11 +++++++++++ hls/lab1/exercise_0_solution.cpp | 8 ++++---- hls/lab1/exercise_0_testbench.cpp | 28 ++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 hls/lab1/exercise_0.hpp create mode 100644 hls/lab1/exercise_0_testbench.cpp diff --git a/hls/lab1/exercise_0.hpp b/hls/lab1/exercise_0.hpp new file mode 100644 index 0000000..3ca2c2f --- /dev/null +++ b/hls/lab1/exercise_0.hpp @@ -0,0 +1,11 @@ +#ifndef VADD_HPP +#define VADD_HPP + + #include + + //#define TEST_DATA_SIZE 4194304 // 2^22 + #define TEST_DATA_SIZE 12 + + void vadd(int *a, int *b, int *c, const int len); + +#endif diff --git a/hls/lab1/exercise_0_solution.cpp b/hls/lab1/exercise_0_solution.cpp index f1739ee..4eaebfc 100755 --- a/hls/lab1/exercise_0_solution.cpp +++ b/hls/lab1/exercise_0_solution.cpp @@ -1,12 +1,12 @@ -#define TEST_DATA_SIZE 4194304 // 2^22 +#include "exercise_0.hpp" const unsigned int c_dim = TEST_DATA_SIZE; void vadd(int *a, int *b, int *c, const int len) { - #pragma HLS INTERFACE m_axi port=a offset=slave bundle=mem - #pragma HLS INTERFACE m_axi port=b offset=slave bundle=mem - #pragma HLS INTERFACE m_axi port=c offset=slave bundle=mem + #pragma HLS INTERFACE m_axi port=a offset=slave depth=c_dim bundle=mem + #pragma HLS INTERFACE m_axi port=b offset=slave depth=c_dim bundle=mem + #pragma HLS INTERFACE m_axi port=c offset=slave depth=c_dim bundle=mem #pragma HLS INTERFACE s_axilite port=len bundle=params #pragma HLS INTERFACE s_axilite port=return bundle=params diff --git a/hls/lab1/exercise_0_testbench.cpp b/hls/lab1/exercise_0_testbench.cpp new file mode 100644 index 0000000..bcafd7b --- /dev/null +++ b/hls/lab1/exercise_0_testbench.cpp @@ -0,0 +1,28 @@ +#include +#include + +#include "exercise_0.hpp" + +int main(int argc, char ** argv) { + + int * a = (int *)malloc(TEST_DATA_SIZE*sizeof(int)); + int * b = (int *)malloc(TEST_DATA_SIZE*sizeof(int)); + int * c = (int *)malloc(TEST_DATA_SIZE*sizeof(int)); + + for(int i = 0; i < TEST_DATA_SIZE; i++) { + a[i] = i*i; + b[i] = i; + } + + vadd(a, b, c, TEST_DATA_SIZE); + + for(int i = 0; i < TEST_DATA_SIZE; i++) { + printf("%d\n", c[i]); + } + + free(a); + free(b); + free(c); + + return 0; +}