|
由于要换芯片atmel 的,必须用MAX+plus II,
可是现在编译不能通过 急
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity count25 is
port(
Ain:in std_logic;
Bin:in std_logic;
Zin:in std_logic;
Aout:buffer std_logic;
Bout:buffer std_logic;
Zout:buffer std_logic
);
end count25;
architecture encoder_arc of count25 is
signal count11,count12:std_logic_vector(3 downto 0);
signal clk11,clk12,clk1:std_logic;
signal pclk1:std_logic;
signal ba:std_logic;
signal ck:std_logic;
signal Counter:std_logic:='0';
signal Zin_last:std_logic:='0';
signal Zin_lastA:std_logic:='0';
signal Zin_flag:std_logic:='0';
signal C:std_logic;
begin
ck<=Ain xor Bin;
clk1<=clk11 or clk12;
process(Ain)
begin
if(Ain'event and Ain='0') then
if(Bin='0') then
ba<='1';
else
ba<='0';
end if;
end if;
end process;
process(Bout,Aout,ba)
begin
-- if(ba='0') then
C<=Bout;
-- elsif(ba='1') then
-- C<=Aout;
-- end if;
end process;
process(ck,count11,Zin)
begin
if(ck'event and ck='1' and ck'last_value='0') then
if(Zin_lastA='0' and Zin='0') then
Count11<="0000";
Zin_lastA<=not Zin;
else
if(count11="0100")then
count11<="0000";
else
count11<=count11+1;
end if;
Zin_lastA<=not Zin;
end if;
end if;
end process;
process(ck)
begin
if(ck'event and ck='0') then
count12<=count11;
end if;
end process;
process(count11,count12)
begin
if(count11>="0010")then
clk11<='0';
else
clk11<='1';
end if;
if(count12>="0010")then
clk12<='0';
else
clk12<='1';
end if;
end process;
process(count11,count12)
begin
if(count11="0001" ) then
pclk1<=Ain xnor Bin;
elsif(count11="0100") then
pclk1<=Ain xor Bin;
else pclk1<='0';
end if;
end process;
process(ba,clk11,clk12,clk1,pclk1,Aout,Bout)
begin
if(ba='0') then
Aout<=clk1;
if(pclk1'event and pclk1='1' and pclk1'last_value='0') then
if(clk1='0') then
Bout<='0';
else
Bout<='1';
end if;
end if;
elsif(ba='1') then
Bout<=clk1;
if(pclk1'event and pclk1='1' and pclk1'last_value='0') then
if(clk1='0') then
Aout<='0';
else
Aout<='1';
end if;
end if;
end if;
end process;
process(Zin,C)
begin
if(C'event and C='0' and C'last_value='1') then
if((Zin_last XNOR Zin)='1') then
Zin_last<=(not Zin);
if(Zin='0') then
Counter<='1';
else
Counter<='0';
end if;
else
Counter<='0';
end if;
end if;
end process;
process(Counter, Aout)
begin
if(Counter='1') then
Zout<=Counter and Aout; --'0'
else
Zout<='1';
end if;
end process;
end encoder_arc; |
阿莫论坛20周年了!感谢大家的支持与爱护!!
一只鸟敢站在脆弱的枝条上歇脚,它依仗的不是枝条不会断,而是自己有翅膀,会飞。
|