已阅读5页,还剩4页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
CPLD/FPGA原理及应用课程上机实验报告(六)实验名称自动售货机的设计实验时间实验地点计算机房实 验 人姓 名陈凯文合 作 者无学 号20101185066实验小组第 组实验性质验证性 设计性 综合性 应用性实验成绩: 评阅教师签名:一实验要求1)设计一个自动售货机2)只能卖1.5,2,2.5三种商品只能投0.5,1,5元三种货币3)用modelsim仿真观察波形验证程序二实验内容 Sa,sb,sc分别表示1.5,2,2.5三种商品Ma,mb,mc分别表示0.5 1 5元三种钱Ch1,ch2,ch3分别表示三种商品的出货Zl代表找零首先我这一次实验并不成功,由于对verilog语言不熟练很多语法规则都不知道,加之身体问题好吧这些都是我失败的借口吧。下面是我的状态图状态图:这个状态图画完我想可能我的设计可能存在很大的问题因为我从未在case你写过case编程如下timescale 1ns/1nsmodule zidong_tp;reg3:0c,t;reg rst,clk;reg sa,sb,sc,ma,mb,mc;wire ch1,ch2,ch3,zl;parameter CYCLE=100;always #(CYCLE/2) clk=clk;initial clk=1;zidong u1(sa,sb,sc,ma,mb,mc,rst,zl,ch1,ch2,ch3,clk);initial begin sa=1;sb=0;sc=0;rst=1;ma=0;mb=0;mc=0; #100sa=1;sb=0;sc=0;rst=0;mc=0;ma=0;mb=0; #10sa=0;sb=0;sc=0;rst=0;mc=1;ma=0;mb=0; #90sa=1;sb=0;sc=0;rst=1;mc=0;ma=0;mb=0; #10sa=0;sb=0;sc=0;rst=0;mc=1;ma=0;mb=0; endinitial $monitor($time,%d,%d,%d,%d,%d,%d,%d,%b,%d,%d,%d,%d,sa,sb,sc,ma,mb,mc,rst,zl,ch1,ch2,ch3,clk);endmodulemodule zidong(sa,sb,sc,ma,mb,mc,rst,zl,ch1,ch2,ch3,clk);input sa,sb,sc,ma,mb,mc,rst,clk;output zl,ch1,ch2,ch3;reg3:0c,t;reg zl,ch1,ch2,ch3;parameter c0=0,c1=1,c2=2,c3=3,t0=0,t1=1,t2=2,t3=3,t4=4;always (posedge clk)begin if(!rst)begin c=c0;zl=0;ch1=0;ch2=0;ch3=0; t=t0; end else if(sa=1&sb=0&sc=0) c=c1; else if(sa=0&sb=1&sc=0) c=c2; else if(sa=0&sb=0&sc=1) c=c3; else c=c0;endalways(ma or mb or mc or rst)begin case(c) 0:begin zl=0;ch1=0;ch2=0;ch3=0; t=t0; end 1:begin case(t) 0:begin if(ma)begin t=t1;zl=0;ch1=0;end else if(mb)begin t=t2;zl=0;ch1=0;end else if(mc)begin t=t0; zl=3.5;ch1=1;end else begin t=t0;zl=0;ch1=0;ch1=1;end end 1:begin if(!rst)begin t=t0;zl=0.5;ch1=0;end else if(ma)begin t=t2;zl=0;ch1=0;end else if(mb)begin t=t0;zl=0;ch1=1;end else if(mc)begin t=t0;zl=4;ch1=1;end else begin t=t1; zl=0;ch1=0;end end 2:begin if(!rst)begin t=t0;zl=1;ch1=0;end else if(ma)begin t=t0;zl=0;ch1=1;end else if(mb)begin t=t0;zl=0.5;ch1=1;end else if(mc)begin t=t0;zl=4.5;ch1=1;end else begin t=t2;zl=0;ch1=0;end end default:t=t0; endcase end 2: begin case(t) 0:begin if(ma)begin t=t1;zl=0;ch2=0;end else if(mb)begin t=t2;zl=0;ch2=0;end else if(mc)begin t=t0; zl=3;ch2=1;end else begin t=t0;zl=0;ch2=0;end end 1:begin if(!rst)begin t=t0;zl=0.5;ch2=0;end else if(ma)begin t=t2;zl=0;ch2=0;end else if(mb)begin t=t3;zl=0;ch2=0;end else if(mc)begin t=t0;zl=3.5;ch2=1;end else begin t=t1;zl=0;ch2=0; end end 2:begin if(!rst)begin t=t0;zl=1;ch2=0;end else if(ma)begin t=t3;zl=0;ch2=0;end else if(mb)begin t=t0;zl=0;ch2=1;end else if(mc)begin t=t0;zl=4;ch2=1;end else t=t2;zl=0;ch2=0; end 3:begin if(!rst)begin t=t0;zl=1.5;ch2=0;end else if(ma)begin t=t0;zl=0;ch2=1;end else if(mb)begin t=t0;zl=0.5;ch2=1;end else if(mc)begin t=t0;zl=4.5;ch2=1;end else begin t=t2;zl=0;ch2=0;end end default:t=t0; endcase end3: begin case(t) 0:begin if(ma)begin t=t1;zl=0;ch3=0;end else if(mb)begin t=t2;zl=0;ch3=0;end else if(mc)begin t=t0;zl=2.5;ch3=1;end else begin t=t0;zl=0;ch3=0;end end 1:begin if(!rst)begin t=t0;zl=0.5;ch3=0;end else if(ma)begin t=t2;zl=0;ch3=0;end else if(mb)begin t=t3;zl=0;ch3=0;end else if(mc)begin t=t0;zl=3;ch3=1;end else begin t=t1;zl=0;ch3=0;end end 2:begin if(!rst)begin t=t0;zl=1;ch3=0;end else if(ma)begin t=t3;zl=0;ch3=0;end else if(mb)begin t=t4;zl=0;ch3=0;end else if(mc)begin t=t0;zl=3.5;ch3=1;end else begin t=t2;zl=0;ch3=0;end end 3:begin if(!rst)begin t=t0;zl=1.5;ch3=0;end else if(ma)begin t=t4;zl=0;ch3=0;end else if(mb)begin t=t0;zl=0;ch3=1;end else if(mc)begin t=t0;zl=4;ch3=1;end else begin t=t3;zl=0;ch3=0;end end 4:begin if(!rst)begin t=t0;zl=2;ch3=0;end else if(ma)begin t=t0;zl=0;ch3=1;end else if(mb)begin t=t0;zl=0.5;ch3=1;end else if(mc)begin t=t0;zl=4.5;ch3=1;end else begin t=t4;zl=0;ch3=0;end end default:t=t0; endcase end default:c=c0; endcase end endmodule仿真波形如下很明显存在问题zl无法正确显示只能正常出货编译后生成状态图只看到大状态看不到里面的小状态我也不知道是否正确于是做了大量修改发现这样出的波形算是比较好的,可能是触发的问题在一些情况下比如延迟和clk周期一样是是完全没有实现的,后来我仔细思考了一下我的程序最大的问题可能是状态间转换没有做延迟,这样造成程序并不好仿真。后来在网上收集了大量资料找到了和我思想相似的程序,作者做的非常明了状态转换也十分清晰,相比之下我应该是初学
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026秋小学人教版(新教材)数学二年级上册第三单元应用题学困生易错题专项练习题附参考答案
- 保险行业风险管理与内部控制专项训练题库
- 保险市场研究与营销策略模拟试题
- 高中体育专业知识考试试题及答案
- 中级注册安全工程师之安全生产法及相关法律知识题库练习试卷B卷附答案
- 疫情安全考试题及答案
- 2026年中医耳鼻喉科耳廓挫伤中医消肿护理考核卷及答案
- 2025年江苏省太仓市高二生物上册期末考试测试卷附完整答案(有一套)
- 山地风电升压站土建考题及答案解析
- 2026年沼气工职业技能等级认定题库
- 3.2.1 分数除以整数 教学课件2026-2027学年人教版数学六年级上册
- 译林版七年级英语上册知识清单
- 2026秋冀少版新教材七年级上册生物学每课知识点清单
- 中国重症患者液体管理专家共识(2026版)
- 2026年6月英语四级真题(第一套)附答案
- 燃料电池发动机YHT30版用户使用手册
- 2026年全国翻译专业资格考试(CATTI)三级口译英语口译综合能力真题
- GB/T 21873-2025橡胶密封件给、排水管及污水管道用接口密封圈材料规范
- 雨课堂学堂在线学堂云《临床伦理与科研道德(山东大学)》单元测试考核答案
- 2025年住院医师规范化师资培训考试题附答案
- 粮库智能化设备管理制度
评论
0/150
提交评论