- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
[自动售货机程序
8.21 自动售货机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 clk1event and clk1=1 then act5=0; act10=0;
if coin0=1 then
if coin1001then coin=coin+1; --投入5角硬币,coin自加1
else coin=0000;
end if;
elsif coin1=1 then
if coin1001then coin=coin+2; --投入1元硬币,coin自加2
else coin=0000;
end if;
elsif sel=1 then item=item+1; --对商品进行循环选择
elsif get=1 then --对商品进行购买
if qua0000 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;
您可能关注的文档
最近下载
- 2025-2026学年小学英语五年级上册湘鲁版(2024)教学设计合集.docx
- 宜搭低代码开发师(中级)部分考题.docx VIP
- 2023年海峡杯数学试题八年级.pdf VIP
- 小学自考本科《小学课程与教学设计》2024年10月真题(附答案).docx VIP
- 等保2.0网络安全相关知识考试试卷题目及答案.doc
- DGTJ08-205-2024 居住建筑节能设计标准.pdf VIP
- 五年级上册英语教案Unit1 There is a big music room.1湘鲁版.doc VIP
- 2019钢筋焊接及验收规程JGJ182012.pdf VIP
- 高创CDHD使用说明书.pdf VIP
- 二年级语文上册试卷、练习单元测试卷第2单元第二单元 达标测试卷+答案.pdf VIP
文档评论(0)