⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 trace_file.vhd

📁 EAS 的接收程序接收来自发射板的RF信号
💻 VHD
字号:
library IEEE; 
use IEEE.STD_LOGIC_1164.ALL; 
use IEEE.STD_LOGIC_ARITH.ALL; 
use IEEE.STD_LOGIC_UNSIGNED.ALL; 
entity trace_file is 
 Port (flat:in std_logic;
       clk:in std_logic;
       control:in std_logic;
       timer_begin:in std_logic_vector(2 downto 0);
       timer :in std_logic;
       trace :in bit;
       green1:out std_logic;
       green2:out std_logic;
       green3:out std_logic;
       alarm:buffer std_logic
     );
end trace_file;
architecture behavioral of trace_file is
signal a :std_logic_vector(5 downto 0);
signal e :std_logic_vector(5 downto 0);
signal f :std_logic_vector(5 downto 0);

signal a_b :std_logic_vector(2 downto 0);
signal a_b1 :std_logic_vector(2 downto 0);
signal a_b2 :std_logic_vector(2 downto 0);


constant c5:std_logic_vector(5 downto 0):="010100";   ---Define scanning NO.20
constant c10:std_logic_vector(5 downto 0):="101000";---Define scanning NO.40
constant c20:std_logic_vector(5 downto 0):="110010";---Define scanning NO.50


signal green3_1:std_logic:='0';
signal green3_2:std_logic:='0';
signal green3_3:std_logic:='0';

signal count1 :std_logic_vector(5 downto 0):="000000";
signal count2 :std_logic_vector(5 downto 0):="000000";
signal count3 :std_logic_vector(5 downto 0):="000000";

signal count :std_logic_vector(15 downto 0):="0000000000000000";


begin
process(clk)--,judge2,judge3


begin
-------------------------------------------sgnal arithmetic
if clk'event and clk='1' then

if flat='1' then

if trace='0' then

case timer_begin is
when "001" =>
count1<=count1+1;
when "010" =>
count2<=count2+1;
when "100" =>
count3<=count3+1;
when others => NULL;
end case;
--if timer_begin="001" then
--count1<=count1+1;
--elsif timer_begin="001" then
--count2<=count2+1;
--elsif timer_begin="001" then
--count3<=count3+1;
--end if;

else
--if end_timer='1'then
a<=count1;
count1<="000000";
e<=count2;
count2<="000000";
f<=count3;
count3<="000000";
--end if;
end if;
end if;
end if;


end process;



---------------------------------------------------------comparisoner
process(a,e,f)   
variable a_dy_b1 :std_logic;
variable a_dy_c1 :std_logic;
variable a_dy_d1 :std_logic;

variable a_dy_b2 :std_logic;
variable a_dy_c2 :std_logic;
variable a_dy_d2 :std_logic;

variable a_dy_b:std_logic;--:='0';
variable a_dy_c:std_logic;--:='0';
variable a_dy_d:std_logic;--:='0';

variable b :std_logic_vector(5 downto 0);
variable c :std_logic_vector(5 downto 0);
variable d :std_logic_vector(5 downto 0);

begin
b:=c5;
c:=c10;
d:=c20;
if a>b then
a_dy_b:='1';
else
a_dy_b:= '0';
end if;
if a>c then
a_dy_c:='1';
else
a_dy_c:= '0';
end if;
if a>d then 
a_dy_d:='1'; 
else
a_dy_d:='0';
end if;
a_b<=a_dy_b & a_dy_c & a_dy_d;


if e>b then
a_dy_b1:='1';
else
a_dy_b1:= '0';
end if;
if e>c then
a_dy_c1:='1';
else
a_dy_c1:= '0';
end if;
if e>d then 
a_dy_d1:='1'; 
else
a_dy_d1:='0';
end if;
a_b1<=a_dy_b1 & a_dy_c1 & a_dy_d1;


if f>b then
a_dy_b2:='1';
else
a_dy_b2:= '0';
end if;
if f>c then
a_dy_c2:='1';
else
a_dy_c2:= '0';
end if;
if f>d then 
a_dy_d2:='1'; 
else
a_dy_d2:='0';
end if;
a_b2<=a_dy_b2 & a_dy_c2 & a_dy_d2;
end process;



process(a_b,a_b1,a_b2)
begin

if a_b="100" then      --5
green1<='1';
green2<='0';
green3_1<='0';
elsif a_b="110" then   --10
green1<='1';
green2<='1';
green3_1<='0';
elsif a_b="111"  then  --20
green1<='1';
green2<='1';
green3_1<='1';
else 
--NULL;
green1<='0';
green2<='0';
green3<='0';
end if;

if a_b1="100" then      --5
green1<='1';
green2<='0';
green3_2<='0';
elsif a_b1="110" then   --10
green1<='1';
green2<='1';
green3_2<='0';
elsif a_b1="111"  then  --20
green1<='1';
green2<='1';
green3_2<='1';
else 
--NULL;
green1<='0';
green2<='0';
green3<='0';
end if;


if a_b2="100" then      --5
green1<='1';
green3<='0';
green2<='0';
green3_3<='0';
elsif a_b2="110" then   --10
green1<='1';
green2<='1';
green3<='0';
green3_3<='0';
elsif a_b2="111"  then  --20
green1<='1';
green2<='1';
green3<='1';
green3_3<='1';
else 
--NULL;
green1<='0';
green2<='0';
green3<='0';
end if;
end process;





------------------------------------------------------alarm delay
process(timer)
begin
if timer'event and timer='1' then
if (green3_1='1'and green3_2='1' and green3_3='1') then
if control='1' then
alarm<='1';
--green3<='0';
--else
--green3<='0';
end if;
end if;

if alarm='1' then
if count="111010100110000" then  --3s
alarm<='0';
count<="0000000000000000";
else
count<=count+1;
end if;
end if;
end if;
end process;
--process(green3_1,green3_2,green3_1)

--begin

--------------------------------------------------------touch off alarm
--if (green3_1='1'and green3_2='1' and green3_3='1') then
--alarm<='1';
--green3<='1';
--else
--green3<='0';
--end if;
--end process;


end behavioral;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -