---------------------------------------------------------------------------------- -- Company: CPE133-07 -- Asian Kids: Jade Jang, Kevin Yu, William Hsu & Alvin Chui -- Create Date: 11/28/2017 09:51:58 PM -- Design Name: Frequency Comparator -- Module Name: 12bitComparator - Behavioral -- Revision 0.01 - File Created -- Additional Comments: Compare two input, one from the user interface, and the other is from reciever. -- Both are 12 bit data. ---------------------------------------------------------------------------------- library IEEE; use IEEE.STD_LOGIC_1164.All; entity Comparator is Port ( Ain, Bin : in STD_LOGIC_VECTOR(11 downto 0); high : out STD_LOGIC; low : out STD_LOGIC; note : out STD_LOGIC_VECTOR(3 downto 0)); end Comparator; architecture my_arch of Comparator is component RCA is Port ( A : in STD_LOGIC_VECTOR(11 downto 0); B : in STD_LOGIC_VECTOR(11 downto 0); SUM : out STD_LOGIC_VECTOR(11 downto 0); Cout : out STD_LOGIC); end component; signal sum1, sum2: STD_LOGIC_VECTOR(11 downto 0); signal c1, c2 : STD_LOGIC; begin RCA1 : RCA port map ( A => Ain, B => "000000000010", Cout => c1, SUM => sum1); -- sum1 is upper bound RCA2 : RCA port map ( A => Bin, B => "000000000010", Cout => c2, SUM => sum2); proc1: process (Ain, Bin, sum1, sum2) begin if (sum1 < Bin) then high <= '0'; low <= '1'; elsif (sum2 < Ain) then high <= '1'; low <= '0'; else high <= '0'; low <= '0'; end if; end process proc1; proc2: process (Ain) -- from e2 to g5, typical guitar range begin if (Ain >= "000001010000" AND Ain <= "000001010100") then -- e2 note <= "0101"; end if; if (Ain >= "000001010101" AND Ain <= "000001011001") then -- f2 note <= "0110"; end if; if (Ain >= "000001011010" AND Ain <= "000001011110") then -- f2 sharp note <= "1110"; end if; if (Ain >= "000001100000" AND Ain <= "000001100100") then -- g2 note <= "0111"; end if; if (Ain >= "000001100110" AND Ain <= "000001101010") then -- g2 sharp note <= "1111"; end if; if (Ain >= "000001101100" AND Ain <= "000001110000") then -- a2 note <= "0001"; end if; if (Ain >= "000001110010" AND Ain <= "000001110110") then -- a2 sharp note <= "1001"; end if; if (Ain >= "000001111001" AND Ain <= "000001111101") then -- b2 note <= "0010"; end if; if (Ain >= "000010000001" AND Ain <= "000010000101") then -- c3 note <= "0011"; end if; if (Ain >= "000010001001" AND Ain <= "000010001101") then -- c3 sharp note <= "1011"; end if; if (Ain >= "000010010001" AND Ain <= "000010010101") then -- d3 note <= "0100"; end if; if (Ain >= "000010011010" AND Ain <= "000010011110") then -- d3 sharp note <= "1100"; end if; if (Ain >= "000010100011" AND Ain <= "000010100111") then -- e3 note <= "0101"; end if; if (Ain >= "000010101101" AND Ain <= "000010110001") then -- f3 note <= "0110"; end if; if (Ain >= "000010110111" AND Ain <= "000010111011") then -- f3 sharp note <= "1110"; end if; if (Ain >= "000011000010" AND Ain <= "000011000110") then -- g3 note <= "0111"; end if; if (Ain >= "000011001110" AND Ain <= "000011010010") then -- g3 sharp note <= "1111"; end if; if (Ain >= "000011011010" AND Ain <= "000011011110") then -- a3 note <= "0001"; end if; if (Ain >= "000011100111" AND Ain <= "000011101011") then -- a3 sharp note <= "1001"; end if; if (Ain >= "000011110101" AND Ain <= "000011111001") then -- b3 note <= "0010"; end if; if (Ain >= "000100000100" AND Ain <= "000100001000") then -- c4 note <= "0011"; end if; if (Ain >= "000100010011" AND Ain <= "000100010111") then -- c4 sharp note <= "1011"; end if; if (Ain >= "000100100100" AND Ain <= "000100101000") then -- d4 note <= "0100"; end if; if (Ain >= "000100110101" AND Ain <= "000100111001") then -- d4 sharp note <= "1100"; end if; if (Ain >= "000101001000" AND Ain <= "000101001100") then -- e4 note <= "0101"; end if; if (Ain >= "000101011011" AND Ain <= "000101011111") then -- f4 note <= "0110"; end if; if (Ain >= "000101110000" AND Ain <= "000101110100") then -- f4 sharp note <= "1110"; end if; if (Ain >= "000110000110" AND Ain <= "000110001010") then -- g4 note <= "0111"; end if; if (Ain >= "000110011101" AND Ain <= "000110100000") then -- g4 sharp note <= "1111"; end if; if (Ain >= "000110110110" AND Ain <= "000110111010") then -- a4 note <= "0001"; end if; if (Ain >= "000111010000" AND Ain <= "000111010100") then -- a4 sharp note <= "1001"; end if; if (Ain >= "000111101100" AND Ain <= "000111110000") then -- b4 note <= "0010"; end if; if (Ain >= "001000001001" AND Ain <= "001000001101") then -- c5 note <= "0011"; end if; if (Ain >= "001000101000" AND Ain <= "001000101100") then -- c5 sharp note <= "1011"; end if; if (Ain >= "001001001001" AND Ain <= "001001001101") then -- d5 note <= "0100"; end if; if (Ain >= "001001101100" AND Ain <= "001001110000") then -- d5 sharp note <= "1100"; end if; if (Ain >= "001010010001" AND Ain <= "001010010101") then -- e5 note <= "0101"; end if; if (Ain >= "001010111000" AND Ain <= "001010111100") then -- f5 note <= "0110"; end if; if (Ain >= "001011100010" AND Ain <= "001011100110") then -- f5 sharp note <= "1110"; end if; if (Ain >= "001100001110" AND Ain <= "001100010010") then -- g5 note <= "0111"; end if; end process proc2; end my_arch;