📄 frequent.vhd
字号:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity frequent is
port(xclk,clk,clk1:in std_logic;
data:out std_logic_vector(7 downto 0);
choice:out std_logic_vector(5 downto 0));
end;
architecture arth of frequent is
signal en,clr,m0,m1,m2,m3,m4,m5:std_logic;
signal couta:std_logic_vector(3 downto 0);
signal cout0:std_logic_vector(3 downto 0);
signal cout1:std_logic_vector(3 downto 0);
signal cout2:std_logic_vector(3 downto 0);
signal cout3:std_logic_vector(3 downto 0);
signal cout4:std_logic_vector(3 downto 0);
signal cout5:std_logic_vector(3 downto 0);
signal cout6:std_logic_vector(3 downto 0);
signal count0:std_logic_vector(3 downto 0);
signal count1:std_logic_vector(3 downto 0);
signal count2:std_logic_vector(3 downto 0);
signal count3:std_logic_vector(3 downto 0);
signal count4:std_logic_vector(3 downto 0);
signal count5:std_logic_vector(3 downto 0);
signal count6:std_logic_vector(3 downto 0);
SIGNAL count : STD_LOGIC_VECTOR(2 downto 0);
SIGNAL temp : STD_LOGIC_VECTOR(3 downto 0);
--SIGNAL datain : STD_LOGIC_VECTOR(7 downto 0);
--SIGNAL choicein:std_logic_vector(5 downto 0);
begin
p1:process(xclk,en,clr)
begin
if(clr='0') then
cout0<="0000";m0<='0';
elsif((en='1')and rising_edge (xclk)) then
if(cout0="1001") then
cout0<="0000";m0<='0';
else
cout0<=cout0+'1';m0<='1';
end if;
end if;
end process p1;
p2:process(clr,en,m0)
begin
if(clr='0') then
cout1<="0000";m1<='0';
elsif((en='1') and falling_edge (m0)) then
if(cout1="1001") then
cout1<="0000";m1<='0';
else
cout1<=cout1+'1';m1<='1';
end if;
end if;
end process p2;
p3:process(clr,en,m1)
begin
if(clr='0') then
cout2<="0000";m2<='0';
elsif((en='1') and falling_edge (m1)) then
if(cout2="1001") then
cout2<="0000";m2<='0';
else
cout2<=cout2+'1';m2<='1';
end if;
end if;
end process p3;
p4:process(clr,en,m2)
begin
if(clr='0') then
cout3<="0000";m3<='0';
elsif((en='1') and falling_edge (m2)) then
if(cout3="1001") then
cout3<="0000";m3<='0';
else
cout3<=cout3+'1';m3<='1';
end if;
end if;
end process p4;
p5:process(clr,en,m3)
begin
if(clr='0') then
cout4<="0000";m4<='0';
elsif((en='1') and falling_edge (m3)) then
if(cout4="1001") then
cout4<="0000";m4<='0';
else
cout4<=cout4+'1';m4<='1';
end if;
end if;
end process p5;
p6:process(clr,en,m4)
begin
if(clr='0') then
cout5<="0000";m5<='0';
elsif((en='1') and falling_edge (m4)) then
if(cout5="1001") then
cout5<="0000";m5<='0';
else
cout5<=cout5+'1';m5<='1';
end if;
end if;
end process p6;
p60:process(clr,en,m5)
begin
if(clr='0')then
cout6<="0000";
elsif(en='1' and falling_edge(m5))then
if(cout6="1001")then
cout6<="0000";
else
cout6<=cout6+'1';
end if;
end if;
end process p60;
p7:process(clk1)
begin
if rising_edge(clk1) then
couta<=couta+'1';
else
couta<=couta;
end if;
if (couta="0111") then
clr<='0';
else
clr<='1';
end if;
if (couta>"0111") then
en<='1';
else
en<='0';
end if;
end process p7;
p8:process(en,clr,clk)
begin
if((en='0') and (clr='1') and rising_edge(clk)) then
count0<=cout0;
count1<=cout1;
count2<=cout2;
count3<=cout3;
count4<=cout4;
count5<=cout5;
count6<=cout6;
end if;
end process p8;
PROCESS (clk)
BEGIN
IF rising_edge(clk) THEN
if(count<"101") then
count<=count+1;
else
count<="000";
end if;
END IF;
END PROCESS;
process(count6,count,clk)
begin
if(rising_edge(clk))then
if(count6="0000")then
if(count="000")then
temp<=count0;
elsif(count="001")then
temp<=count1;
elsif(count="010")then
temp<=count2;
elsif(count="011")then
temp<=count3;
elsif(count="100")then
temp<=count4;
elsif(count="101")then
temp<=count5;
end if;
elsif(count6>="0001")then
if(count="000")then
temp<=count2;
elsif(count="001")then
temp<=count3;
elsif(count="010")then
temp<=count4;
elsif(count="011")then
temp<=count5;
elsif(count="100")then
temp<="1010";
elsif(count="101")then
temp<=count6;
end if;
end if;
end if;
end process;
choice<="011111" when count="000" else
"111110" when count="001" else
"111101" when count="010" else
"111011" when count="011" else
"110111" when count="100" else
"101111" when count="101" ;
WITH temp select
data <= "11111100" WHEN "0000",
"01100000" WHEN "0001",
"11011010" WHEN "0010",
"11110010" WHEN "0011",
"01100110" WHEN "0100",
"10110110" WHEN "0101",
"10111110" WHEN "0110",
"11100000" WHEN "0111",
"11111110" WHEN "1000",
"11110110" WHEN "1001",
"00000001" WHEN "1010";
end arth;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -