-- Interactive Audio Manipulation Processor -- -- file: audio.vhd -- status: not compiled -- -- author: Stephen Tang -- -- A wrapper entity for the audio functionality. Currently, this entity -- only converts the onscreen X and Y coordinates of the sound source to -- a coarser-grained set of coordinates. library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; library work; use work.Constants_Pkg.all; entity audio2 is port ( clock: in std_logic; screenX: in std_logic_vector(DISPLAY_X-1 downto 0); screenY: in std_logic_vector(DISPLAY_Y-1-4 downto 0); locationX: out std_logic_vector(SOURCE_WIDTH-1 downto 0); locationY: out std_logic_vector(SOURCE_WIDTH-1 downto 0) ); end audio2; architecture wrapper of audio2 is begin ConvertCoordinates: process(clock) variable count1,count2: std_logic_vector(DISPLAY_X-1-4 downto 0); variable countA,countB: std_logic_vector(DISPLAY_X-1 downto 0); variable val,newLocation: std_logic_vector(SOURCE_WIDTH-1 downto 0); variable NoRemainder: std_logic_vector(1 downto 0); begin if rising_edge(clock) then -- convert X value; see end of file for more info countB := "0000000000"; val := "0000"; NoRemainder := "00"; for i in 1 to MAX_SOUND loop countA := countB; countB := countB + X"2B"; -- add 42+1 val := val + "0001"; NoRemainder := NoRemainder + '1'; if (NoRemainder = "11") then countB := countB - '1'; NoRemainder := "00"; end if; if (screenX >= countA) and (screenX < countB) then newLocation := val; i := MAX_SOUND; end if; end loop; locationX <= newLocation; -- convert Y value count2 := "000000"; val := "0000"; for i in 1 to MAX_SOUND loop count1 := count2; count2 := count2 + X"2"; -- add 32 val := val + "0001"; if (screenY >= count1) and (screenY < count2) then newLocation := val; end if; end loop; locationY <= newLocation; end if; end process ConvertCoordinates; end;