1. <tt id="5hhch"><source id="5hhch"></source></tt>
    1. <xmp id="5hhch"></xmp>

  2. <xmp id="5hhch"><rt id="5hhch"></rt></xmp>

    <rp id="5hhch"></rp>
        <dfn id="5hhch"></dfn>

      1. 自動(dòng)售貨機(jī)VHDL程序

        時(shí)間:2022-11-22 15:24:55 通信工程畢業(yè)論文 我要投稿
        • 相關(guān)推薦

        自動(dòng)售貨機(jī)VHDL程序

        (1)自動(dòng)售貨機(jī)VHDL程序如下:
        --文件名:pl_auto1.vhd。
        --功能:貨物信息存儲(chǔ),進(jìn)程控制,硬幣處理,余額計(jì)算,顯示等功能。
        --說(shuō)明:顯示的錢(qián)數(shù)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;                              --系統(tǒng)時(shí)鐘
         set,get,sel,finish: in std_logic;                   --設(shè)定、買(mǎi)、選擇、完成信號(hào)
         coin0,coin1: in std_logic;                      --5角硬幣、1元硬幣
         price,quantity  :in std_logic_vector(3 downto 0);   --價(jià)格、數(shù)量數(shù)據(jù)
         item0 , act:out std_logic_vector(3 downto 0);       --顯示、開(kāi)關(guān)信號(hào)
         y0,y1 :out std_logic_vector(6 downto 0);          --錢(qián)數(shù)、商品數(shù)量顯示數(shù)據(jù)
         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);                      --商品種類(lèi)
        signal coin: std_logic_vector(3 downto 0);                      --幣數(shù)計(jì)數(shù)器
        signal pri,qua:std_logic_vector(3 downto 0);                    --商品單價(jià)、數(shù)量
        signal clk1: std_logic;                                      --控制系統(tǒng)的時(shí)鐘信號(hào)
        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";
         --把商品的單價(jià)、數(shù)量置入到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;                  --對(duì)商品進(jìn)行循環(huán)選擇
         elsif get='1' then                              --對(duì)商品進(jìn)行購(gòu)買(mǎi)
         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";  --購(gòu)買(mǎi)時(shí),自動(dòng)售貨機(jī)對(duì)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                            --結(jié)束交易,退幣(找?guī)牛?br />          if coin>"0001" then act10<='1';coin<=coin-2;     --此IF語(yǔ)句完成找?guī)挪僮?br />          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);           --商品單價(jià)的讀取
                 end loop;
                 for i in 0 to 3 loop
                 quan(i):=ram(conv_integer(item))(i);            --商品數(shù)量的讀取
                 end loop;
              end if;
          end if;
         qua<=quan;
        end process com;

        m32:process(clk)                            --此進(jìn)程完成對(duì)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)                       --錢(qián)數(shù)的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)                       --單價(jià)的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;

        【自動(dòng)售貨機(jī)VHDL程序】相關(guān)文章:

        從程序本位到程序自治06-04

        開(kāi)題會(huì)的程序03-07

        淺議民事再審程序06-04

        批捕聽(tīng)證程序初探08-15

        本科畢業(yè)答辯程序05-03

        論民事再審程序的改革06-02

        小額訴訟程序的理解與適用05-05

        配網(wǎng)自動(dòng)化論文06-08

        我國(guó)土地征收程序的完善06-04

        論道路運(yùn)輸管理的行政程序06-01

        国产高潮无套免费视频_久久九九兔免费精品6_99精品热6080YY久久_国产91久久久久久无码

        1. <tt id="5hhch"><source id="5hhch"></source></tt>
          1. <xmp id="5hhch"></xmp>

        2. <xmp id="5hhch"><rt id="5hhch"></rt></xmp>

          <rp id="5hhch"></rp>
              <dfn id="5hhch"></dfn>