基于fpga的自动售票机,暂时一部分源码而已
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity ch is
port(a,b,c,d,choose,qux:in std_logic;
a1,b1,c1,d1:in integer range 0 to 7;--shuru ku cun
m1:in integer range 0 to 7;--shu ru jin er
m:out integer range 0 to 7;--sheng yu jin er
suo:out std_logic;
z1,z2,z3,z4:out std_logic;
a0,b0,c0,d0:out integer range 0 to 7);--ku cun shu liang
end entity;
architecture one of ch is
signal abcd:std_logic_vector(3 downto 0);
signal m2,m3:integer range 0 to 7;
signal kua,kub,kuc,kud:integer range 0 to 7;
signal ch:std_logic;
begin
z1<=a;
z2<=b;
z3<=c;
z4<=d;
process(choose,a)
begin
if choose'event and choose='1' then
abcd<=a&b&c&d;
if ( qux='0' )then -- choose'event and
case abcd is
when "1000"=>m2<=1;kua<=a1-1;m3<=m1-m2;
when "0100"=>m2<=2;kub<=b1-1;m3<=m1-m2;
when "0010"=>m2<=3;kuc<=c1-1;m3<=m1-m2;
when "0001"=>m2<=4;kud<=d1-1;m3<=m1-m2;
when others=> m2<=0;
end case;
end if;
end if;
if kua=0 or kub=0 or kuc=0 or kud=0 or m3=0 then
suo<='0';
else
suo<='1';
end if;
m<=m3;
a0<=kua;
b0<=kub;
c0<=kuc;
d0<=kud;
end process;
end one;
文章评论(0条评论)
登录后参与讨论