?? ask_modulation.vhd
字號(hào):
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity ask_modulation is
port(clk : in std_logic;
mod_sel: in std_logic_vector (1 downto 0);
I : in std_logic;--signal
P : in std_logic_vector(13 downto 0);--carrier input
Q : out std_logic_vector(13 downto 0));--output after mod
end ask_modulation;
architecture behave of ask_modulation is
--signal K : std_logic_vector(13 downto 0);--carrier input
--variable K : std_logic_vector(13 downto 0);--carrier input
begin
process(clk)
begin
if clk'event and clk='1' then
if (mod_sel(1)='1') then
if (I='1') then
Q<=P;
--DSB-ASK or SSB-ASK
elsif (P(13)='0') then--modulation depth=87.5%
Q(13)<=P(13);
Q(11)<='0';
Q(10)<='0';
Q(9)<=P(12);
Q(8)<=P(11);
Q(7)<=P(10);
Q(6)<=P(9);
Q(5)<=P(8);
Q(4)<=P(7);
Q(3)<=P(6);
Q(2)<=P(5);
Q(1)<=P(4);
Q(0)<=P(3);
else
Q(13)<=P(13);
Q(12)<='1';
Q(11)<='1';
Q(10)<='1';
Q(9)<=P(12);
Q(8)<=P(11);
Q(7)<=P(10);
Q(6)<=P(9);
Q(5)<=P(8);
Q(4)<=P(7);
Q(3)<=P(6);
Q(2)<=P(5);
Q(1)<=P(4);
Q(0)<=P(3);
end if;
--PR-ASK
elsif (mod_sel(1)='0' and mod_sel(0)='1') then--pr-ask modulation mode selected
if (I='0') then
Q(13 downto 0)<=P(13 downto 0);--data '0'
else --data '1' oppsite
--not tested if(P(13)='0') then
-- K(13 downto 0)<=not(P(13 downto 0));
-- else
-- if P(0)='1' then K(0)<='0'; K(13 downto 1)<=P(13 downto 1);
-- elsif P(1)='1' then K(1)<='0'; K(0)<='1'; K(13 downto 2)<=P(13 downto 2);
-- elsif P(2)='1' then K(2)<='0'; K(1 downto 0)<=(others=>'1'); K(13 downto 3)<=P(13 downto 3);
-- elsif P(3)='1' then K(3)<='0'; K(2 downto 0)<=(others=>'1'); K(13 downto 4)<=P(13 downto 4);
-- elsif P(4)='1' then K(4)<='0'; K(3 downto 0)<=(others=>'1'); K(13 downto 5)<=P(13 downto 5);
-- elsif P(5)='1' then K(5)<='0'; K(4 downto 0)<=(others=>'1'); K(13 downto 6)<=P(13 downto 6);
-- elsif P(6)='1' then K(6)<='0'; K(5 downto 0)<=(others=>'1'); K(13 downto 7)<=P(13 downto 7);
-- elsif P(7)='1' then K(7)<='0'; K(6 downto 0)<=(others=>'1'); K(13 downto 8)<=P(13 downto 8);
-- elsif P(8)='1' then K(8)<='0'; K(7 downto 0)<=(others=>'1'); K(13 downto 9)<=P(13 downto 9);
-- elsif P(9)='1' then K(9)<='0'; K(8 downto 0)<=(others=>'1'); K(13 downto 10)<=P(13 downto 10);
-- elsif P(10)='1' then K(10)<='0'; K(9 downto 0)<=(others=>'1'); K(13 downto 11)<=P(13 downto 11);
-- elsif P(11)='1' then K(11)<='0'; K(10 downto 0)<=(others=>'1'); K(13 downto 12)<=P(13 downto 12);
-- elsif P(12)='1' then K(12)<='0'; K(11 downto 0)<=(others=>'1'); K(13)<=P(13);
-- else K(13)<='0'; K(12 downto 0)<=(others=>'1');
-- end if;
-- end if;
--
-- if(P(13)='0') then
-- if K(0)='0' then Q(0)<='1'; Q(13 downto 1)<=K(13 downto 1);
-- elsif K(1)='0' then Q(1)<='1'; Q(13 downto 2)<=K(13 downto 2); Q(0)<='0';
-- elsif K(2)='0' then Q(2)<='1'; Q(13 downto 3)<=K(13 downto 3); Q(1 downto 0)<=(others=>'0');
-- elsif K(3)='0' then Q(3)<='1'; Q(13 downto 4)<=K(13 downto 4); Q(2 downto 0)<=(others=>'0');
-- elsif K(4)='0' then Q(4)<='1'; Q(13 downto 5)<=K(13 downto 5); Q(3 downto 0)<=(others=>'0');
-- elsif K(5)='0' then Q(5)<='1'; Q(13 downto 6)<=K(13 downto 6); Q(4 downto 0)<=(others=>'0');
-- elsif K(6)='0' then Q(6)<='1'; Q(13 downto 7)<=K(13 downto 7); Q(5 downto 0)<=(others=>'0');
-- elsif K(7)='0' then Q(7)<='1'; Q(13 downto 8)<=K(13 downto 8); Q(6 downto 0)<=(others=>'0');
-- elsif K(8)='0' then Q(8)<='1'; Q(13 downto 9)<=K(13 downto 9); Q(7 downto 0)<=(others=>'0');
-- elsif K(9)='0' then Q(9)<='1'; Q(13 downto 10)<=K(13 downto 10); Q(8 downto 0)<=(others=>'0');
-- elsif K(10)='0' then Q(10)<='1'; Q(13 downto 11)<=K(13 downto 11); Q(9 downto 0)<=(others=>'0');
-- elsif K(11)='0' then Q(11)<='1'; Q(13 downto 12)<=K(13 downto 12); Q(10 downto 0)<=(others=>'0');
-- elsif K(12)='0' then Q(12)<='1'; Q(13)<='1'; Q(11 downto 0)<=(others=>'0');
-- else Q(13 downto 0)<=(others=>'0');
-- end if;
-- else
-- Q(13 downto 0)<=not(K(13 downto 0));
-- end if;
--double clk if(P(13)='0') then
-- K(13 downto 0)<=not(P(13 downto 0));
-- if K(0)='0' then Q(0)<='1'; Q(13 downto 1)<=K(13 downto 1);
-- elsif K(1)='0' then Q(1)<='1'; Q(13 downto 2)<=K(13 downto 2); Q(0)<='0';
-- elsif K(2)='0' then Q(2)<='1'; Q(13 downto 3)<=K(13 downto 3); Q(1 downto 0)<=(others=>'0');
-- elsif K(3)='0' then Q(3)<='1'; Q(13 downto 4)<=K(13 downto 4); Q(2 downto 0)<=(others=>'0');
-- elsif K(4)='0' then Q(4)<='1'; Q(13 downto 5)<=K(13 downto 5); Q(3 downto 0)<=(others=>'0');
-- elsif K(5)='0' then Q(5)<='1'; Q(13 downto 6)<=K(13 downto 6); Q(4 downto 0)<=(others=>'0');
-- elsif K(6)='0' then Q(6)<='1'; Q(13 downto 7)<=K(13 downto 7); Q(5 downto 0)<=(others=>'0');
-- elsif K(7)='0' then Q(7)<='1'; Q(13 downto 8)<=K(13 downto 8); Q(6 downto 0)<=(others=>'0');
-- elsif K(8)='0' then Q(8)<='1'; Q(13 downto 9)<=K(13 downto 9); Q(7 downto 0)<=(others=>'0');
-- elsif K(9)='0' then Q(9)<='1'; Q(13 downto 10)<=K(13 downto 10); Q(8 downto 0)<=(others=>'0');
-- elsif K(10)='0' then Q(10)<='1'; Q(13 downto 11)<=K(13 downto 11); Q(9 downto 0)<=(others=>'0');
-- elsif K(11)='0' then Q(11)<='1'; Q(13 downto 12)<=K(13 downto 12); Q(10 downto 0)<=(others=>'0');
-- elsif K(12)='0' then Q(12)<='1'; Q(13)<='1'; Q(11 downto 0)<=(others=>'0');
-- else Q(13 downto 0)<=(others=>'0');
-- end if;
-- else
-- if P(0)='1' then K(0)<='0'; K(13 downto 1)<=P(13 downto 1);
-- elsif P(1)='1' then K(1)<='0'; K(0)<='1'; K(13 downto 2)<=P(13 downto 2);
-- elsif P(2)='1' then K(2)<='0'; K(1 downto 0)<=(others=>'1'); K(13 downto 3)<=P(13 downto 3);
-- elsif P(3)='1' then K(3)<='0'; K(2 downto 0)<=(others=>'1'); K(13 downto 4)<=P(13 downto 4);
-- elsif P(4)='1' then K(4)<='0'; K(3 downto 0)<=(others=>'1'); K(13 downto 5)<=P(13 downto 5);
-- elsif P(5)='1' then K(5)<='0'; K(4 downto 0)<=(others=>'1'); K(13 downto 6)<=P(13 downto 6);
-- elsif P(6)='1' then K(6)<='0'; K(5 downto 0)<=(others=>'1'); K(13 downto 7)<=P(13 downto 7);
-- elsif P(7)='1' then K(7)<='0'; K(6 downto 0)<=(others=>'1'); K(13 downto 8)<=P(13 downto 8);
-- elsif P(8)='1' then K(8)<='0'; K(7 downto 0)<=(others=>'1'); K(13 downto 9)<=P(13 downto 9);
-- elsif P(9)='1' then K(9)<='0'; K(8 downto 0)<=(others=>'1'); K(13 downto 10)<=P(13 downto 10);
-- elsif P(10)='1' then K(10)<='0'; K(9 downto 0)<=(others=>'1'); K(13 downto 11)<=P(13 downto 11);
-- elsif P(11)='1' then K(11)<='0'; K(10 downto 0)<=(others=>'1'); K(13 downto 12)<=P(13 downto 12);
-- elsif P(12)='1' then K(12)<='0'; K(11 downto 0)<=(others=>'1'); K(13)<=P(13);
-- else K(13)<='0'; K(12 downto 0)<=(others=>'1');
-- end if;
-- Q(13 downto 0)<=not(K(13 downto 0));
-- end if;
--variable usage if(P(13)='0') then
-- K(13 downto 0):=not(P(13 downto 0));
-- if K(0)='0' then Q(0)<='1'; Q(13 downto 1)<=K(13 downto 1);
-- elsif K(1)='0' then Q(1)<='1'; Q(13 downto 2)<=K(13 downto 2); Q(0)<='0';
-- elsif K(2)='0' then Q(2)<='1'; Q(13 downto 3)<=K(13 downto 3); Q(1 downto 0)<=(others=>'0');
-- elsif K(3)='0' then Q(3)<='1'; Q(13 downto 4)<=K(13 downto 4); Q(2 downto 0)<=(others=>'0');
-- elsif K(4)='0' then Q(4)<='1'; Q(13 downto 5)<=K(13 downto 5); Q(3 downto 0)<=(others=>'0');
-- elsif K(5)='0' then Q(5)<='1'; Q(13 downto 6)<=K(13 downto 6); Q(4 downto 0)<=(others=>'0');
-- elsif K(6)='0' then Q(6)<='1'; Q(13 downto 7)<=K(13 downto 7); Q(5 downto 0)<=(others=>'0');
-- elsif K(7)='0' then Q(7)<='1'; Q(13 downto 8)<=K(13 downto 8); Q(6 downto 0)<=(others=>'0');
-- elsif K(8)='0' then Q(8)<='1'; Q(13 downto 9)<=K(13 downto 9); Q(7 downto 0)<=(others=>'0');
-- elsif K(9)='0' then Q(9)<='1'; Q(13 downto 10)<=K(13 downto 10); Q(8 downto 0)<=(others=>'0');
-- elsif K(10)='0' then Q(10)<='1'; Q(13 downto 11)<=K(13 downto 11); Q(9 downto 0)<=(others=>'0');
-- elsif K(11)='0' then Q(11)<='1'; Q(13 downto 12)<=K(13 downto 12); Q(10 downto 0)<=(others=>'0');
-- elsif K(12)='0' then Q(12)<='1'; Q(13)<='1'; Q(11 downto 0)<=(others=>'0');
-- else Q(13 downto 0)<=(others=>'0');
-- end if;
-- else
-- if P(0)='1' then K(0):='0'; K(13 downto 1):=P(13 downto 1);
-- elsif P(1)='1' then K(1):='0'; K(0):='1'; K(13 downto 2):=P(13 downto 2);
-- elsif P(2)='1' then K(2):='0'; K(1 downto 0):=(others=>'1'); K(13 downto 3):=P(13 downto 3);
-- elsif P(3)='1' then K(3):='0'; K(2 downto 0):=(others=>'1'); K(13 downto 4):=P(13 downto 4);
-- elsif P(4)='1' then K(4):='0'; K(3 downto 0):=(others=>'1'); K(13 downto 5):=P(13 downto 5);
-- elsif P(6)='1' then K(6):='0'; K(5 downto 0):=(others=>'1'); K(13 downto 7):=P(13 downto 7);
-- elsif P(7)='1' then K(7):='0'; K(6 downto 0):=(others=>'1'); K(13 downto 8):=P(13 downto 8);
-- elsif P(8)='1' then K(8):='0'; K(7 downto 0):=(others=>'1'); K(13 downto 9):=P(13 downto 9);
-- elsif P(9)='1' then K(9):='0'; K(8 downto 0):=(others=>'1'); K(13 downto 10):=P(13 downto 10);
-- elsif P(10)='1' then K(10):='0'; K(9 downto 0):=(others=>'1'); K(13 downto 11):=P(13 downto 11);
-- elsif P(11)='1' then K(11):='0'; K(10 downto 0):=(others=>'1'); K(13 downto 12):=P(13 downto 12);
-- elsif P(12)='1' then K(12):='0'; K(11 downto 0):=(others=>'1'); K(13):=P(13);
-- else K(13):='0'; K(12 downto 0):=(others=>'1');
-- end if;
-- Q(13 downto 0)<=not(K(13 downto 0));
-- end if;
-- if(P(13)='0') then
-- K(13 downto 0)<=not(P(13 downto 0));
if P(0)='1' then Q(0)<='1'; Q(13 downto 1)<=NOT P(13 downto 1);
elsif P(1)='1' then Q(1)<='1'; Q(13 downto 2)<=NOT P(13 downto 2); Q(0)<='0';
elsif P(2)='1' then Q(2)<='1'; Q(13 downto 3)<=NOT P(13 downto 3); Q(1 downto 0)<=(others=>'0');
elsif P(3)='1' then Q(3)<='1'; Q(13 downto 4)<=NOT P(13 downto 4); Q(2 downto 0)<=(others=>'0');
elsif P(4)='1' then Q(4)<='1'; Q(13 downto 5)<=NOT P(13 downto 5); Q(3 downto 0)<=(others=>'0');
elsif P(5)='1' then Q(5)<='1'; Q(13 downto 6)<=NOT P(13 downto 6); Q(4 downto 0)<=(others=>'0');
elsif P(6)='1' then Q(6)<='1'; Q(13 downto 7)<=NOT P(13 downto 7); Q(5 downto 0)<=(others=>'0');
elsif P(7)='1' then Q(7)<='1'; Q(13 downto 8)<=NOT P(13 downto 8); Q(6 downto 0)<=(others=>'0');
elsif P(8)='1' then Q(8)<='1'; Q(13 downto 9)<=NOT P(13 downto 9); Q(7 downto 0)<=(others=>'0');
elsif P(9)='1' then Q(9)<='1'; Q(13 downto 10)<=NOT P(13 downto 10); Q(8 downto 0)<=(others=>'0');
elsif P(10)='1' then Q(10)<='1'; Q(13 downto 11)<=NOT P(13 downto 11); Q(9 downto 0)<=(others=>'0');
elsif P(11)='1' then Q(11)<='1'; Q(13 downto 12)<=NOT P(13 downto 12); Q(10 downto 0)<=(others=>'0');
elsif P(12)='1' then Q(12)<='1'; Q(13)<=NOT P(13); Q(11 downto 0)<=(others=>'0');
else Q(13 downto 0)<=P(13 downto 0);
end if;
-- else
-- if P(0)='1' then Q(0)<='1'; Q(13 downto 1)<=NOT P(13 downto 1);
-- elsif P(1)='1' then Q(1)<='1'; Q(0)<='0'; Q(13 downto 2)<=NOT P(13 downto 2);
-- elsif P(2)='1' then Q(2)<='1'; Q(1 downto 0)<=(others=>'0'); Q(13 downto 3)<=NOT P(13 downto 3);
-- elsif P(3)='1' then Q(3)<='1'; Q(2 downto 0)<=(others=>'0'); Q(13 downto 4)<=NOT P(13 downto 4);
-- elsif P(4)='1' then Q(4)<='1'; Q(3 downto 0)<=(others=>'0'); Q(13 downto 5)<=NOT P(13 downto 5);
-- elsif P(5)='1' then Q(5)<='1'; Q(4 downto 0)<=(others=>'0'); Q(13 downto 6)<=NOT P(13 downto 6);
-- elsif P(6)='1' then Q(6)<='1'; Q(5 downto 0)<=(others=>'0'); Q(13 downto 7)<=NOT P(13 downto 7);
-- elsif P(7)='1' then Q(7)<='1'; Q(6 downto 0)<=(others=>'0'); Q(13 downto 8)<=NOT P(13 downto 8);
-- elsif P(8)='1' then Q(8)<='1'; Q(7 downto 0)<=(others=>'0'); Q(13 downto 9)<=NOT P(13 downto 9);
-- elsif P(9)='1' then Q(9)<='1'; Q(8 downto 0)<=(others=>'0'); Q(13 downto 10)<=NOT P(13 downto 10);
-- elsif P(10)='1' then Q(10)<='1'; Q(9 downto 0)<=(others=>'0'); Q(13 downto 11)<=NOT P(13 downto 11);
-- elsif P(11)='1' then Q(11)<='1'; Q(10 downto 0)<=(others=>'0'); Q(13 downto 12)<=NOT P(13 downto 12);
-- elsif P(12)='1' then Q(12)<='1'; Q(11 downto 0)<=(others=>'0'); Q(13)<=NOT P(13);
-- else Q(13)<='1'; K(12 downto 0)<=(others=>'0');
-- end if;
---- Q(13 downto 0)<=not(K(13 downto 0));
-- end if;
end if;
--CW
else
Q(13 downto 0)<=P(13 downto 0);
end if;
end if;
end process;
end behave;
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -