中文字幕在线一区二区在线,久久久精品免费观看国产,无码日日模日日碰夜夜爽,天堂av在线最新版在线,日韩美精品无码一本二本三本,麻豆精品三级国产国语,精品无码AⅤ片,国产区在线观看视频

      自動售貨機VHDL程序

      時間:2024-10-18 18:22:56 通信工程畢業論文 我要投稿
      • 相關推薦

      自動售貨機VHDL程序

      (1)自動售貨機VHDL程序如下:
      --文件名:pl_auto1.vhd。
      --功能:貨物信息存儲,進程控制,硬幣處理,余額計算,顯示等功能。
      --說明:顯示的錢數coin的 以5角為單位。
      --最后修改日期:2004.3.23。
      library ieee;
      use ieee.std_logic_arith.all;
      use ieee.std_logic_1164.all;
      use ieee.std_logic_unsigned.all;
      entity PL_auto1 is
      port ( clk:in std_logic;                              --系統時鐘
       set,get,sel,finish: in std_logic;                   --設定、買、選擇、完成信號
       coin0,coin1: in std_logic;                      --5角硬幣、1元硬幣
       price,quantity  :in std_logic_vector(3 downto 0);   --價格、數量數據
       item0 , act:out std_logic_vector(3 downto 0);       --顯示、開關信號
       y0,y1 :out std_logic_vector(6 downto 0);          --錢數、商品數量顯示數據
       act10,act5   :out std_logic);                   --1元硬幣、5角硬幣
      end PL_auto1;
      architecture behav of PL_auto1 is
      type  ram_type is array(3 downto 0)of std_logic_vector(7 downto 0);
      signal ram :ram_type;                                      --定義RAM
      signal item: std_logic_vector(1 downto 0);                      --商品種類
      signal coin: std_logic_vector(3 downto 0);                      --幣數計數器
      signal pri,qua:std_logic_vector(3 downto 0);                    --商品單價、數量
      signal clk1: std_logic;                                      --控制系統的時鐘信號
      begin
      com:process(set,clk1)
      variable quan:std_logic_vector(3 downto 0);
      begin
        if set='1' then ram(conv_integer(item))<=price & quantity;act<="0000";
       --把商品的單價、數量置入到RAM
        elsif clk1'event and clk1='1' then  act5<='0'; act10<='0';
            if coin0='1' then    
            if coin<"1001"then coin<=coin+1;            --投入5角硬幣,coin自加1
         else coin<="0000";
         end if;
            elsif coin1='1' then
         if coin<"1001"then coin<=coin+2;            --投入1元硬幣,coin自加2
         else coin<="0000";
         end if;
            elsif sel='1' then item<=item+1;                  --對商品進行循環選擇
       elsif get='1' then                              --對商品進行購買
       if qua>"0000" and coin>=pri then coin<=coin-pri;quan:=quan-1;
       ram(conv_integer(item))<=pri & quan;
                  if   item="00" then act<="1000";  --購買時,自動售貨機對4種商品的操作
         elsif item="01" then act<="0100";
            elsif item="10" then act<="0010";
            elsif item="11" then act<="0001";
         end if;
        end if;
            elsif  finish='1' then                            --結束交易,退幣(找幣)
               if coin>"0001" then act10<='1';coin<=coin-2;     --此IF語句完成找幣操作
               elsif coin>"0000" then act5<='1'; coin<=coin-1;
               else act5<='0'; act10<='0';
               end if;
            elsif get='0' then act<="0000";                 
               for i in 4 to 7 loop                   
               pri(i-4)<=ram (conv_integer(item))(i);           --商品單價的讀取
               end loop;
               for i in 0 to 3 loop
               quan(i):=ram(conv_integer(item))(i);            --商品數量的讀取
               end loop;
            end if;
        end if;
       qua<=quan;
      end process com;

      m32:process(clk)                            --此進程完成對32Mhz的脈沖分頻
      variable q: std_logic_vector( 24 downto 0);
      begin
         if clk'event and clk='1' then q:=q+1;
         end if;
         if q="111111111111111111111111" then clk1<='1';
         else clk1<='0';
         end if;
      end process m32;

      code0:process(item)                          --商品指示燈譯碼
      begin
       case item is
       when "00"=>item0<="0111";
       when "01"=>item0<="1011";
       when "10"=>item0<="1101";
       when others=>item0<="1110";
       end case;
      end process;

      code1: process (coin)                       --錢數的BCD到七段碼的譯碼
      begin
        case coin is
            when "0000"=>y0<="0000001";
            when "0001"=>y0<="1001111";
            when "0010"=>y0<="0010010";
            when "0011"=>y0<="0000110";
            when "0100"=>y0<="1001100";
            when "0101"=>y0<="0100100";
            when "0110"=>y0<="0100000";
            when "0111"=>y0<="0001111";
            when "1000"=>y0<="0000000";
            when "1001"=>y0<="0000100";
            when others=>y0<="1111111";
        end case;
      end process;

      code2: process (qua)                       --單價的BCD到七段碼的譯碼
      begin
        case qua is
            when "0000"=>y1<="0000001";
            when "0001"=>y1<="1001111";
            when "0010"=>y1<="0010010";
            when "0011"=>y1<="0000110";
            when "0100"=>y1<="1001100";
            when "0101"=>y1<="0100100";
            when "0110"=>y1<="0100000";
            when "0111"=>y1<="0001111";
            when "1000"=>y1<="0000000";
            when "1001"=>y1<="0000100";
            when others=>y1<="1111111";
        end case;
      end process;
      end behav;

      【自動售貨機VHDL程序】相關文章:

      基于VHDL的DDS的設計與分析03-07

      在PLD開發中提高VHDL的綜合質量03-18

      PLC程序設計(洗衣機程序)全自動洗衣機的控制(一)03-07

      VHDL在高速圖像采集系統中的應用設計03-18

      有限狀態機的VHDL優化設計03-07

      自動噴水滅火系統管網的水力計算及程序實現03-20

      基于VHDL的I2C總線控制核設計03-18

      簡易通用型PCI接口的VHDL-CPLD設計03-18

      從程序本位到程序自治01-11

      主站蜘蛛池模板: 亚洲视频第一页在线观看 | 熟女少妇av免费观看| 亚洲av婷婷一区二区三区| 兴义市| 探花国产精品三级在线播放| 无码AV大香线蕉伊人久久 | 石泉县| 四虎成人精品国产永久免费| 东方市| 亚洲区1区3区4区中文字幕码| 亚洲AV秘 无码一区二区三区| 亚洲一二三四五区中文字幕| 欧美成人高清手机在线视频| 崇礼县| 精品国产午夜久久久久九九| 天全县| 蕲春县| 友谊县| 多伦县| 国产韩国精品一区二区三区| 国产一区二区三区资源在线观看| 上杭县| 久久国产色av老熟蜜臀av| 孝义市| 中文字幕日本丰满人妻| 国产一区二区内射最近人| 日本少妇精品一区二区| 日本第一区二区三区视频| 精品中文字幕日本久久久| 中文字幕在线观看乱码一区| 精品人妻一区二区久久| 国产丝袜高跟美腿一区在线| 国产av乳头久久一区| 免费人成在线高清网站| 天天摸天天做天天爽天天舒服| 成人综合久久精品色婷婷| 免费大学生国产在线观看p| av最新版天堂在资源在线| 久久99精品这里精品动漫6| 岛国熟女一区二区三区| 国产精品系列亚洲第一|