代码如下:(太简单了)
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity XC2S151 is
Port (
CLK:IN STD_LOGIC;
LOAD :IN STD_LOGIC;
PLUSEX: OUT STD_LOGIC
);
end XC2S151;
architecture Behavioral of XC2S151 is
SIGNAL BUFY2,SAVE3:STD_LOGIC_VECTOR (15 DOWNTO 0);--
SIGNAL XAXA3,CLK1,RST,RST1,RST2:STD_LOGIC;
SIGNAL QN:STD_LOGIC_VECTOR (3 DOWNTO 0);--
begin
PROCESS(CLK,RST) --CLK 1M
BEGIN
IF RST='1'THEN
QN<="0000";
ELSIF CLK' EVENT AND CLK='1' THEN
QN<=QN+1;
END IF;
END PROCESS;
RST<='1' WHEN QN=10 ELSE
'0';
CLK1<=QN(2);
PLUSEX<=XAXA3;
PROCESS(CLK1,LOAD) --CLK1 100K LOAD外部随机信号
BEGIN
IF SAVE3="0000000000000000" THEN
IF LOAD='1' THEN
SAVE3<="0000000000001100
END IF;
ELSIF CLK1' EVENT AND CLK1='1' THEN
IF SAVE3/="0000000000000000" THEN
CASE SAVE3 IS
WHEN "0000000000001100"=>
SAVE3<="0000000000000100";
WHEN "0000000000000100"=>
SAVE3<="0000000000000101";
WHEN "0000000000000101"=>
SAVE3<="0000000000000111";
WHEN "0000000000000111"=>
SAVE3<="0000000000000110";
WHEN "0000000000000110"=>
SAVE3<="0000000000000010";
WHEN "0000000000000010"=>
SAVE3<="0000000000000011";
WHEN "0000000000000011"=>
SAVE3<="0000000000000001";
WHEN "0000000000000001"=>
SAVE3<="0000000000000000";
WHEN OTHERS=>
SAVE3<="0000000000000000";
END CASE;
XAXA3<=NOT XAXA3;
END IF;
END IF;
END PROCESS;
end Behavioral;
|