久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 3578|回復: 2
收起左側

fpga模擬一個自動售貨機 源代碼

[復制鏈接]
ID:393004 發表于 2018-9-3 15:27 | 顯示全部樓層 |閱讀模式
售貨機賣出的商品價值5元,只能投入1元,2元,5元。因此需要多種狀態,分別代表投入的錢數,直到投夠5元顯示出貨狀態,當超過5元時還要找零。

源代碼如下:
library ieee;
use ieee.std_logic_1164.all;
entity state is
port(
  clk,reset:in std_logic;
  input : in std_logic_vector(0 to 1);
  sel : buffer std_logic_vector(0 to 2);    --片選
  show : out std_logic_vector(0 to 6);      --八位七段
  output:out std_logic_vector(0 to 1)
);
end state;
architecture behave of state is
type s_m is (s0,s1,s2,s3,s5,s6);
signal current_state,next_state:s_m;



begin
   sel<="000";
       process(reset,clk)
       begin
                    if (clk'event and clk='1') then
   current_state<=next_state;
     if reset='1' then
                  current_state<=s0;
                    end if;
                      end if;
       end process;
      
       process(current_state,input)
begin
       case current_state is
       when s0=>output<="00";
        show<="1111110";  --0
        if input="00" then next_state<=s0;
        elsif input="01" then next_state<=s1;
                       elsif input="10" then next_state<=s2;
        elsif input="11" then next_state<=s5;
        end if;
   
       when s1=>output<="00";
        show<="0110000";   --1
        if input="00" then next_state<=s1;
        elsif input="01" then next_state<=s2;
        elsif input="10" then next_state<=s3;
        elsif input="11" then next_state<=s6;
       end if;
   
       when s2=>output<="11";
  show<="0110111";   --H
  if input="00" then next_state<=s0;
  elsif input="01" then next_state<=s1;
  elsif input="10" then next_state<=s2;
  elsif input="11" then next_state<=s5;
  end if;
   
       when s3=>output<="11";
  show<="0110000";   --找1
  if input="00" then next_state<=s0;
  elsif input="01" then next_state<=s1;
  elsif input="10" then next_state<=s2;
                elsif input="11" then next_state<=s5;
  end if;
   
         
       when s5=>output<="11";
  show<="0110000";   --找1
  if input="00" then next_state<=s0;
  elsif input="01" then next_state<=s1;
                elsif input="10" then next_state<=s2;
  elsif input="11" then next_state<=s5;
  end if;
   
       when s6=>output<="11";
                show<="0110111";   --H
  if input="00" then next_state<=s0;
  elsif input="01" then next_state<=s1;
  elsif input="10" then next_state<=s2;
  elsif input="11" then next_state<=s5;
  end if;
   
      
   
end case;
                end process;
end behave;
   
   
   
回復

使用道具 舉報

ID:375250 發表于 2018-12-19 19:38 | 顯示全部樓層
這個是vhdl
回復

使用道具 舉報

ID:453467 發表于 2018-12-24 15:13 | 顯示全部樓層
復位信號建議寫成:異步復位,同步釋放
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表
主站蜘蛛池模板: www精品美女久久久tv | 亚洲欧美日韩中文在线 | 97国产爽爽爽久久久 | 欧美一区二区在线看 | 亚洲一区免费 | 国产精品18毛片一区二区 | 日韩一区二区视频 | 狠狠亚洲 | 日本免费黄色 | 欧美精品一区二区三区在线播放 | 亚洲狠狠丁香婷婷综合久久久 | 日韩亚洲视频 | 99久久99| 亚州av | 亚洲视频一区二区 | 午夜精品一区二区三区在线观看 | 久久久久国产一区二区三区 | 亚洲国产精品99久久久久久久久 | 国产精品免费观看 | 欧美久久视频 | 国产精品av久久久久久久久久 | 国产精品成人一区二区三区夜夜夜 | 欧美白人做受xxxx视频 | 日韩小视频 | 麻豆精品一区二区三区在线观看 | 中文字幕在线视频精品 | 日韩精品一区二区三区四区视频 | 精品粉嫩aⅴ一区二区三区四区 | 国产一区不卡在线观看 | 成人免费视频网站在线看 | 日韩一区二区三区在线播放 | 欧区一欧区二欧区三免费 | 亚洲精品久久久久久首妖 | 久久久久久一区 | 密乳av | 欧美日韩专区 | a级在线免费 | 日本三级全黄三级三级三级口周 | 欧美在线色 | 国产精品日女人 | 日韩视频精品在线 |