奋斗的小孩 发表于 2016-7-8 21:24:02

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

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';
         endcase;
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

:handshake感谢群主分享

芙蓉王 发表于 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]
查看完整版本: 自动售货机vhdl代码以及解析