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:
parent
7e94c3bf93
commit
515ca52cc9
3 changed files with 43 additions and 4 deletions
11
hls/lab1/exercise_0.hpp
Normal file
11
hls/lab1/exercise_0.hpp
Normal 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
|
|
@ -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
|
||||
|
||||
|
|
28
hls/lab1/exercise_0_testbench.cpp
Normal file
28
hls/lab1/exercise_0_testbench.cpp
Normal 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;
|
||||
}
|
Loading…
Reference in a new issue