简易数字跑表设计(共14页)

上传人:des****85 文档编号:215695341 上传时间:2021-11-26 格式:DOC 页数:14 大小:7.22MB
返回 下载 相关 举报
简易数字跑表设计(共14页)_第1页
第1页 / 共14页
简易数字跑表设计(共14页)_第2页
第2页 / 共14页
简易数字跑表设计(共14页)_第3页
第3页 / 共14页
简易数字跑表设计(共14页)_第4页
第4页 / 共14页
简易数字跑表设计(共14页)_第5页
第5页 / 共14页
点击查看更多>>
资源描述

《简易数字跑表设计(共14页)》由会员分享,可在线阅读,更多相关《简易数字跑表设计(共14页)(14页珍藏版)》请在金锄头文库上搜索。

1、精选优质文档-倾情为你奉上 西安郵電大学数字控制系统课程设计报告书院(系)名称:自 动 化 学 院学生姓名:专业名称:自动化班 级:自动1103时间:2014年9月1日 至2014年9月12日乘法器设计1、 设计要求:计时精度10ms,计时范围59.99秒。(1) 对单人计时,能实现暂停、显示及清零功能,在数码管上实时显示,设置启动/暂停、清零按键;(2) 对多个人同时计时,在数码管上实时显示,并能回显出六个时间。可控制显示,设置清零、取时按键;(3) 采用状态机设计;(4) 百分秒在数码管上实时显示,秒利用多个数码管显示BCD值。二、设计过程:1.方案设计: 1)画状态图: 按键 状态 输出

2、 复位:00 开始:S0 清 零:z=0; 启/停:01 计数:S1 不清零:z=1; 存/回显:10 暂停:S2 存/回显:S32) 写程序: 在一个module模块里,有多个always块; 有分频、计数、存储、输出等模块; 测试模块的输入输出与源程序的输入输出相反;2. 系统仿真: Verilog仿真所需仿真环境: 3.管脚配置: 1.4、 软件设计:源程序 module paobiao(clk,rst,pause,save,mg,md,bg,bd);/秒高,秒低,百分秒高,百分秒低 input clk,rst,pause,save; output reg 3:0 mg,md,bg,bd

3、;reg 15:0 zd,zz,zg;/中间变量reg 17:0 count1;reg clk1;/100msreg pause_temp,save_temp;/取上升沿reg 13:0 count2,reg0,reg1,reg2,reg3,reg4,reg5;reg 2:0 count3;/reg 1:0 state,next_state;reg cn1;parameter S0=2b00,S1=2b01,S2=2b11;/分频always (posedge clk or negedge rst) begin if(!rst) count1=0; else if(count1=) count

4、1=0;/ else count1=count1+1; end always (posedge clk ) begin if(!rst) clk1=0;else if(count1=99999) clk1=clk1;/99999else clk1=clk1;end/总计时always (negedge clk1 or negedge rst)/clk1 begin if(!rst) count2=0; else if(state=S1) count2=count2+1; / else if(state=S2) count2=count2; else count2=count2; end/存储个

5、数计数always (negedge rst or negedge save) begin if(!rst) count3=0; else if (next_state=S1) count3=count3+1; else if (next_state=S2) count3=count3-1; else count3=count3; end /毫秒低位显示结果 always (negedge rst or posedge clk) begin if(!rst) bd=0; else if(state=S1) bd=count2%10; else if(state=S2) begin case (

6、count3) 3b000: bd=reg0%10; 3b001: bd=reg1%10; 3b010: bd=reg2%10; 3b011: bd=reg3%10; 3b100: bd=reg4%10; 3b101: bd=reg5%10; default: bd=reg0%10; endcase end else bd=bd; end /毫秒高位显示结果 always (negedge rst or posedge clk) begin if(!rst) bg=0; else if(state=S1) bg=(count2/10)%10; else if(state=S2) begin c

7、ase (count3) 3b000: bg=(reg0/10)%10; 3b001: bg=(reg1/10)%10; 3b010: bg=(reg2/10)%10; 3b011: bg=(reg3/10)%10; 3b100: bg=(reg4/10)%10; 3b101: bg=(reg5/10)%10; default: bg=(reg0/10)%10; endcase end else bg=bg; end /秒位显示结果 always (negedge rst or posedge clk) begin if(!rst) md=0; else if(state=S1) md=(co

8、unt2/100)%10; else if(state=S2) begin case (count3) 3b000: md=(reg0/100)%10; 3b001: md=(reg1/100)%10; 3b010: md=(reg2/100)%10; 3b011: md=(reg3/100)%10; 3b100: md=(reg4/100)%10; 3b101: md=(reg5/100)%10; default: md=(reg0/100)%10; endcaseend else md=md; end /十秒位显示结果 always (negedge rst or posedge clk)

9、 begin if(!rst) mg=0; else if(state=S1) mg=(count2/1000)%10; else if(state=S2) begin case (count3) 3b000: mg=(reg0/100)%10; 3b001: mg=(reg1/100)%10; 3b010: mg=(reg2/100)%10; 3b011: mg=(reg3/100)%10; 3b100: mg=(reg4/100)%10; 3b101: mg=(reg5/100)%10; default: mg=(reg0/100)%10; endcase end else mg=mg;

10、end always (negedge rst or posedge clk)/定义当前状态 begin if(!rst) state=S0;/异步复位,S0为初始状态 else state=next_state; end /状态转移always (state or pause or pause_temp )begin case (state) S0:begin if(pause=0&pause_temp=1) next_state=S1; else next_state=S0; end S1:begin if(pause=0&pause_temp=1) next_state=S2; else next_state=S1;end S2:begin if(pause=0&pause_temp=1) next_state=S1; else next_state=S2;end defa

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

最新文档


当前位置:首页 > 办公文档 > 教学/培训

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