|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
process(uart_clk,rst,rxds) -- --主控时序、组合进程 ----数据接收
variable ff2: integer range 0 to 8;--
begin
if rst='0' then
r_state<=r_start;finish<='0';--判断复位状态
elsif uart_clk'event and uart_clk='1' then --上升沿有效
case r_state is
when r_start=>--等待起始位
if rxds='0' then
r_state<=r_shift; ff2:=0;
else
r_state<=r_start; ff2:=0; start<='0';
end if;
when r_shift=>
case temp_state is
when 0=>
test0(ff2)<=rxds;
ff2:=ff2+1;
start<='0';
if ff2=ff then
ff2:=0;
r_state<=r_start;
if special_temp1="10101010" and test0="01010101" then
temp_state<=2;
else
temp_state<=1;
end if;
end if;
when 1=>
test1(ff2)<=rxds;
ff2:=ff2+1;
if ff2=ff then
ff2:=0;
r_state<=r_start;
temp_state<=2;
end if;
when 2=>
mode(ff2)<=rxds;
ff2:=ff2+1;
if ff2=ff then
ff2:=0;
r_state<=r_start;
if test1="10101010" and mode="01010101" then
temp_state<=2;
else
temp_state<=3;
end if;
end if;
when 3=>
freq_temp0(ff2)<=rxds;
ff2:=ff2+1;
if ff2=ff then
ff2:=0;
r_state<=r_start;
if mode="10101010" and freq_temp0="01010101" then
temp_state<=2;
else
temp_state<=4;
end if;
end if;
when 4=>
freq_temp1(ff2)<=rxds;
ff2:=ff2+1;
if ff2=ff then
ff2:=0;
r_state<=r_start;
if freq_temp0>"00001100" then
temp_state<=5;
sw<='0';
else
temp_state<=5;
sw<='1';
end if;
end if;
when 5=>
freq_temp2(ff2)<=rxds;
ff2:=ff2+1;
if ff2=ff then
ff2:=0;
r_state<=r_start;
temp_state<=6;
end if;
when 6=>
freq_temp3(ff2)<=rxds;
ff2:=ff2+1;
if ff2=ff then
ff2:=0;
r_state<=r_start;
temp_state<=7;
end if;
when 7=>
freq_temp4(ff2)<=rxds;
ff2:=ff2+1;
if ff2=ff then
ff2:=0;
r_state<=r_start;
temp_state<=8;
end if;
when 8=>
freq_temp5(ff2)<=rxds;
ff2:=ff2+1;
if ff2=ff then
ff2:=0;
r_state<=r_start;
temp_state<=9;
end if;
when 9=>
att_temp(ff2)<=rxds;
ff2:=ff2+1;
if ff2=ff then
ff2:=0;
r_state<=r_start;
temp_state<=10;
end if;
when 10=>
special_temp0(ff2)<=rxds;
ff2:=ff2+1;
if ff2=ff then
ff2:=0;
r_state<=r_start;
if att_temp="10101010" and special_temp0="01010101" then
temp_state<=2;
else
temp_state<=11;
end if;
end if;
when 11=>
special_temp1(ff2)<=rxds;
ff2:=ff2+1;
if ff2=ff then
ff2:=0;
r_state<=r_start;
if special_temp0="10101010" and special_temp1="01010101" then
temp_state<=2;
else
temp_state<=0;
start<='1';
end if;
end if;
end case;
when others=> r_state<=r_start;
end case;
end if;
end process; |
|