电子系统设计论文施晓波

上传人:大米 文档编号:556749813 上传时间:2023-12-17 格式:DOCX 页数:6 大小:165.50KB
返回 下载 相关 举报
电子系统设计论文施晓波_第1页
第1页 / 共6页
电子系统设计论文施晓波_第2页
第2页 / 共6页
电子系统设计论文施晓波_第3页
第3页 / 共6页
电子系统设计论文施晓波_第4页
第4页 / 共6页
电子系统设计论文施晓波_第5页
第5页 / 共6页
点击查看更多>>
资源描述

《电子系统设计论文施晓波》由会员分享,可在线阅读,更多相关《电子系统设计论文施晓波(6页珍藏版)》请在金锄头文库上搜索。

1、滋共丈理摩院Hubei University of Arts and Science电子系统设计论文自动售货机学 院: 物理与电子工程学院 专 业: 电子信息工程 0911 班 学生姓名:施晓波(2009128103 指导教师:胡 晗自动售货机的设计与仿真摘要:该设计是基于Alt era公司的开发软件Quar tusll平台上,采用Verilog HDL硬件描 述语言编程的设计方法,设计系统核心电路的硬件程序,在软件Quar tusll上进行编译和电 路仿真,并得到仿真及原理模块图,最终完成的自动售货机系统具有投币处理、商品选择、 购货撤消、异常退币报警和实施找零等主要功能。关键字:EDA;

2、Quar tusll; Verilog HDL硬件描述语言;自动售货机Design and simulation of the vending machineAbstract: The design is based on Altera Corporation development software Quartus II platform using Verilog HDL hardware description language programming of the design method, design system, the core circuit hardware proce

3、dures, software, the Quartus II carried out to compile and circuit simulation, and get the simulation and the principle of modulemap, final completion of the vending machine with coin processing, selection of merchandise, purchases of undo, abnormal coin alarm and implementation of the change for th

4、e main function.Keywords: EDA; the Quartus II; Verilog HDL hardware description language; vending machines1 前言 本设计主要以程序为主,硬件方面则使用实验箱,将程序各变量端口与实验箱管脚进行相应 的配置,用九个开关分别代表商品价格、所投钱币价格、确认付款找零及复位操作。当选择 好商品并投币后,数码管显示所选商品价格及投入钱币价格;按下确认付款开关,数码管显 示应找多少钱,蜂鸣器响,对应商品LED灯亮。若所投钱币不足所选商品价格,对应警告钱 币不足的 LED 灯亮。自动售货机作为一种先进的

5、消费方式,已经成为城市现代文明发达程度 的重要标志,其新颖、时尚的购物方式, 24 小时营业的特点给人们生活带来了便利,美化 了城市环境,受到消费者的欢迎。整个系统的开发体现了在软件Quartusll平台上用Verilog HDL 设计数字控制系统的实用性。2 系统设计2.1 自动售货机状态描述4 个开关分别代表四种商品。 3 个开关分别代表投入0.5 元, 1 元, 5 元的七种组合, 统计投入总额。投入总额与商品价格做比较,如果总额商品价格,退钱报警并返回初始状 态,如果总额=商品价格,则继续执行下面的程序。找零=总额-商品价格,数码管显示找零 金额。状态图如下所示:/初始状态/nr2.2

6、详细状态描述2.2.1 初始状态各变量都设置为零,按下RESET键后,一切恢复到初始状态。2.2.2 选商品状态分别有价格为 0.5 元、1 元、1.5 元和 2 元的商品,每次选择商品前,设置一个标志位 xz_sell 表示选择商品状态。此自动售货机每一次售货时只能一次选择一种商品,当同时选 择两种以上时,选择商品无效,数码管显示清零,重新进行商品选择。选择商品后,数码管 显示所选商品价格。2.2.3 投币状态当选好商品后,开始投币。同样有一标志位 xz_mony 表示投币金额。投币口只接受三种 面值的钱币0.5元、1元和5 元,可以同时投入多种面值钱币。投完币后,先有一个确认买 商品的过程

7、,若投了币但又不购买商品了,就将全部投币金额退回;若确认购买商品,则进 入下一状态找零状态。2.2.4 找零状态投完币,并确认购买商品后,进入找零状态。首先要将所投的金额与所选商品的价格做 比较,若所投金额小于商品价格,则通过设置一个标志位led_warn警告并退回所投钱币;若大于等于商品价格,则两者做差,得到需要找零的钱并由数码管显示。3 程序设计自动售货机程序如下:module auto(CLK,RST,xz_mony,xz_sell,led_warn,led,beep,q_ok,flag,sm_xs);/有 0.5,1,1.5,2 四种商品input CLK,RST,q_ok;确定付款i

8、nput 2:0 xz_mony;/ 选择放入多少钱input 3:0 xz_sell;/ 选择商 品output 2:0 flag;/ 位选 output 3:0 led;/ 对应商 品的灯亮output led_warn; / 钱不 够output beep;output 6:0 sm_xs;reg 3:0 led;reg led_warn;reg 2:0 flag;reg 31:0 counter; /计数器 reg9:0price,price_all,price_sx;reg beep;reg clkout; reg 6:0 sm_xs; reg16:0 cnt;parameter c

9、ount1 = 5d10000;always(posedge CLK)/ 减 法分频begin if(counter=count1-1) begin counter=0; clkout=clkout;end else counter=counter+1; endalways(negedge RST or posedge CLK)begin if(!RST) beginled=4b0000;售货机的初 始化price=0; price_all=0; led_warn=0;beep=1;end else begin/有0.5丄5三种钱 case(xz_mony)3b001:begin price_

10、all = 5;end3b010:begin price_all = 10;end 3b011:begin price_all = 15;end 3b100:begin price_all = 50;end 3b101:begin price_all = 55;end 3b110:begin price_all = 60;end 3b111:begin price_all = 65;end default:begin price_all = 0;end endcasecase(xz_sell)4b0001:begin price = 5; end / 只能让一种 LED 灯亮,所以选 择一个灯

11、有效4b0010:begin price = 10; end4b0100:begin price = 15;end4b1000:begin price = 20;end default:begin price = 0;end endcaseif(q_ok=1)beginif(price_allprice) beginled_warn=l; 钱 不够 price=0;beep=l; price_sx=price_all; endelsebeginprice_sx=price_all-price;beep=O;蜂鸣器响case(price)5: begin led = 4b000l;end l0:

12、begin led = 4b00l0;end l5:begin led = 4b0l00;end 20:begin led = 4bl000;end endcaseendendelsebeep=l;endendalways(posedge clkout ornegedge RST) /延时部分if(!RST) cnt=lb0;else cnt=cnt+lbl; always(cnt2:0)位选部分,改 变其位数来改变延时时间begin case(cnt2:0)3b000:flag=3b000;3b00l: flag=3b00l;3b0l0: flag=3b0l0;3b0ll: flag=3b0

13、ll;3bl00: flag=3bl00;3bl0l: flag=3bl0l;3bll0: flag=3bll0; default: flag=3blll;endcaseendalways(flag )/段选部分 begin case(flag) 3bl0l:sm_xs= ledsm(price_all/l0); 3bl00:sm_xs=ledsm(price_all% l0);3b0ll:sm_xs= ledsm(price/l0); 3b0l0:sm_xs= ledsm(price%l0); 3b00l:sm_xs=ledsm(price_sx/l 0);3b000:sm_xs=ledsm

14、(price_sx% l0);3bll0:sm_xs=7b0000000; 3blll:sm_xs=7b0000000;endcaseendfunction 6:0 ledsm;/数码管段 表input 3:0 sm_input ;begincase (sm_input)0 : ledsm = 7b0llllll;1 : ledsm = 7b0000ll0;2 : ledsm = 7bl0ll0ll;3 : ledsm = 7bl00llll;4 : ledsm = 7bll00ll0;5 : ledsm = 7bll0ll0l;6 : ledsm = 7blllll0l;7 : ledsm

15、= 7b0000lll;8 : ledsm = 7blllllll;9 : ledsm = 7bll0llll; default : ledsm = 7b0000000;endcaseendendfunctionendmodule4 仿真结果第一种情况:放入1 元买 1.5 元的商品第三种情况:放入1 元买1 元的商品其余商品情况类似。5 结束语通过本次课程设计,我对Verilog HDL语言有了更深刻的了解,能够比较灵活地运用它 来实现我们所想要实现的功能。在实验中,我们也遇到了很多挫折,不过我都和同伴一一克 服了,两人齐心协力解决了问题,在以后的道路上我们深刻认识到团队合作的精神的重要性。 成功就是在不断摸索着前进中实现的,遇到问题我们不能灰心、烦

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 办公文档 > 解决方案

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号