From 6780852b7ff105c670a19fae56a5800e0ab4f00b Mon Sep 17 00:00:00 2001 From: Klagarge Date: Fri, 15 Mar 2024 14:03:21 +0100 Subject: [PATCH] finish lab2 --- ...nterpolatorCalculatePolynom_studentVersion.vhd | 12 ++++-------- .../hdl/offsetToUnsigned_studentVersion.vhd | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/02-SplineInterpolator/SplineInterpolator/hdl/interpolatorCalculatePolynom_studentVersion.vhd b/02-SplineInterpolator/SplineInterpolator/hdl/interpolatorCalculatePolynom_studentVersion.vhd index 8c86122..7015431 100644 --- a/02-SplineInterpolator/SplineInterpolator/hdl/interpolatorCalculatePolynom_studentVersion.vhd +++ b/02-SplineInterpolator/SplineInterpolator/hdl/interpolatorCalculatePolynom_studentVersion.vhd @@ -5,7 +5,6 @@ signal x: st; signal u: st; signal v: st; signal w: st; -signal y: st; BEGIN @@ -15,28 +14,25 @@ BEGIN u <= (others => '0'); v <= (others => '0'); w <= (others => '0'); - y <= (others => '0'); elsif rising_edge(clock) then if restartPolynom = '1' then - x <= resize(d, st'high+1) sll (oversamplingBitNb * 3 + 1); - u <= resize(a, st'high+1) + (resize(b, st'high+1) sll oversamplingBitNb) + (resize(c, st'high+1) sll (oversamplingBitNb*2)); - v <= resize(6*a, v'length) + (resize(b, st'high+1) sll (oversamplingBitNb + 1)); + x <= resize(d, st'high+1) sla (oversamplingBitNb * 3 + 1); + u <= resize(a, st'high+1) + (resize(b, st'high+1) sla oversamplingBitNb) + (resize(c, st'high+1) sla (oversamplingBitNb*2)); + v <= resize(6*a, v'length) + (resize(b, st'high+1) sla (oversamplingBitNb + 1)); w <= resize(6*a, w'length); - y <= resize(d, st'high+1); else x <= x + u; u <= u + v; v <= v + w; - y <= x srl (oversamplingBitNb * 3 + 1); end if; end if; end process; - sampleOut <= resize(y,signalBitNb); + sampleOut <= resize(x sra (oversamplingBitNb * 3 + 1),signalBitNb); END ARCHITECTURE studentVersion; diff --git a/02-SplineInterpolator/SplineInterpolator/hdl/offsetToUnsigned_studentVersion.vhd b/02-SplineInterpolator/SplineInterpolator/hdl/offsetToUnsigned_studentVersion.vhd index 360c161..fb29ec9 100644 --- a/02-SplineInterpolator/SplineInterpolator/hdl/offsetToUnsigned_studentVersion.vhd +++ b/02-SplineInterpolator/SplineInterpolator/hdl/offsetToUnsigned_studentVersion.vhd @@ -1,4 +1,17 @@ ARCHITECTURE studentVersion OF offsetToUnsigned IS + + signal mySignal : unsigned(BitNb-1 downto 0); + signal const : unsigned(BitNb-1 downto 0) := (others => '1'); + BEGIN - unsignedOut <= (others => '0'); + process(signedIn) begin + if signedIn(signedIn'high) then + mySignal <= unsigned(signedIn) - (const srl 1); + else + mySignal <= unsigned(signedIn) + (const srl 1); + end if; + end process; + + unsignedOut <= mySignal; + END ARCHITECTURE studentVersion;