add solutions
This commit is contained in:
		| @@ -0,0 +1,56 @@ | ||||
| ARCHITECTURE masterVersion OF interpolatorCalculatePolynom IS | ||||
|  | ||||
|   constant additionalBitNb: positive := 1; | ||||
|   constant internalsBitNb: positive := signalBitNb + 3*oversamplingBitNb + 1 | ||||
|     + additionalBitNb; | ||||
|   signal x: signed(internalsBitNb-1 downto 0); | ||||
|   signal u: signed(internalsBitNb-1 downto 0); | ||||
|   signal v: signed(internalsBitNb-1 downto 0); | ||||
|   signal w: signed(internalsBitNb-1 downto 0); | ||||
|  | ||||
| BEGIN | ||||
|  | ||||
|   iterativePolynom: process(reset, clock) | ||||
|   begin | ||||
|     if reset = '1' then | ||||
|       x <= (others => '0'); | ||||
|       u <= (others => '0'); | ||||
|       v <= (others => '0'); | ||||
|       w <= (others => '0'); | ||||
|       sampleOut <= (others => '0'); | ||||
|     elsif rising_edge(clock) then | ||||
|       if en = '1' then | ||||
|         if restartPolynom = '1' then | ||||
|           x <=   shift_left(resize(2*d, x'length), 3*oversamplingBitNb); | ||||
|           u <=   resize(a, u'length) | ||||
|                + shift_left(resize(b, u'length), oversamplingBitNb) | ||||
|                + shift_left(resize(c, u'length), 2*oversamplingBitNb); | ||||
|           v <=   resize(6*a, v'length) | ||||
|                + shift_left(resize(2*b, v'length), oversamplingBitNb); | ||||
|           w <=   resize(6*a, w'length); | ||||
|           sampleOut <= resize(d, sampleOut'length); | ||||
|         else | ||||
|           x <= x + u; | ||||
|           u <= u + v; | ||||
|           v <= v + w; | ||||
|           sampleOut <= resize( | ||||
|             shift_right(x, 3*oversamplingBitNb+1), sampleOut'length | ||||
|           ); | ||||
|                                                                -- limit overflow | ||||
|           if x(x'high downto x'high-additionalBitNb) = "01" then | ||||
|             sampleOut <= not shift_left( | ||||
|               resize("10", sampleOut'length), sampleOut'length-2 | ||||
|             ); | ||||
|           end if; | ||||
|                                                               -- limit underflow | ||||
|           if x(x'high downto x'high-additionalBitNb) = "10" then | ||||
|             sampleOut <= shift_left( | ||||
|               resize("10", sampleOut'length), sampleOut'length-2 | ||||
|             ); | ||||
|           end if; | ||||
|         end if; | ||||
|       end if; | ||||
|     end if; | ||||
|   end process iterativePolynom; | ||||
|  | ||||
| END ARCHITECTURE masterVersion; | ||||
| @@ -0,0 +1,4 @@ | ||||
| ARCHITECTURE studentVersion OF interpolatorCalculatePolynom IS | ||||
| BEGIN | ||||
|   sampleOut <= (others => '0'); | ||||
| END ARCHITECTURE studentVersion; | ||||
| @@ -0,0 +1,28 @@ | ||||
| ARCHITECTURE masterVersion OF interpolatorCoefficients IS | ||||
| BEGIN | ||||
|  | ||||
|   calcCoeffs: process(interpolateLinear, sample1, sample2, sample3, sample4) | ||||
|   begin | ||||
|     if interpolateLinear = '1' then | ||||
|       a <= (others => '0'); | ||||
|       b <= (others => '0'); | ||||
|       c <=   resize(2*sample3, c'length) | ||||
|            - resize(2*sample2, c'length); | ||||
|       d <=   resize(  sample2, d'length); | ||||
|     else | ||||
|       a <=   resize(  sample4, a'length) | ||||
|            - resize(3*sample3, a'length) | ||||
|            + resize(3*sample2, a'length) | ||||
|            - resize(  sample1, a'length); | ||||
|       b <=   resize(2*sample1, b'length) | ||||
|            - resize(5*sample2, b'length) | ||||
|            + resize(4*sample3, b'length) | ||||
|            - resize(  sample4, b'length); | ||||
|       c <=   resize(  sample3, c'length) | ||||
|            - resize(  sample1, c'length); | ||||
|       d <=   resize(  sample2, d'length); | ||||
|     end if; | ||||
|   end process calcCoeffs; | ||||
|  | ||||
| END ARCHITECTURE masterVersion; | ||||
|  | ||||
| @@ -0,0 +1,7 @@ | ||||
| ARCHITECTURE studentVersion OF interpolatorCoefficients IS | ||||
| BEGIN | ||||
|   a <= (others => '0'); | ||||
|   b <= (others => '0'); | ||||
|   c <= (others => '0'); | ||||
|   d <= (others => '0'); | ||||
| END ARCHITECTURE studentVersion; | ||||
| @@ -0,0 +1,40 @@ | ||||
| ARCHITECTURE masterVersion OF interpolatorShiftRegister IS | ||||
|  | ||||
|   -- signal sample4_int: signed(sampleIn'range); | ||||
|   -- signal sample3_int: signed(sampleIn'range); | ||||
|   -- signal sample2_int: signed(sampleIn'range); | ||||
|   -- signal sample1_int: signed(sampleIn'range); | ||||
|    | ||||
|   type samplesArray is array(3 downto 0) of signed(sampleIn'range); | ||||
|   signal samples: samplesArray; | ||||
|  | ||||
| begin | ||||
|  | ||||
|   shiftThem: process(reset, clock) | ||||
|   begin | ||||
|     if reset = '1' then | ||||
| 		samples <= (others=>(others=>'0')); | ||||
|       -- sample1_int <= (others => '0'); | ||||
|       -- sample2_int <= (others => '0'); | ||||
|       -- sample3_int <= (others => '0'); | ||||
|       -- sample4_int <= (others => '0'); | ||||
|     elsif rising_edge(clock) then | ||||
|       if shiftSamples = '1' then | ||||
|         -- sample1_int <= sample2_int; | ||||
|         -- sample2_int <= sample3_int; | ||||
|         -- sample3_int <= sample4_int; | ||||
|         -- sample4_int <= sampleIn; | ||||
| 		samples(0) <= samples(1); | ||||
| 		samples(1) <= samples(2); | ||||
| 		samples(2) <= samples(3); | ||||
| 		samples(3) <= sampleIn; | ||||
|       end if; | ||||
|     end if; | ||||
|   end process shiftThem; | ||||
|  | ||||
|   sample4 <= samples(3); | ||||
|   sample3 <= samples(2); | ||||
|   sample2 <= samples(1); | ||||
|   sample1 <= samples(0); | ||||
|  | ||||
| END ARCHITECTURE masterVersion; | ||||
| @@ -0,0 +1,7 @@ | ||||
| ARCHITECTURE studentVersion OF interpolatorShiftRegister IS | ||||
| BEGIN | ||||
|   sample1 <= (others => '0'); | ||||
|   sample2 <= (others => '0'); | ||||
|   sample3 <= (others => '0'); | ||||
|   sample4 <= (others => '0'); | ||||
| END ARCHITECTURE studentVersion; | ||||
| @@ -0,0 +1,27 @@ | ||||
| ARCHITECTURE masterVersion OF interpolatorTrigger IS | ||||
|  | ||||
|   signal triggerCounter: unsigned(counterBitNb-1 downto 0); | ||||
|  | ||||
| BEGIN | ||||
|  | ||||
|   count: process(reset, clock) | ||||
|   begin | ||||
|     if reset = '1' then | ||||
|       triggerCounter <= (others => '0'); | ||||
|     elsif rising_edge(clock) then | ||||
|       if en = '1' then | ||||
|         triggerCounter <= triggerCounter + 1; | ||||
|       end if; | ||||
|     end if; | ||||
|   end process count; | ||||
|  | ||||
|   trig: process(triggerCounter, en) | ||||
|   begin | ||||
|     if triggerCounter = 0 then | ||||
|       triggerOut <= en; | ||||
|     else | ||||
|       triggerOut <= '0'; | ||||
|     end if; | ||||
|   end process trig; | ||||
|  | ||||
| END ARCHITECTURE masterVersion; | ||||
| @@ -0,0 +1,4 @@ | ||||
| ARCHITECTURE studentVersion OF interpolatorTrigger IS | ||||
| BEGIN | ||||
|   triggerOut <= '0'; | ||||
| END ARCHITECTURE studentVersion; | ||||
| @@ -0,0 +1,34 @@ | ||||
| -- VHDL Entity SplineInterpolator.interpolatorCalculatePolynom.symbol | ||||
| -- | ||||
| -- Created: | ||||
| --          by - francois.francois (Aphelia) | ||||
| --          at - 13:00:14 02/19/19 | ||||
| -- | ||||
| -- Generated by Mentor Graphics' HDL Designer(TM) 2019.2 (Build 5) | ||||
| -- | ||||
| LIBRARY ieee; | ||||
|   USE ieee.std_logic_1164.all; | ||||
|   USE ieee.numeric_std.all; | ||||
|  | ||||
| ENTITY interpolatorCalculatePolynom IS | ||||
|     GENERIC(  | ||||
|         signalBitNb       : positive := 16; | ||||
|         coeffBitNb        : positive := 16; | ||||
|         oversamplingBitNb : positive := 8 | ||||
|     ); | ||||
|     PORT(  | ||||
|         clock          : IN     std_ulogic; | ||||
|         reset          : IN     std_ulogic; | ||||
|         restartPolynom : IN     std_ulogic; | ||||
|         d              : IN     signed (coeffBitNb-1 DOWNTO 0); | ||||
|         sampleOut      : OUT    signed (signalBitNb-1 DOWNTO 0); | ||||
|         c              : IN     signed (coeffBitNb-1 DOWNTO 0); | ||||
|         b              : IN     signed (coeffBitNb-1 DOWNTO 0); | ||||
|         a              : IN     signed (coeffBitNb-1 DOWNTO 0); | ||||
|         en             : IN     std_ulogic | ||||
|     ); | ||||
|  | ||||
| -- Declarations | ||||
|  | ||||
| END interpolatorCalculatePolynom ; | ||||
|  | ||||
| @@ -0,0 +1,33 @@ | ||||
| -- VHDL Entity SplineInterpolator.interpolatorCoefficients.symbol | ||||
| -- | ||||
| -- Created: | ||||
| --          by - francois.francois (Aphelia) | ||||
| --          at - 13:00:20 02/19/19 | ||||
| -- | ||||
| -- Generated by Mentor Graphics' HDL Designer(TM) 2019.2 (Build 5) | ||||
| -- | ||||
| LIBRARY ieee; | ||||
|   USE ieee.std_logic_1164.all; | ||||
|   USE ieee.numeric_std.all; | ||||
|  | ||||
| ENTITY interpolatorCoefficients IS | ||||
|     GENERIC(  | ||||
|         bitNb      : positive := 16; | ||||
|         coeffBitNb : positive := 16 | ||||
|     ); | ||||
|     PORT(  | ||||
|         sample1           : IN     signed (bitNb-1 DOWNTO 0); | ||||
|         sample2           : IN     signed (bitNb-1 DOWNTO 0); | ||||
|         sample3           : IN     signed (bitNb-1 DOWNTO 0); | ||||
|         sample4           : IN     signed (bitNb-1 DOWNTO 0); | ||||
|         a                 : OUT    signed (coeffBitNb-1 DOWNTO 0); | ||||
|         b                 : OUT    signed (coeffBitNb-1 DOWNTO 0); | ||||
|         c                 : OUT    signed (coeffBitNb-1 DOWNTO 0); | ||||
|         d                 : OUT    signed (coeffBitNb-1 DOWNTO 0); | ||||
|         interpolateLinear : IN     std_ulogic | ||||
|     ); | ||||
|  | ||||
| -- Declarations | ||||
|  | ||||
| END interpolatorCoefficients ; | ||||
|  | ||||
| @@ -0,0 +1,31 @@ | ||||
| -- VHDL Entity SplineInterpolator.interpolatorShiftRegister.symbol | ||||
| -- | ||||
| -- Created: | ||||
| --          by - francois.francois (Aphelia) | ||||
| --          at - 13:00:24 02/19/19 | ||||
| -- | ||||
| -- Generated by Mentor Graphics' HDL Designer(TM) 2019.2 (Build 5) | ||||
| -- | ||||
| LIBRARY ieee; | ||||
|   USE ieee.std_logic_1164.all; | ||||
|   USE ieee.numeric_std.all; | ||||
|  | ||||
| ENTITY interpolatorShiftRegister IS | ||||
|     GENERIC(  | ||||
|         signalBitNb : positive := 16 | ||||
|     ); | ||||
|     PORT(  | ||||
|         clock        : IN     std_ulogic; | ||||
|         reset        : IN     std_ulogic; | ||||
|         shiftSamples : IN     std_ulogic; | ||||
|         sampleIn     : IN     signed (signalBitNb-1 DOWNTO 0); | ||||
|         sample1      : OUT    signed (signalBitNb-1 DOWNTO 0); | ||||
|         sample2      : OUT    signed (signalBitNb-1 DOWNTO 0); | ||||
|         sample3      : OUT    signed (signalBitNb-1 DOWNTO 0); | ||||
|         sample4      : OUT    signed (signalBitNb-1 DOWNTO 0) | ||||
|     ); | ||||
|  | ||||
| -- Declarations | ||||
|  | ||||
| END interpolatorShiftRegister ; | ||||
|  | ||||
| @@ -0,0 +1,27 @@ | ||||
| -- VHDL Entity SplineInterpolator.interpolatorTrigger.symbol | ||||
| -- | ||||
| -- Created: | ||||
| --          by - francois.francois (Aphelia) | ||||
| --          at - 13:00:28 02/19/19 | ||||
| -- | ||||
| -- Generated by Mentor Graphics' HDL Designer(TM) 2019.2 (Build 5) | ||||
| -- | ||||
| LIBRARY ieee; | ||||
|   USE ieee.std_logic_1164.all; | ||||
|   USE ieee.numeric_std.all; | ||||
|  | ||||
| ENTITY interpolatorTrigger IS | ||||
|     GENERIC(  | ||||
|         counterBitNb : positive := 4 | ||||
|     ); | ||||
|     PORT(  | ||||
|         triggerOut : OUT    std_ulogic; | ||||
|         clock      : IN     std_ulogic; | ||||
|         reset      : IN     std_ulogic; | ||||
|         en         : IN     std_ulogic | ||||
|     ); | ||||
|  | ||||
| -- Declarations | ||||
|  | ||||
| END interpolatorTrigger ; | ||||
|  | ||||
| @@ -0,0 +1,7 @@ | ||||
| ARCHITECTURE masterVersion OF offsetToUnsigned IS | ||||
|  | ||||
| BEGIN | ||||
|  | ||||
|   unsignedOut <= not(signedIn(signedIn'high)) & unsigned(signedIn(signedIn'high-1 downto 0)); | ||||
|  | ||||
| END ARCHITECTURE masterVersion; | ||||
| @@ -0,0 +1,4 @@ | ||||
| ARCHITECTURE studentVersion OF offsetToUnsigned IS | ||||
| BEGIN | ||||
|   unsignedOut <= (others => '0'); | ||||
| END ARCHITECTURE studentVersion; | ||||
| @@ -0,0 +1,25 @@ | ||||
| -- VHDL Entity SplineInterpolator.offsetToUnsigned.symbol | ||||
| -- | ||||
| -- Created: | ||||
| --          by - francois.francois (Aphelia) | ||||
| --          at - 13:00:32 02/19/19 | ||||
| -- | ||||
| -- Generated by Mentor Graphics' HDL Designer(TM) 2019.2 (Build 5) | ||||
| -- | ||||
| LIBRARY ieee; | ||||
|   USE ieee.std_logic_1164.all; | ||||
|   USE ieee.numeric_std.all; | ||||
|  | ||||
| ENTITY offsetToUnsigned IS | ||||
|     GENERIC(  | ||||
|         bitNb : positive := 16 | ||||
|     ); | ||||
|     PORT(  | ||||
|         unsignedOut : OUT    unsigned (bitNb-1 DOWNTO 0); | ||||
|         signedIn    : IN     signed (bitNb-1 DOWNTO 0) | ||||
|     ); | ||||
|  | ||||
| -- Declarations | ||||
|  | ||||
| END offsetToUnsigned ; | ||||
|  | ||||
| @@ -0,0 +1,26 @@ | ||||
| -- VHDL Entity SplineInterpolator.resizer.symbol | ||||
| -- | ||||
| -- Created: | ||||
| --          by - francois.francois (Aphelia) | ||||
| --          at - 13:00:36 02/19/19 | ||||
| -- | ||||
| -- Generated by Mentor Graphics' HDL Designer(TM) 2019.2 (Build 5) | ||||
| -- | ||||
| LIBRARY ieee; | ||||
|   USE ieee.std_logic_1164.all; | ||||
|   USE ieee.numeric_std.all; | ||||
|  | ||||
| ENTITY resizer IS | ||||
|     GENERIC(  | ||||
|         inputBitNb  : positive := 16; | ||||
|         outputBitNb : positive := 16 | ||||
|     ); | ||||
|     PORT(  | ||||
|         resizeOut : OUT    unsigned (outputBitNb-1 DOWNTO 0); | ||||
|         resizeIn  : IN     unsigned (inputBitNb-1 DOWNTO 0) | ||||
|     ); | ||||
|  | ||||
| -- Declarations | ||||
|  | ||||
| END resizer ; | ||||
|  | ||||
| @@ -0,0 +1,33 @@ | ||||
| ARCHITECTURE masterVersion OF resizer IS | ||||
|  | ||||
| BEGIN | ||||
|  | ||||
|   outGtIn: if resizeOut'length > resizeIn'length generate | ||||
|   begin | ||||
|     resizeOut <= shift_left( | ||||
|       resize( | ||||
|         resizeIn, | ||||
|         resizeOut'length | ||||
|       ), | ||||
|       resizeOut'length-resizeIn'length | ||||
|     ); | ||||
|   end generate outGtIn; | ||||
|  | ||||
|   outEqIn: if resizeOut'length = resizeIn'length generate | ||||
|   begin | ||||
|     resizeOut <= resizeIn; | ||||
|   end generate outEqIn; | ||||
|  | ||||
|   outLtIn: if resizeOut'length < resizeIn'length generate | ||||
|   begin | ||||
|     resizeOut <= resize( | ||||
|       shift_right( | ||||
|         resizeIn, | ||||
|         resizeIn'length-resizeOut'length | ||||
|       ), | ||||
|       resizeOut'length | ||||
|     ); | ||||
|   end generate outLtIn; | ||||
|  | ||||
| END ARCHITECTURE masterVersion; | ||||
|  | ||||
| @@ -0,0 +1,4 @@ | ||||
| ARCHITECTURE studentVersion OF resizer IS | ||||
| BEGIN | ||||
|   resizeOut <= (others => '0'); | ||||
| END ARCHITECTURE studentVersion; | ||||
| @@ -0,0 +1,57 @@ | ||||
| ARCHITECTURE masterVersion OF sineTable IS | ||||
|  | ||||
|   signal changeSign : std_uLogic; | ||||
|   signal flipPhase : std_uLogic; | ||||
|   signal phaseTableAddress1 : unsigned(tableAddressBitNb-1 downto 0); | ||||
|   signal phaseTableAddress2 : unsigned(phaseTableAddress1'range); | ||||
|   signal quarterSine : signed(sine'range); | ||||
|  | ||||
|   signal shiftPhase : std_uLogic := '0';  -- can be used to build a cosine | ||||
|  | ||||
| begin | ||||
|  | ||||
|   changeSign <= phase(phase'high); | ||||
|   flipPhase <= phase(phase'high-1); | ||||
|  | ||||
|   phaseTableAddress1 <= phase(phase'high-2 downto phase'high-2-tableAddressBitNb+1); | ||||
|  | ||||
|   checkPhase: process(flipPhase, shiftPhase, phaseTableAddress1) | ||||
|   begin | ||||
|     if (flipPhase xor shiftPhase) = '0' then | ||||
|       phaseTableAddress2 <= phaseTableAddress1; | ||||
|     else | ||||
|       phaseTableAddress2 <= 0 - phaseTableAddress1; | ||||
|     end if; | ||||
|   end process checkPhase; | ||||
|  | ||||
|  | ||||
|   quarterTable: process(phaseTableAddress2, flipPhase, shiftPhase) | ||||
|   begin | ||||
|     case to_integer(phaseTableAddress2) is | ||||
|       when 0 => if (flipPhase xor shiftPhase) = '0' then | ||||
|                   quarterSine <= to_signed(16#0000#, quarterSine'length); | ||||
|                 else | ||||
|                   quarterSine <= to_signed(16#7FFF#, quarterSine'length); | ||||
|                 end if; | ||||
|       when 1 => quarterSine <= to_signed(16#18F9#, quarterSine'length); | ||||
|       when 2 => quarterSine <= to_signed(16#30FB#, quarterSine'length); | ||||
|       when 3 => quarterSine <= to_signed(16#471C#, quarterSine'length); | ||||
|       when 4 => quarterSine <= to_signed(16#5A82#, quarterSine'length); | ||||
|       when 5 => quarterSine <= to_signed(16#6A6D#, quarterSine'length); | ||||
|       when 6 => quarterSine <= to_signed(16#7641#, quarterSine'length); | ||||
|       when 7 => quarterSine <= to_signed(16#7D89#, quarterSine'length); | ||||
|       when others => quarterSine <= (others => '-'); | ||||
|     end case; | ||||
|   end process quarterTable; | ||||
|  | ||||
|   checkSign: process(changeSign, flipPhase, shiftPhase, quarterSine) | ||||
|   begin | ||||
|     if (changeSign xor (flipPhase and shiftPhase)) = '0' then | ||||
|       sine <= quarterSine; | ||||
|     else | ||||
|       sine <= 0 - quarterSine; | ||||
|     end if; | ||||
|   end process checkSign; | ||||
|  | ||||
| END ARCHITECTURE masterVersion; | ||||
|  | ||||
| @@ -0,0 +1,27 @@ | ||||
| ARCHITECTURE studentVersion OF sineTable IS | ||||
|  | ||||
|   signal phaseTableAddress : unsigned(tableAddressBitNb-1 downto 0); | ||||
|   signal quarterSine : signed(sine'range); | ||||
|  | ||||
| BEGIN | ||||
|  | ||||
|   phaseTableAddress <= phase(phase'high-2 downto phase'high-2-tableAddressBitNb+1); | ||||
|  | ||||
|   quarterTable: process(phaseTableAddress) | ||||
|   begin | ||||
|     case to_integer(phaseTableAddress) is | ||||
|       when 0 => quarterSine <= to_signed(16#0000#, quarterSine'length); | ||||
|       when 1 => quarterSine <= to_signed(16#18F9#, quarterSine'length); | ||||
|       when 2 => quarterSine <= to_signed(16#30FB#, quarterSine'length); | ||||
|       when 3 => quarterSine <= to_signed(16#471C#, quarterSine'length); | ||||
|       when 4 => quarterSine <= to_signed(16#5A82#, quarterSine'length); | ||||
|       when 5 => quarterSine <= to_signed(16#6A6D#, quarterSine'length); | ||||
|       when 6 => quarterSine <= to_signed(16#7641#, quarterSine'length); | ||||
|       when 7 => quarterSine <= to_signed(16#7D89#, quarterSine'length); | ||||
|       when others => quarterSine <= (others => '-'); | ||||
|     end case; | ||||
|   end process quarterTable; | ||||
|  | ||||
|   sine <= (others => '0'); | ||||
|  | ||||
| END ARCHITECTURE studentVersion; | ||||
| @@ -0,0 +1,31 @@ | ||||
| -- VHDL Entity SplineInterpolator.sineGen.symbol | ||||
| -- | ||||
| -- Created: | ||||
| --          by - francois.francois (Aphelia) | ||||
| --          at - 13:00:40 02/19/19 | ||||
| -- | ||||
| -- Generated by Mentor Graphics' HDL Designer(TM) 2019.2 (Build 5) | ||||
| -- | ||||
| LIBRARY ieee; | ||||
|   USE ieee.std_logic_1164.all; | ||||
|   USE ieee.numeric_std.all; | ||||
|  | ||||
| ENTITY sineGen IS | ||||
|     GENERIC(  | ||||
|         signalBitNb : positive := 16; | ||||
|         phaseBitNb  : positive := 10 | ||||
|     ); | ||||
|     PORT(  | ||||
|         clock    : IN     std_ulogic; | ||||
|         reset    : IN     std_ulogic; | ||||
|         step     : IN     unsigned (phaseBitNb-1 DOWNTO 0); | ||||
|         sawtooth : OUT    unsigned (signalBitNb-1 DOWNTO 0); | ||||
|         sine     : OUT    unsigned (signalBitNb-1 DOWNTO 0); | ||||
|         square   : OUT    unsigned (signalBitNb-1 DOWNTO 0); | ||||
|         triangle : OUT    unsigned (signalBitNb-1 DOWNTO 0) | ||||
|     ); | ||||
|  | ||||
| -- Declarations | ||||
|  | ||||
| END sineGen ; | ||||
|  | ||||
| @@ -0,0 +1,307 @@ | ||||
| -- | ||||
| -- VHDL Architecture SplineInterpolator.sineGen.struct | ||||
| -- | ||||
| -- Created: | ||||
| --          by - axel.amand.UNKNOWN (WE7860) | ||||
| --          at - 14:42:04 28.04.2023 | ||||
| -- | ||||
| -- Generated by Mentor Graphics' HDL Designer(TM) 2019.2 (Build 5) | ||||
| -- | ||||
| LIBRARY ieee; | ||||
|   USE ieee.std_logic_1164.all; | ||||
|   USE ieee.numeric_std.all; | ||||
|  | ||||
| LIBRARY SplineInterpolator; | ||||
| LIBRARY WaveformGenerator; | ||||
|  | ||||
| ARCHITECTURE struct OF sineGen IS | ||||
|  | ||||
|     -- Architecture declarations | ||||
|     constant tableAddressBitNb : positive := 3; | ||||
|     constant sampleCountBitNb : positive := phaseBitNb-2-tableAddressBitNb; | ||||
|     constant coeffBitNb : positive := signalBitNb+4; | ||||
|  | ||||
|     -- Internal signal declarations | ||||
|     SIGNAL a           : signed(coeffBitNb-1 DOWNTO 0); | ||||
|     SIGNAL b           : signed(coeffBitNb-1 DOWNTO 0); | ||||
|     SIGNAL c           : signed(coeffBitNb-1 DOWNTO 0); | ||||
|     SIGNAL d           : signed(coeffBitNb-1 DOWNTO 0); | ||||
|     SIGNAL logic0      : std_ulogic; | ||||
|     SIGNAL logic1      : std_ulogic; | ||||
|     SIGNAL newPolynom  : std_ulogic; | ||||
|     SIGNAL phase       : unsigned(phaseBitNb-1 DOWNTO 0); | ||||
|     SIGNAL sample1     : signed(signalBitNb-1 DOWNTO 0); | ||||
|     SIGNAL sample2     : signed(signalBitNb-1 DOWNTO 0); | ||||
|     SIGNAL sample3     : signed(signalBitNb-1 DOWNTO 0); | ||||
|     SIGNAL sample4     : signed(signalBitNb-1 DOWNTO 0); | ||||
|     SIGNAL sineSamples : signed(signalBitNb-1 DOWNTO 0); | ||||
|     SIGNAL sineSigned  : signed(signalBitNb-1 DOWNTO 0); | ||||
|  | ||||
|     -- Implicit buffer signal declarations | ||||
|     SIGNAL sawtooth_internal : unsigned (signalBitNb-1 DOWNTO 0); | ||||
|  | ||||
|  | ||||
|     -- Component Declarations | ||||
|     COMPONENT interpolatorCalculatePolynom | ||||
|     GENERIC ( | ||||
|         signalBitNb       : positive := 16; | ||||
|         coeffBitNb        : positive := 16; | ||||
|         oversamplingBitNb : positive := 8 | ||||
|     ); | ||||
|     PORT ( | ||||
|         clock          : IN     std_ulogic ; | ||||
|         reset          : IN     std_ulogic ; | ||||
|         restartPolynom : IN     std_ulogic ; | ||||
|         d              : IN     signed (coeffBitNb-1 DOWNTO 0); | ||||
|         sampleOut      : OUT    signed (signalBitNb-1 DOWNTO 0); | ||||
|         c              : IN     signed (coeffBitNb-1 DOWNTO 0); | ||||
|         b              : IN     signed (coeffBitNb-1 DOWNTO 0); | ||||
|         a              : IN     signed (coeffBitNb-1 DOWNTO 0); | ||||
|         en             : IN     std_ulogic  | ||||
|     ); | ||||
|     END COMPONENT; | ||||
|     COMPONENT interpolatorCoefficients | ||||
|     GENERIC ( | ||||
|         bitNb      : positive := 16; | ||||
|         coeffBitNb : positive := 16 | ||||
|     ); | ||||
|     PORT ( | ||||
|         sample1           : IN     signed (bitNb-1 DOWNTO 0); | ||||
|         sample2           : IN     signed (bitNb-1 DOWNTO 0); | ||||
|         sample3           : IN     signed (bitNb-1 DOWNTO 0); | ||||
|         sample4           : IN     signed (bitNb-1 DOWNTO 0); | ||||
|         a                 : OUT    signed (coeffBitNb-1 DOWNTO 0); | ||||
|         b                 : OUT    signed (coeffBitNb-1 DOWNTO 0); | ||||
|         c                 : OUT    signed (coeffBitNb-1 DOWNTO 0); | ||||
|         d                 : OUT    signed (coeffBitNb-1 DOWNTO 0); | ||||
|         interpolateLinear : IN     std_ulogic  | ||||
|     ); | ||||
|     END COMPONENT; | ||||
|     COMPONENT interpolatorShiftRegister | ||||
|     GENERIC ( | ||||
|         signalBitNb : positive := 16 | ||||
|     ); | ||||
|     PORT ( | ||||
|         clock        : IN     std_ulogic ; | ||||
|         reset        : IN     std_ulogic ; | ||||
|         shiftSamples : IN     std_ulogic ; | ||||
|         sampleIn     : IN     signed (signalBitNb-1 DOWNTO 0); | ||||
|         sample1      : OUT    signed (signalBitNb-1 DOWNTO 0); | ||||
|         sample2      : OUT    signed (signalBitNb-1 DOWNTO 0); | ||||
|         sample3      : OUT    signed (signalBitNb-1 DOWNTO 0); | ||||
|         sample4      : OUT    signed (signalBitNb-1 DOWNTO 0) | ||||
|     ); | ||||
|     END COMPONENT; | ||||
|     COMPONENT interpolatorTrigger | ||||
|     GENERIC ( | ||||
|         counterBitNb : positive := 4 | ||||
|     ); | ||||
|     PORT ( | ||||
|         triggerOut : OUT    std_ulogic ; | ||||
|         clock      : IN     std_ulogic ; | ||||
|         reset      : IN     std_ulogic ; | ||||
|         en         : IN     std_ulogic  | ||||
|     ); | ||||
|     END COMPONENT; | ||||
|     COMPONENT offsetToUnsigned | ||||
|     GENERIC ( | ||||
|         bitNb : positive := 16 | ||||
|     ); | ||||
|     PORT ( | ||||
|         unsignedOut : OUT    unsigned (bitNb-1 DOWNTO 0); | ||||
|         signedIn    : IN     signed (bitNb-1 DOWNTO 0) | ||||
|     ); | ||||
|     END COMPONENT; | ||||
|     COMPONENT resizer | ||||
|     GENERIC ( | ||||
|         inputBitNb  : positive := 16; | ||||
|         outputBitNb : positive := 16 | ||||
|     ); | ||||
|     PORT ( | ||||
|         resizeOut : OUT    unsigned (outputBitNb-1 DOWNTO 0); | ||||
|         resizeIn  : IN     unsigned (inputBitNb-1 DOWNTO 0) | ||||
|     ); | ||||
|     END COMPONENT; | ||||
|     COMPONENT sineTable | ||||
|     GENERIC ( | ||||
|         inputBitNb        : positive := 16; | ||||
|         outputBitNb       : positive := 16; | ||||
|         tableAddressBitNb : positive := 3 | ||||
|     ); | ||||
|     PORT ( | ||||
|         sine  : OUT    signed (outputBitNb-1 DOWNTO 0); | ||||
|         phase : IN     unsigned (inputBitNb-1 DOWNTO 0) | ||||
|     ); | ||||
|     END COMPONENT; | ||||
|     COMPONENT sawtoothGen | ||||
|     GENERIC ( | ||||
|         bitNb : positive := 16 | ||||
|     ); | ||||
|     PORT ( | ||||
|         sawtooth : OUT    unsigned (bitNb-1 DOWNTO 0); | ||||
|         clock    : IN     std_ulogic ; | ||||
|         reset    : IN     std_ulogic ; | ||||
|         step     : IN     unsigned (bitNb-1 DOWNTO 0); | ||||
|         en       : IN     std_ulogic  | ||||
|     ); | ||||
|     END COMPONENT; | ||||
|     COMPONENT sawtoothToSquare | ||||
|     GENERIC ( | ||||
|         bitNb : positive := 16 | ||||
|     ); | ||||
|     PORT ( | ||||
|         square   : OUT    unsigned (bitNb-1 DOWNTO 0); | ||||
|         sawtooth : IN     unsigned (bitNb-1 DOWNTO 0) | ||||
|     ); | ||||
|     END COMPONENT; | ||||
|     COMPONENT sawtoothToTriangle | ||||
|     GENERIC ( | ||||
|         bitNb : positive := 16 | ||||
|     ); | ||||
|     PORT ( | ||||
|         triangle : OUT    unsigned (bitNb-1 DOWNTO 0); | ||||
|         sawtooth : IN     unsigned (bitNb-1 DOWNTO 0) | ||||
|     ); | ||||
|     END COMPONENT; | ||||
|  | ||||
|     -- Optional embedded configurations | ||||
|     -- pragma synthesis_off | ||||
|     FOR ALL : interpolatorCalculatePolynom USE ENTITY SplineInterpolator.interpolatorCalculatePolynom; | ||||
|     FOR ALL : interpolatorCoefficients USE ENTITY SplineInterpolator.interpolatorCoefficients; | ||||
|     FOR ALL : interpolatorShiftRegister USE ENTITY SplineInterpolator.interpolatorShiftRegister; | ||||
|     FOR ALL : interpolatorTrigger USE ENTITY SplineInterpolator.interpolatorTrigger; | ||||
|     FOR ALL : offsetToUnsigned USE ENTITY SplineInterpolator.offsetToUnsigned; | ||||
|     FOR ALL : resizer USE ENTITY SplineInterpolator.resizer; | ||||
|     FOR ALL : sawtoothGen USE ENTITY WaveformGenerator.sawtoothGen; | ||||
|     FOR ALL : sawtoothToSquare USE ENTITY WaveformGenerator.sawtoothToSquare; | ||||
|     FOR ALL : sawtoothToTriangle USE ENTITY WaveformGenerator.sawtoothToTriangle; | ||||
|     FOR ALL : sineTable USE ENTITY SplineInterpolator.sineTable; | ||||
|     -- pragma synthesis_on | ||||
|  | ||||
|  | ||||
| BEGIN | ||||
|     -- Architecture concurrent statements | ||||
|     -- HDL Embedded Text Block 2 eb2 | ||||
|     logic1 <= '1'; | ||||
|  | ||||
|     -- HDL Embedded Text Block 3 eb3 | ||||
|     logic0 <= '0'; | ||||
|  | ||||
|  | ||||
|     -- Instance port mappings. | ||||
|     I_spline : interpolatorCalculatePolynom | ||||
|         GENERIC MAP ( | ||||
|             signalBitNb       => signalBitNb, | ||||
|             coeffBitNb        => coeffBitNb, | ||||
|             oversamplingBitNb => sampleCountBitNb | ||||
|         ) | ||||
|         PORT MAP ( | ||||
|             clock          => clock, | ||||
|             reset          => reset, | ||||
|             restartPolynom => newPolynom, | ||||
|             d              => d, | ||||
|             sampleOut      => sineSigned, | ||||
|             c              => c, | ||||
|             b              => b, | ||||
|             a              => a, | ||||
|             en             => logic1 | ||||
|         ); | ||||
|     I_coeffs : interpolatorCoefficients | ||||
|         GENERIC MAP ( | ||||
|             bitNb      => signalBitNb, | ||||
|             coeffBitNb => coeffBitNb | ||||
|         ) | ||||
|         PORT MAP ( | ||||
|             sample1           => sample1, | ||||
|             sample2           => sample2, | ||||
|             sample3           => sample3, | ||||
|             sample4           => sample4, | ||||
|             a                 => a, | ||||
|             b                 => b, | ||||
|             c                 => c, | ||||
|             d                 => d, | ||||
|             interpolateLinear => logic0 | ||||
|         ); | ||||
|     I_shReg : interpolatorShiftRegister | ||||
|         GENERIC MAP ( | ||||
|             signalBitNb => signalBitNb | ||||
|         ) | ||||
|         PORT MAP ( | ||||
|             clock        => clock, | ||||
|             reset        => reset, | ||||
|             shiftSamples => newPolynom, | ||||
|             sampleIn     => sineSamples, | ||||
|             sample1      => sample1, | ||||
|             sample2      => sample2, | ||||
|             sample3      => sample3, | ||||
|             sample4      => sample4 | ||||
|         ); | ||||
|     I_trig : interpolatorTrigger | ||||
|         GENERIC MAP ( | ||||
|             counterBitNb => sampleCountBitNb | ||||
|         ) | ||||
|         PORT MAP ( | ||||
|             triggerOut => newPolynom, | ||||
|             clock      => clock, | ||||
|             reset      => reset, | ||||
|             en         => logic1 | ||||
|         ); | ||||
|     I_unsigned : offsetToUnsigned | ||||
|         GENERIC MAP ( | ||||
|             bitNb => signalBitNb | ||||
|         ) | ||||
|         PORT MAP ( | ||||
|             unsignedOut => sine, | ||||
|             signedIn    => sineSigned | ||||
|         ); | ||||
|     I_size : resizer | ||||
|         GENERIC MAP ( | ||||
|             inputBitNb  => phaseBitNb, | ||||
|             outputBitNb => signalBitNb | ||||
|         ) | ||||
|         PORT MAP ( | ||||
|             resizeOut => sawtooth_internal, | ||||
|             resizeIn  => phase | ||||
|         ); | ||||
|     I_sin : sineTable | ||||
|         GENERIC MAP ( | ||||
|             inputBitNb        => phaseBitNb, | ||||
|             outputBitNb       => signalBitNb, | ||||
|             tableAddressBitNb => tableAddressBitNb | ||||
|         ) | ||||
|         PORT MAP ( | ||||
|             sine  => sineSamples, | ||||
|             phase => phase | ||||
|         ); | ||||
|     I_saw : sawtoothGen | ||||
|         GENERIC MAP ( | ||||
|             bitNb => phaseBitNb | ||||
|         ) | ||||
|         PORT MAP ( | ||||
|             sawtooth => phase, | ||||
|             clock    => clock, | ||||
|             reset    => reset, | ||||
|             step     => step, | ||||
|             en       => logic1 | ||||
|         ); | ||||
|     I_square : sawtoothToSquare | ||||
|         GENERIC MAP ( | ||||
|             bitNb => signalBitNb | ||||
|         ) | ||||
|         PORT MAP ( | ||||
|             square   => square, | ||||
|             sawtooth => sawtooth_internal | ||||
|         ); | ||||
|     I_tri : sawtoothToTriangle | ||||
|         GENERIC MAP ( | ||||
|             bitNb => signalBitNb | ||||
|         ) | ||||
|         PORT MAP ( | ||||
|             triangle => triangle, | ||||
|             sawtooth => sawtooth_internal | ||||
|         ); | ||||
|  | ||||
|     -- Implicit buffered output assignments | ||||
|     sawtooth <= sawtooth_internal; | ||||
|  | ||||
| END struct; | ||||
| @@ -0,0 +1,27 @@ | ||||
| -- VHDL Entity SplineInterpolator.sineTable.symbol | ||||
| -- | ||||
| -- Created: | ||||
| --          by - francois.francois (Aphelia) | ||||
| --          at - 13:00:46 02/19/19 | ||||
| -- | ||||
| -- Generated by Mentor Graphics' HDL Designer(TM) 2019.2 (Build 5) | ||||
| -- | ||||
| LIBRARY ieee; | ||||
|   USE ieee.std_logic_1164.all; | ||||
|   USE ieee.numeric_std.all; | ||||
|  | ||||
| ENTITY sineTable IS | ||||
|     GENERIC(  | ||||
|         inputBitNb        : positive := 16; | ||||
|         outputBitNb       : positive := 16; | ||||
|         tableAddressBitNb : positive := 3 | ||||
|     ); | ||||
|     PORT(  | ||||
|         sine  : OUT    signed (outputBitNb-1 DOWNTO 0); | ||||
|         phase : IN     unsigned (inputBitNb-1 DOWNTO 0) | ||||
|     ); | ||||
|  | ||||
| -- Declarations | ||||
|  | ||||
| END sineTable ; | ||||
|  | ||||
		Reference in New Issue
	
	Block a user