-- indi16 vhdl -- Delta Sigma DAC (First Order) -- (C)2007 K Ring Technologies Semiconductor -- designed for 66MHz operation LIBRARY ieee; USE ieee.std_logic_1164.all; USE ieee.std_logic_unsigned.all; ENTITY dac IS PORT ( CLK_I : IN STD_LOGIC; Sample : IN STD_LOGIC_VECTOR(15 DOWNTO 0); Output : OUT STD_LOGIC ); END dac; ARCHITECTURE a OF dac IS SIGNAL Residual, Diff : STD_LOGIC_VECTOR(16 DOWNTO 0); BEGIN Diff <= (Sample(15) & Sample) - Residual; PROCESS(CLK_I) CONSTANT Max : STD_LOGIC_VECTOR(16 DOWNTO 0) := "10000000000000000"; BEGIN IF rising_edge(CLK_I) THEN -- output 1 when +ve and 0 when -ve Output <= NOT Diff(16); -- calc the residual with sign (assumes +max = 0-(+max) for easier calc) -- residual is the overshooted by amount Residual <= Max - Diff; END IF; END PROCESS; END a;