1
Fork 0
mirror of https://github.com/Steffo99/unimore-hpc-assignments.git synced 2024-11-25 09:34:23 +00:00

HLS lab 1

This commit is contained in:
Gianluca Brilli 2021-05-13 22:03:14 +02:00
parent 7e94c3bf93
commit 515ca52cc9
3 changed files with 43 additions and 4 deletions

11
hls/lab1/exercise_0.hpp Normal file
View file

@ -0,0 +1,11 @@
#ifndef VADD_HPP
#define VADD_HPP
#include <stdio.h>
//#define TEST_DATA_SIZE 4194304 // 2^22
#define TEST_DATA_SIZE 12
void vadd(int *a, int *b, int *c, const int len);
#endif

View file

@ -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

View file

@ -0,0 +1,28 @@
#include <stdio.h>
#include <stdlib.h>
#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;
}