Archived
1
0

add solutions

This commit is contained in:
2024-03-15 15:03:34 +01:00
parent 3095603e39
commit 9ceb15c0ff
612 changed files with 272868 additions and 0 deletions

View File

@ -0,0 +1,29 @@
ARCHITECTURE masterVersion OF DAC IS
signal parallelIn1: unsigned(parallelIn'range);
signal integrator: unsigned(parallelIn'high+1 downto 0);
signal quantized: std_ulogic;
BEGIN
-- parallelIn1 <= parallelIn;
parallelIn1 <= parallelIn/2 + 2**(parallelIn'length-2);
integrate: process(reset, clock)
begin
if reset = '1' then
integrator <= (others => '0');
elsif rising_edge(clock) then
if quantized = '0' then
integrator <= integrator + parallelIn1;
else
integrator <= integrator + parallelIn1 - 2**parallelIn'length;
end if;
end if;
end process integrate;
quantized <= integrator(integrator'high);
serialOut <= quantized;
END ARCHITECTURE masterVersion;

View File

@ -0,0 +1,4 @@
ARCHITECTURE studentVersion OF DAC IS
BEGIN
serialOut <= '0';
END ARCHITECTURE studentVersion;

View File

@ -0,0 +1,59 @@
ARCHITECTURE order2_masterVersion OF DAC IS
constant attenuationShift: positive := 3;
constant acc1BitNb: positive := parallelIn'length+5;
constant acc2BitNb: positive := parallelIn'length+5;
signal parallelIn1, parallelIn2: signed(parallelIn'high downto 0);
signal acc1: signed(acc1BitNb-1 downto 0);
signal acc2: signed(acc2BitNb-1 downto 0);
constant c1: signed(acc1'range)
:= shift_left(to_signed(1, acc1'length), parallelIn'length-1);
constant c2: signed(acc2'range)
:= resize(shift_left(c1, 4), acc2'length);
signal quantized: std_ulogic;
BEGIN
------------------------------------------------------------------------------
-- offset input to signed values
parallelIn1(parallelIn1'high) <= not parallelIn(parallelIn'high);
parallelIn1(parallelIn1'high-1 downto 0) <=
signed(parallelIn(parallelIn'high-1 downto 0));
-- attenuate signal
parallelIn2 <= parallelIn1 - shift_right(parallelIn1, attenuationShift);
------------------------------------------------------------------------------
-- SD integrators
integrate1: process(reset, clock)
begin
if reset = '1' then
acc1 <= (others => '0');
elsif rising_edge(clock) then
if quantized = '1' then
acc1 <= acc1 + resize(parallelIn2, acc1'length) - c1;
else
acc1 <= acc1 + resize(parallelIn2, acc1'length) + c1;
end if;
end if;
end process integrate1;
integrate2: process(reset, clock)
begin
if reset = '1' then
acc2 <= (others => '0');
elsif rising_edge(clock) then
if quantized = '1' then
acc2 <= acc2 + resize(acc1, acc2'length) - c2;
else
acc2 <= acc2 + resize(acc1, acc2'length) + c2;
end if;
end if;
end process integrate2;
------------------------------------------------------------------------------
-- test last integrator output
quantized <= '1' when acc2 >= 0 else '0';
serialOut <= quantized;
END ARCHITECTURE order2_masterVersion;

View File

@ -0,0 +1,4 @@
ARCHITECTURE order2_studentVersion OF DAC IS
BEGIN
serialOut <= '0';
END ARCHITECTURE order2_studentVersion;

View File

@ -0,0 +1,27 @@
-- VHDL Entity DigitalToAnalogConverter.DAC.symbol
--
-- Created:
-- by - francois.francois (Aphelia)
-- at - 13:06:08 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 DAC IS
GENERIC(
signalBitNb : positive := 16
);
PORT(
serialOut : OUT std_ulogic;
parallelIn : IN unsigned (signalBitNb-1 DOWNTO 0);
clock : IN std_ulogic;
reset : IN std_ulogic
);
-- Declarations
END DAC ;