LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
ENTITY mywork IS
PORT(a,b,c,d,e,f,back,clk1,clk2,start:IN STD_LOGIC;
num,choose:OUT STD_LOGIC_VECTOR (7 DOWNTO 0)
);
END ENTITY mywork;
ARCHITECTURE start OF mywork IS
signal q:integer :=0;
signal fg : std_logic := '1';
signal kong:integer range 0 to 1;
signal huo:integer range 0 to 6;
SIGNAL chose:STD_LOGIC_VECTOR (7 DOWNTO 0);
SIGNAL h1:STD_LOGIC_VECTOR (7 DOWNTO 0);
SIGNAL h2:STD_LOGIC_VECTOR (7 DOWNTO 0);
SIGNAL h3:STD_LOGIC_VECTOR (7 DOWNTO 0);
SIGNAL h4:STD_LOGIC_VECTOR (7 DOWNTO 0);
SIGNAL h5:STD_LOGIC_VECTOR (7 DOWNTO 0);
SIGNAL h6:STD_LOGIC_VECTOR (7 DOWNTO 0);
SIGNAL t1:STD_LOGIC_VECTOR (7 DOWNTO 0);
SIGNAL t2:STD_LOGIC_VECTOR (7 DOWNTO 0);
SIGNAL d1:STD_LOGIC_VECTOR (7 DOWNTO 0);
SIGNAL d2:STD_LOGIC_VECTOR (7 DOWNTO 0);
SIGNAL d3:STD_LOGIC_VECTOR (7 DOWNTO 0);
SIGNAL d4:STD_LOGIC_VECTOR (7 DOWNTO 0);
SIGNAL aa:STD_LOGIC_VECTOR (7 DOWNTO 0);
SIGNAL bb:STD_LOGIC_VECTOR (7 DOWNTO 0);
SIGNAL cc:STD_LOGIC_VECTOR (7 DOWNTO 0);
SIGNAL dd:STD_LOGIC_VECTOR (7 DOWNTO 0);
SIGNAL ee:STD_LOGIC_VECTOR (7 DOWNTO 0);
SIGNAL ff:STD_LOGIC_VECTOR (7 DOWNTO 0);
SIGNAL gg:STD_LOGIC_VECTOR (7 DOWNTO 0);
SIGNAL hh:STD_LOGIC_VECTOR (7 DOWNTO 0);
BEGIN
dongtai:process(clk1,start)
BEGIN
if clk1'event and clk1='1' then
if chose="01111111" then chose<="11111110";num<=hh;
elsif chose="11111110" then chose<="11111101";num<=gg;
elsif chose="11111101" then chose<="11111011";num<=ff;
elsif chose="11111011" then chose<="11110111";num<=ee;
elsif chose="11110111" then chose<="11101111";num<=dd;
elsif chose="11101111" then chose<="11011111";num<=cc;
elsif chose="11011111" then chose<="10111111";num<=bb;
elsif chose="10111111" then chose<="01111111";num<=aa;
else chose<="01111111";num<=aa;
END if;
END if;
choose<=chose;
END process;
xianshi:process(clk1,start)//不买:q=0; 买q=1
BEGIN
if q=0 then
aa<="00000000";bb<="00000000";cc<=h1;dd<=h2;ee<=h3;ff<=h4;gg<=h5;hh<=h6;
else
aa<=t1;bb<=t2;cc<="00000000";dd<="00000000";ee<=d1;ff<=d2;gg<=d3;hh<=d4;
END if;
END process;
kaishi:process(clk2,start)//开始
BEGIN
if clk2'event and clk2='1' then
if back='0' then
q<=0;huo<=0;kong<=0;
elsif t1="11111100" and t2="11111100" then
q<=0;huo<=0;kong<=0;
elsif a='0' and q=0 then
if h1="11111100" then kong<=1;q<=1;
else huo<=1;q<=1;
END if;
elsif b='0' and q=0 then
if h2="11111100" then kong<=1;q<=1;
else huo<=2;q<=1;
END if;
elsif c='0' and q=0 then
if h3="11111100" then kong<=1;q<=1;
else huo<=3;q<=1;
END if;
elsif d='0' and q=0 then
if h4="11111100" then kong<=1;q<=1;
else huo<=4;q<=1;
END if;
elsif e='0' and q=0 then
if h5="11111100" then kong<=1;q<=1;
else huo<=5;q<=1;
END if;
elsif f='0' and q=0 then
if h6="11111100" then kong<=1;q<=1;
else huo<=6;q<=1;
END if;
END if;
END if;
END process;
jishi:process(start,clk2)//计时
BEGIN
if clk2'event and clk2='1' then
if q=0 then
t1<="10111110";t2<="11111100";
elsif kong=1 and t1="10111110" then
t1<="11111100";t2<="10110110";
elsif kong=1 and t1="10110110" then
t1<="11111100";t2<="10110110";
elsif clk2'event and clk2='1' then
if t2="11111100" then
if t1="11111100" then
elsif t1="10111110" then
t1<="10110110";t2<="11110110";
elsif t1="10110110" then
t1<="01100110";t2<="11110110";
elsif t1="01100110" then
t1<="11110010";t2<="11110110";
elsif t1="11110010" then
t1<="11011010";t2<="11110110";
elsif t1="11011010" then
t1<="01100000";t2<="11110110";
elsif t1="01100000" then
t1<="11111100";t2<="11110110";
END if;
elsif t2="11110110" then
t2<="11111110";
elsif t2="11111110" then
t2<="11100000";
elsif t2="11100000" then
t2<="10111110";
elsif t2="10111110" then
t2<="10110110";
elsif t2="01100110" then
t2<="11110010";
elsif t2="11110010" then
t2<="11011010";
elsif t2="11011010" then
t2<="01100000";
elsif t2="01100000" then
t2<="11111100";
elsif t2="10110110" then
t2<="01100110";
END if;
END if;
END if;
END process;
chenggong:process(start,clk2)//成功
BEGIN
if clk2'event and clk2='1' then
if start='0' then fg<='1';
END if;
if fg='1' then h1<="11110110";h2<="11110110";h3<="11110110";h4<="11110110";h5<="11110110";h6<="11110110";fg<='0';
END if;
if huo=1 and back='0' then //不恢复:back=1,恢复back=0
if h1="11110110" then h1<="11111110";
elsif h1="11111110" then h1<="11100000";
elsif h1="11100000" then h1<="10111110";
elsif h1="10111110" then h1<="10110110";
elsif h1="10110110" then h1<="01100110";
elsif h1="01100110" then h1<="11110010";
elsif h1="11110010" then h1<="11011010";
elsif h1="11011010" then h1<="01100000";
elsif h1="01100000" then h1<="11111100";
END if;
elsif huo=2 and back='0' then
if h2="11110110" then h2<="11111110";
elsif h2="11111110" then h2<="11100000";
elsif h2="11100000" then h2<="10111110";
elsif h2="10111110" then h2<="10110110";
elsif h2="10110110" then h2<="01100110";
elsif h2="01100110" then h2<="11110010";
elsif h2="11110010" then h2<="11011010";
elsif h2="11011010" then h2<="01100000";
elsif h2="01100000" then h2<="11111100";
END if;
elsif huo=3 and back='0' then
if h3="11110110" then h3<="11111110";
elsif h3="11111110" then h3<="11100000";
elsif h3="11100000" then h3<="10111110";
elsif h3="10111110" then h3<="10110110";
elsif h3="10110110" then h3<="01100110";
elsif h3="01100110" then h3<="11110010";
elsif h3="11110010" then h3<="11011010";
elsif h3="11011010" then h3<="01100000";
elsif h3="01100000" then h3<="11111100";
END if;
elsif huo=4 and back='0' then
if h4="11110110" then h4<="11111110";
elsif h4="11111110" then h4<="11100000";
elsif h4="11100000" then h4<="10111110";
elsif h4="10111110" then h4<="10110110";
elsif h4="10110110" then h4<="01100110";
elsif h4="01100110" then h4<="11110010";
elsif h4="11110010" then h4<="11011010";
elsif h4="11011010" then h4<="01100000";
elsif h4="01100000" then h4<="11111100";
END if;
elsif huo=5 and back='0' then
if h5="11110110" then h5<="11111110";
elsif h5="11111110" then h5<="11100000";
elsif h5="11100000" then h5<="10111110";
elsif h5="10111110" then h5<="10110110";
elsif h5="10110110" then h5<="01100110";
elsif h5="01100110" then h5<="11110010";
elsif h5="11110010" then h5<="11011010";
elsif h5="11011010" then h5<="01100000";
elsif h5="01100000" then h5<="11111100";
END if;
elsif huo=6 and back='0' then
if h6="11110110" then h6<="11111110";
elsif h6="11111110" then h6<="11100000";
elsif h6="11100000" then h6<="10111110";
elsif h6="10111110" then h6<="10110110";
elsif h6="10110110" then h6<="01100110";
elsif h6="01100110" then h6<="11110010";
elsif h6="11110010" then h6<="11011010";
elsif h6="11011010" then h6<="01100000";
elsif h6="01100000" then h6<="11111100";
END if;
END if;
END if;
END process;
jiage:process(start,clk1)//价格
BEGIN
if clk1'event and clk1='1' then
if kong=1 then
d1<="11101100";d2<="11111100";d3<
- 1
- 2
前往页