简易地铁自动售票系统设计方案 下载本文

内容发布更新时间 : 2024/12/23 1:57:49星期一 下面是文章的全部内容请认真阅读。

Rebuy:in std_logic; --开始购票操作 Clk:in std_logic; -- 系统时钟 Cancelkey: in std_logic; -- 取消操作键 Style: in std_logic_vector(2 downto 0); -- 车票种类 Tnum:in std_logic_vector(2 downto 0); -- 所购票数 Money: in std_logic_vector(2 downto 0); --投币口 MoneyInputAlarm:out std_logic; -- 投币不足报警信号 Tout:out std_logic; -- 出票 Mout:out std_logic_vector(1 downto 0); -- 余额找出 State:out std_logic_vector(4 downto 0);-- 系统状态指示 -- beep:out std_logic; --蜂鸣器信号 SG:out std_logic_vector(6 downto 0); --段码 BT:out std_logic_vector(5 downto 0) ); end SubwayAutoTicketSellSystem; architecture behave of SubwayAutoTicketSellSystem is component div_2K --引入div_2k分频模块 --位码 port(clk_in: in std_logic; clk_out: out std_logic); end component; component div_500K --引入div_500k分频模块 port(clk_in2: in std_logic; clk_out2: out std_logic); end component; component keyin --引入keyin防抖模块 port(clk_in1:in std_logic; reset:in std_logic; resetn:out std_logic); end component; type TT is (selstyle,selticket,inputmoney,ticketout,givechange) ; -- 定义系统转换状态 (等待选择票种状态, 等待选择购票数量状态, 等待放入钱币状态, 出票状态, 找零状态) signal clk_tmp:std_logic; signal clk_tmp2:std_logic; signal --临时时钟 --临时时钟2 CNT6:INTEGER RANGE 0 TO 5; signal A:INTEGER RANGE 0 TO 5; signal Tstyle:std_logic_vector(6 downto 0);--车票单价显示 signal Tnumber:std_logic_vector(6 downto 0); --车票数量显示 signal Minput1:std_logic_vector(6 downto 0); --投入金额十位显示 signal Minput2:std_logic_vector(6 downto 0); --投入金额个位显示 signal Minput:std_logic_vector(4 downto 0); --投入金额计数 signal Toutnum0:std_logic_vector(6 downto 0); --出票数量显示 signal Toutnum:std_logic_vector(1 downto 0); --出票数量计数 signal Changeout0:std_logic_vector(6 downto 0); --输出零钱数显示 signal Changeout:std_logic_vector(3 downto 0); --输出零钱数量计数signal Moneyn:std_logic_vector(2 downto 0); --防抖之后实际投币输入 begin u1:div_2k port map(clk_in=>CLK,clk_out=>clk_tmp); --各种映射 u2:div_500k port map(clk_in2=>CLK,clk_out2=>clk_tmp2); u4:keyin port map(clk_in1=>CLK_tmp2,reset=>money(0),resetn=>moneyn(0)); u5:keyin port map(clk_in1=>clk_tmp2,reset=>money(1),resetn=>moneyn(1)); u6:keyin port map(clk_in1=>clk_tmp2,reset=>money(2),resetn=>moneyn(2)); --------------------以下为数码管显示程序模块----------- process(CNT6) begin case CNT6 is --3线至6线译码器 when 0 => BT <= \为位码 when 1 => BT <= \ when 2 => BT <= \ when 3 => BT <= \ when 4 => BT <= \ when 5 => BT <= \ when others => NULL ; end case ; end process; process(clk_tmp) begin if clk_tmp'event and clk_tmp= '1' then --实现模6计数器 if CNT6 = 5 then CNT6 <= 0; else CNT6 <= CNT6+1; end if; end if; end process; process(A) begin --实现数码管的显示功能 case A is when 0 => SG <= Tstyle ; when 1 => SG <= Tnumber ; when 2 => SG <= Minput1 ; when 3 => SG <= Minput2 ; when 4 => SG <= Toutnum0 ; when 5 => SG <= Changeout0 ; when others => NULL ; end case ; end process; process(Minput) --投入金额数码管显示 begin case Minput is when \when \when \when \when \when \when \when \when \when \when \when \