-- Interactive Audio Manipulation Processor -- -- file: AudioCoords.vhd -- status: simulated -- no known errors -- -- author: Stephen Tang -- -- This entity converts the onscreen X and Y coordinates of the sound -- source from the onscreen 640x480 space to the coarser-grained 15x15 -- space required by the audio manipulator. 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 AudioCoords is port ( clock: in std_logic; -- should be 80ns screenX: in std_logic_vector(DISPLAY_X-1 downto 0); -- note! only supply the MOST significant bits of Y coords here screenY: in std_logic_vector(DISPLAY_Y-1 downto 0); locationX: out std_logic_vector(SOURCE_WIDTH-1 downto 0); locationY: out std_logic_vector(SOURCE_WIDTH-1 downto 0) ); end AudioCoords; architecture wrapper of AudioCoords is begin ConvertCoordinates: process(clock) variable count1,count2: std_logic_vector(DISPLAY_Y-1 downto 0); variable val,newLocation: std_logic_vector(SOURCE_WIDTH-1 downto 0); begin if rising_edge(clock) then -- convert X value; This gigantic if-else ladder looks horribly -- inelegant, but it uses up fewer logic cells than doing the -- job elegantly with adders, counters and multipliers (like -- the Y coordinate conversion below). See end of file for more info -- on how the condition values were chosen. if (screenX >= "0000000000") and (screenX < "0000101010") then locationX <= X"1"; elsif (screenX >= "0000101010") and (screenX < "0001010101") then locationX <= X"2"; elsif (screenX >= "0001010101") and (screenX < "0010000000") then locationX <= X"3"; elsif (screenX >= "0010000000") and (screenX < "0010101010") then locationX <= X"4"; elsif (screenX >= "0010101010") and (screenX < "0011010101") then locationX <= X"5"; elsif (screenX >= "0011010101") and (screenX < "0100000000") then locationX <= X"6"; elsif (screenX > "0011111111") and (screenX < "0100101011") then locationX <= X"7"; elsif (screenX > "0100101010") and (screenX < "0101010101") then locationX <= X"8"; elsif (screenX >= "0101010101") and (screenX < "0110000000") then locationX <= X"9"; elsif (screenX >= "0110000000") and (screenX < "0110101010") then locationX <= X"A"; elsif (screenX >= "0110101010") and (screenX < "0111010101") then locationX <= X"B"; elsif (screenX >= "0111010101") and (screenX < "1000000000") then locationX <= X"C"; elsif (screenX >= "1000000000") and (screenX < "1000101010") then locationX <= X"D"; elsif (screenX >= "1000101010") and (screenX < "1001010101") then locationX <= X"E"; elsif (screenX >= "1001010101") and (screenX < "1010000000") then locationX <= X"F"; end if; -- convert Y value -- 480/15 = 32, so there are 32 pixels for each big block. For -- every count of 32, increment the course-grained y-coordinate by one. count2 := "0000000000"; val := "0000"; for i in 1 to MAX_SOUND loop count1 := count2; count2 := count2 + X"20"; -- 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; -- The ranges of X values make use of the following values, which -- were manually found by taking 640/15*n, where 0