⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chengxu.txt

📁 use of the VHDL language traffic lights control procedures, with a complete report of the experiment
💻 TXT
字号:
具体状态实现:选择站点,算出票价(既2元,4 元)


选择票数,算出所需要的钱(票数分1张,两张,三张,四张)
投币,每次计算投的钱数,或纸币,1,2,5,10元;
比较需要的钱和投的钱
如果无余额,做出票工作
如果有余额,做出票工作,转入找零
找零状态
可以取消,返回选择站点状态









library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;

entity ticketsell is
port (clk       :in std_logic;
      coin5j  :in std_logic_vector(3 downto 0);
   coin1  :in std_logic_vector(3 downto 0);
   paper1  :in std_logic_vector(3 downto 0);
   paper2  :in std_logic_vector(3 downto 0);
   paper5  :in std_logic_vector(3 downto 0);
   paper10 :in std_logic_vector(3 downto 0);
      station   :in std_logic_vector(1 downto 0);
      number    :in std_logic_vector(1 downto 0);
      reset     :in std_logic;
      ticketout :out std_logic_vector(3 downto 0);
      zhaoling  :out std_logic_vector(15 downto 0));
    
      end ticketsell;
 architecture behave of ticketsell is 

        type state_type is(s0,s1,s2); 
        signal state: state_type;
        signal money:std_logic_vector(15 downto 0);
          begin
            process(clk,reset)
                begin
                if reset='1' then
               state<=s0;
                elsif clk'event and clk='1' then
                  case state is 

                  when s0=>
                    case station is
                    when "01"=>
                    money<="0010";
                    state<=s1;
                    when "10"=>
                     money<="0100";
                     state<=s1;
                     when others=>null;
                     end case;

                  when s1=>
                   if money="0010" then
                    case number is
                    when "01"=>
                     money<="0010";
                    when "10"=>
                     money<="0100";
                    when "11"=>
                     money<="0110";
                      end case;
                       state<=s2;
                else  money="0100" then
                   case number is
                    when "01"=>
                     money<="0100";
                    when "10"=>
                     money<="1000";
                    when "11"=>
                     money<="1100";
                      end case;
                       state<=s2;
                      end if;
          
                  when s2=>
                     if (coin5j*0.5+coin+paper1+2*paper2+5*paper5+10*paper10)>=money then
                       ticketout<=number;
                       zhaoling<=coin5j*0.5+coin+paper1+2*paper2+5*paper5+10*paper10-money;
                    else  state<=s1;
                          ticketout<="0";
                          zhaoling<="0"
                      end if;
                      end case;
                      end if;
                      end process;
                      end behave;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -