EDA课程设计报告--基于Verilog DHL自动售票系统的实现.pdf
文本预览下载声明
基于Verilog HDL 自动售票系统的实现
·设计目标:
本设计完成基于Verilog HDL 的自动售票系统,综合软件用Quartus II8.1 。
本自动售票系统可以完成1 元、2 元、3 元、4 元四种票的自动售出,货币种
类可以是1 元、5 元、10 元、50 元、100 元,能自动找零和显示
·总体设计:
共有四个主要模块和一个顶层模块:四个模块分别是主控模块、统计模块、
出票模块和找零模块;顶层模块负责各模块间的连接,组成一个可用的自动售票
系统。
总体结构如下:
需票
输入货币 统计模块
总钱数
余额显示
控制信号 主控模块
需票 找零数
找零模块
出票
模块
自动售票系统顶层模块
·各模块设计:
统计模块:
根据各种货币输入,统计出总钱数提供给主控模块。每次售票完成后总钱数
自动归零(主控模块提供售票完成信号,计数清零)
代码如下:
module count ( rst, //复位 高有?
clr,
ci1,ci5,ci10,ci50,ci100, //1 元、5 元、10 元、50 元、100 元输入
cout //统计出的总钱数
);
input rst;
input clr; //清零信号
input ci1,ci5,ci10,ci50,ci100; //高脉冲有?
output [7:0] cout;
reg [2:0] q1,q5,q10,q50,q100;
assign cout = q1 + 5*q5 + 10*q10 + 50*q50 + 100*q100;
//一元计数
always @ (posedge rst or posedge clr or posedge ci1)
begin
if(rst==1) q1 = 0;
else if(clr==1) q1 = 0;
else
begin
q1 = q1 + 1;
end
end
//5 元计数
always @ (posedge rst or posedge clr or posedge ci5)
begin
if(rst==1) q5 = 0;
else if(clr==1) q5 = 0;
else
begin
q5 = q5 + 1;
end
end
//10 元计数
always @ (posedge rst or posedge clr or posedge ci10)
begin
if(rst==1) q10 = 0;
else if(clr==1) q10 = 0;
else
begin
q10 = q10 + 1;
end
end
//50 元计数
always @ (posedge rst or posedge clr or posedge
显示全部