From ae5f2d0c52f7d8436b586a309bdc15b1d4a4f3e5 Mon Sep 17 00:00:00 2001 From: Gattopandacorno Date: Mon, 19 Dec 2022 10:43:10 +0100 Subject: [PATCH] Add `HLS PIPELINE` and `UNROLL` instructions Co-authored-by: Fabio Zanichelli <274956@studenti.unimore.it> Co-authored-by: Stefano Pigozzi <256895@studenti.unimore.it> --- hls/assignment/sobel/sobel.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hls/assignment/sobel/sobel.cpp b/hls/assignment/sobel/sobel.cpp index 5903f96..6b1c2a8 100644 --- a/hls/assignment/sobel/sobel.cpp +++ b/hls/assignment/sobel/sobel.cpp @@ -17,6 +17,8 @@ void sobel(uint8_t *__restrict__ out, uint8_t *__restrict__ in, const int width, esternoY: for (int y = 0; y < height - 2; y++) { + #pragma HLS PIPELINE + esternoX: for (int x = 0; x < width - 2; x++) { @@ -26,11 +28,15 @@ void sobel(uint8_t *__restrict__ out, uint8_t *__restrict__ in, const int width, internoY: for (int k = 0; k < 3; k++) { + #pragma HLS UNROLL + const int inYOffset = (y + k) * width; internoX: for (int z = 0; z < 3; z++) { + #pragma HLS UNROLL + const int inXOffset = x + z; const int inOffset = inYOffset + inXOffset; @@ -44,7 +50,7 @@ void sobel(uint8_t *__restrict__ out, uint8_t *__restrict__ in, const int width, const int outYOffset = (y + 1) * width; const int outXOffset = (x + 1); const int outOffset = outYOffset + outXOffset; - + out[outOffset] = sqrt((float)((dx * dx) + (dy * dy))); } }