------------------------------------- -- incident_gain.vhd -- Incident Gain Calculator -- -- March 10, 2000 -- Ross, Daniel 355951 -- -- Given the four-bit unsigned -- integers X and Y, we will calculate -- gain values for each speaker, -- A00 through A11 (4-bit unsigned, 0-15). library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; entity incident_gain is generic (bitwidth : positive := 4); port (X, Y : in std_logic_vector (bitwidth-1 downto 0); A00,A01,A10,A11 : out std_logic_vector (bitwidth-1 downto 0) ); end incident_gain; architecture behavioral of incident_gain is signal newX, newY, gain00, gain01, gain10, gain11, notX, notY: std_logic_vector(bitwidth downto 0); signal max00, max01, max10, max11: std_logic_vector(bitwidth downto 0); begin not_calc: process begin newX(bitwidth) <= '0'; newX(bitwidth-1 downto 0) <= X(bitwidth-1 downto 0); newY(bitwidth) <= '0'; newY(bitwidth-1 downto 0) <= Y(bitwidth-1 downto 0); notX <= 16 - newX; notY <= 16 - newY; end process not_calc; gain_00: process begin if newX > newY then max00 <= newX; else max00 <= newY; end if; gain00 <= 16 - max00; if notX > newY then max01 <= notX; else max01 <= newY; end if; gain01 <= 16 - max01; if newX > notY then max10 <= newX; else max10 <= notY; end if; gain10 <= 16 - max10; if notX > notY then max11 <= notX; else max11 <= notY; end if; gain11 <= 16 - max11; end process gain_00; to_output: process begin A00(bitwidth-1 downto 0) <= gain00(bitwidth-1 downto 0); A01(bitwidth-1 downto 0) <= gain01(bitwidth-1 downto 0); A10(bitwidth-1 downto 0) <= gain10(bitwidth-1 downto 0); A11(bitwidth-1 downto 0) <= gain11(bitwidth-1 downto 0); end process to_output; end behavioral;