📄 code.vhd
字号:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity code is
port( reset, clk_send, osc, ready_en: in std_logic;
key_in: in std_logic_vector(12 downto 1);
tx: out std_logic
);
end code;
architecture send of code is
signal temp : std_logic_vector(35 downto 1);
signal C : std_logic_vector( 5 downto 0);
signal d : std_logic_vector(15 downto 0);
signal y: std_logic;
begin
tx<=y;
y <= temp(35) and osc ;
aa: process(d, ready_en, clk_send,osc,y,c,temp,reset)
begin
if reset='1' then
temp<="00000000000000000000000000000000000";
else
if ready_en='1' then --- data input
temp(35 downto 24)<="010101110010"; ---fram head input
temp(23 downto 8)<=d; ----data input
temp(7 downto 2)<=c; ---hammming code input
--temp(2 downto 1)<="00";
else
if clk_send'event and clk_send='1' then
tx_loop: for k in 35 downto 2 loop
temp(k)<=temp(k-1);
end loop tx_loop;
temp(1) <='0';
end if;
end if;
end if;
end process aa;
bb: process(key_in,d,ready_en,clk_send,reset) --- keyboard code
begin
if reset='1' then
d<="0000000000000000";
else
if ready_en='1' then
if clk_send'event and clk_send='0'then
case key_in is
when "111111111110" => d<="0011110000111100"; -- 1 power on and off
when "111111111101" => d<="0001110001110001"; -- 2 mute on and off
when "111111111011" => d<="0000111000011100"; -- 3 standby on and off
when "111111110111" => d<="0011001100110011"; -- 4 Hi up
when "111111101111" => d<="1100110011001100"; -- 5 Hi down
when "111111011111" => d<="1110001110001110"; -- 6 Lo up
when "111110111111" => d<="1111000111100011"; -- 7 Lo down
when "111101111111" => d<="1101101101101101"; -- 8 Vol up
when "111011111111" => d<="0101010101010101"; -- 9 Vol down
when "110111111111" => d<="1001001001001001"; -- 10 Time display
when "101111111111" => d<="0111001100111001"; -- 11 Sleep on and off
when "011111111111" => d<="1010101010101010"; -- 12 resaved
when others => d<="0000000000000000";
end case;
end if;
end if;
end if;
end process bb;
cc: process(d,c,key_in,ready_en,reset,clk_send) -- hamming code
begin
if reset='1' then
c<="000000";
else
if ready_en='1' then
if clk_send'event and clk_send='0'then
c(5)<=d(8) xor d(9) xor d(10) xor d(11) xor d(12) xor d(13) xor d(14) xor d(15);
c(4)<=d(3) xor d(4) xor d(5) xor d(6) xor d(7) xor d(13) xor d(14) xor d(15);
c(3)<=d(0) xor d(1) xor d(2) xor d(6) xor d(7) xor d(10) xor d(11) xor d(12);
c(2)<=d(1) xor d(2) xor d(4) xor d(5) xor d(7) xor d(9) xor d(12) xor d(15);
c(1)<=d(0) xor d(2) xor d(3) xor d(5) xor d(6) xor d(8) xor d(11) xor d(14);
c(0)<=d(0) xor d(1) xor d(3) xor d(4) xor d(8) xor d(9) xor d(10) xor d(13);
end if;
end if;
end if;
end process cc;
end send;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -