library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.numeric_std.all;
entity QAM_demod is
Port ( Q_channel : in STD_LOGIC_VECTOR (7 downto 0);
I_channel : in STD_LOGIC_VECTOR (7 downto 0);
symbol : out STD_LOGIC_VECTOR (3 downto 0);
clk : in STD_LOGIC);
end QAM_demod;
architecture Behavioral of QAM_demod is
signal Q : integer range -2 to 2;
signal I :integer range -2 to 2;
signal Qsigned : signed (7 downto 0);
signal Isigned : signed (7 downto 0);
signal data : std_logic_vector(3 downto 0);
begin
Qsigned <= TO_SIGNED(Q_channel);
Isigned <= TO_SIGNED(I_channel);
Q <= TO_INTEGER(Qsigned);
I <= TO_INTEGER(Isigned);
process(clk,Q,I)
begin
if (clk'event and clk ='1')
then
case Q is
when -1 =>
if(I=-1)then
data<="0000";
elsif(I=-2) then
data<="0010";
elsif(I=1) then
data<="1000";
elsif(I=2) then
data<="1010";
else
data<="0000";
end if;
when -2 =>
if(I=-1)then
data<="0001";
elsif(I=-2) then
data<="0011";
elsif(I=1) then
data<="1001";
elsif(I=2) then
data<="1011";
else
data<="0000";
end if;
when 1 =>
if(I=-1)then
data<="0100";
elsif(I=-2) then
data<="0110";
elsif(I=1) then
data<="1100";
elsif(I=2) then
data<="1110";
else
data<="0000";
end if;
when 2 =>
if(I=-1)then
data<="0101";
elsif(I=-2) then
data<="0111";
elsif(I=1) then
data<="1101";
elsif(I=2) then
data<="1111";
else
data<="0000";
end if;
when others => data<="0000";
end case;
end if;
end process;
symbol<=data;
end Behavioral;