From a229dfad5f8d8e2cc1eebfadd8d826b32f2e332b Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 19 Dec 2022 12:16:55 +0100 Subject: [PATCH] Fix ring buffer dimensions --- hls/assignment/sobel/sobel.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hls/assignment/sobel/sobel.cpp b/hls/assignment/sobel/sobel.cpp index e88ed84..5666746 100644 --- a/hls/assignment/sobel/sobel.cpp +++ b/hls/assignment/sobel/sobel.cpp @@ -17,8 +17,8 @@ void sobel(uint8_t *__restrict__ out, uint8_t *__restrict__ in) }; // Carica le prime tre righe nel buffer - uint8_t inBuffer[3*HEIGHT]; - memcpy(inBuffer, in, 3*HEIGHT*sizeof(uint8_t)); + uint8_t inBuffer[3*WIDTH]; + memcpy(inBuffer, in, 3*WIDTH*sizeof(uint8_t)); esternoY: for (int y = 0; y < HEIGHT - 2; y++) @@ -37,14 +37,14 @@ void sobel(uint8_t *__restrict__ out, uint8_t *__restrict__ in) { #pragma HLS UNROLL - const int inYOffset = ((y + k) % 3) * WIDTH; + const int inYOffset = (y + k) * WIDTH; internoX: for (int z = 0; z < 3; z++) { #pragma HLS UNROLL - const int inXOffset = x + z; + const int inXOffset = (x + z) % 3; const int inOffset = inYOffset + inXOffset; const int inElement = inBuffer[inOffset]; @@ -61,6 +61,6 @@ void sobel(uint8_t *__restrict__ out, uint8_t *__restrict__ in) out[outOffset] = sqrt((float)((dx * dx) + (dy * dy))); } - memcpy(inBuffer, in + (y % 3) * HEIGHT, HEIGHT*sizeof(uint8_t)); + memcpy(inBuffer, in + y * WIDTH, WIDTH*sizeof(uint8_t)); } }