From 00d632a25a2359866ecf2c6bd6add79f71af3890 Mon Sep 17 00:00:00 2001 From: Gattopandacorno Date: Mon, 19 Dec 2022 10:17:14 +0100 Subject: [PATCH] Create independent `address` variable Co-authored-by: Fabio Zanichelli <274956@studenti.unimore.it> Co-authored-by: Stefano Pigozzi <256895@studenti.unimore.it> --- hls/assignment/sobel/sobel.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hls/assignment/sobel/sobel.cpp b/hls/assignment/sobel/sobel.cpp index 0ea4514..cf7a3a9 100644 --- a/hls/assignment/sobel/sobel.cpp +++ b/hls/assignment/sobel/sobel.cpp @@ -25,8 +25,10 @@ void sobel(uint8_t *__restrict__ out, uint8_t *__restrict__ in, const int width, { for (int z = 0; z < 3; z++) { - dx += sobelFilter[k][z] * in[(y + k - 1) * width + x + z - 1]; - dy += sobelFilter[z][k] * in[(y + k - 1) * width + x + z - 1]; + const int address = (y + k - 1) * width + x + z - 1; + + dx += sobelFilter[k][z] * in[address]; + dy += sobelFilter[z][k] * in[address]; } }