集成电路技术分享

 找回密码
 我要注册

QQ登录

只需一步,快速开始

搜索
查看: 4334|回复: 6

自动售货机vhdl代码以及解析

[复制链接]
奋斗的小孩 发表于 2016-7-8 21:24:02 | 显示全部楼层 |阅读模式
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity drink_auto_sale is
         port(clk: in std_logic;
                   reset:in std_logic;
                   sw101:in std_logic;
                   sw102:in std_logic;
                   buy : out std_logic;
                   back: out std_logic);
end drink_auto_sale;
architecture Behavioral of drink_auto_sale is
type state_type is(st0,st1);
signal cs ,ns : state_type;
begin
process(clk,reset)
begin
         if(reset = '1') then
                   cs <= st0;
         elsif(clk'event and clk = '1') then   
                   cs <= ns;
         end if;
end process;

process(reset ,cs)
begin
         case cs is
                   when st0 =>        if( sw101 = '1') then
                                                                 ns <= st1;
                                                                 buy<= '0';
                                                                 back<= '0';
                                                        elsif(sw102 = '1') then
                                                                 ns <= st0;
                                                                 buy<= '1';
                                                                 back <= '0';
                                                        else
                                                                 ns <= st0 ;
                                                                 buy <= '0';
                                                                 back <= '0';
                                                        end if;
                   when st1 => if(sw101 = '1') then
                                                                 ns <= st0;
                                                                 buy <= '1';
                                                                 back <= '0';
                                                        elsif(sw102 = '1') then
                                                                 ns <= st0;
                                                                 buy <= '1';
                                                                 back <= '1';
                                                        end if;
                   when others => ns <= st0;
                                                                 buy<= '0';
                                                                 back <= '0';
         end  case;
end process;
end Behavioral;
设 计过程:设定三个状态:0分,5分;当状态为0分时,接收到5分信号脉冲后转为5分;接收到10分信号脉冲时,转到0分状态,同时弹出饮料,不找零;状态 为5分时,接受到5分信号,弹出饮料,不找零,返回0分状态;当接受到10分状态时,弹出饮料,找零,并返回零分状态。
 楼主| 奋斗的小孩 发表于 2016-7-8 21:24:47 | 显示全部楼层
用vhdl做课程设计的学生,可以借鉴一下哈!!!!!!!。。。。。。。。。。奋斗的小孩
zxopen08 发表于 2016-9-3 12:02:44 | 显示全部楼层
自动售货机vhdl代码以及解析,可以学习了victory:
辉煌 发表于 2016-12-24 09:11:56 | 显示全部楼层
感谢群主分享
芙蓉王 发表于 2016-12-26 15:07:14 | 显示全部楼层
                感谢楼主分享
fpga_wuhan 发表于 2017-1-6 11:05:36 | 显示全部楼层
自动售货机vhdl代码以及解析
fpga_feixiang 发表于 2023-8-21 14:11:17 | 显示全部楼层
6                             
您需要登录后才可以回帖 登录 | 我要注册

本版积分规则

关闭

站长推荐上一条 /1 下一条

QQ|小黑屋|手机版|Archiver|集成电路技术分享 ( 京ICP备20003123号-1 )

GMT+8, 2024-5-19 12:38 , Processed in 0.138715 second(s), 19 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表