当前位置:网站首页>基于Verilog HDL的数字秒表
基于Verilog HDL的数字秒表
2022-07-24 22:44:00 【不认得学霸】
工具:quartus18.1 lite
代码
module biao_v(clk,reset,pause,msh,msl,sh,sl,minh,minl);
//其中msh为百分秒的十位,msl为百分秒的个位,sh为秒的十位,sl为秒的个位,minh为分的十位,minl为分的个位
input clk,reset,pause;//时钟,复位,暂停
output [3:0] msh,msl,sh,sl,minh,minl;//输出
reg [3:0] msh,msl,sh,sl,minh,minl;//寄存器
reg count1,count2;//寄存器
//设置百分秒
always @(posedge clk or posedge reset)//时钟上升沿或复位上升沿
begin
if(reset)//信号为复位时
begin
{msh,msl}<=0;//百分秒十位和百分秒个位赋0
count1<=0;//寄存器count1赋0
end
else if(!pause)//信号不是复位不是暂停时
begin
if(msl==9)//如果百分秒个位为9
begin
msl<=0;//百分秒个位赋0
if(msh==9)//如果百分秒十位为9
begin
msh<=0;//百分秒十位赋0
count1<=1;//寄存器count1赋1
end
else//如果百分秒十位不为9
msh<=msh+1;//百分秒十位加1
end
else//如果百分秒个位不为9
begin
msl<=msl+1;//百分秒个位加1
count1<=0;//寄存器coount1赋0
end
end
end
//设置秒
always @(posedge count1 or posedge reset)//信号为寄存器count1上升沿或复位上升沿时
begin
if(reset)//信号为复位
begin
{sh,sl}<=0;//秒的十位和个位赋0
count2<=0;//寄存器count2赋0
end
else if(sl==9)//秒的个位为9
begin
sl<=0;//秒个位赋0
if(sh==5)//秒十位为5
begin
sh<=0;//秒十位赋0
count2<=1;//寄存器count2赋1
end
else //秒十位不为5
sh<=sh+1;//秒十位加1
end
else//秒个位不为9
begin
sl<=sl+1;//秒个位加1
count2<=0;//寄存器count2赋0
end
end
//设置分
[email protected](posedge count2 or posedge reset)//寄存器count2上升沿或复位上升沿
begin
if(reset)//信号为复位
begin
minh<=0;//分十位赋0
minl<=0;//分个位赋0
end
else if(minl==9)//信号为分个位为9
begin
minl<=0;//分个位赋0
if(minh==5)//分十位为5
minh<=0;//分十位赋0
else//分十位不为5
minh<=minh+1;//分十位加1
end
else//分个位不为9也不是复位
minl<=minl+1;//分个位加1
end
endmodule
结果
从功能仿真结果可以看到,只有百分秒十位个位发生了变化
事实上我自己对这个程序一知半解的,不太了解具体的原理

参考:https://blog.csdn.net/qq_43643118/article/details/117031719
边栏推荐
- 【1184. 公交站间的距离】
- 价值驱动为商业BP转型提供核心动力——业务场景下的BP实现-商业BP分享
- Gee - dataset introduction mcd12q1
- 图结构的实现,从点到边再到图
- Talk about how redis handles requests
- [cloud native kubernetes] kubernetes cluster advanced resource object staterulesets
- Trinitycore worldofwarcraft server - registration website
- Solve the problem that JSP cannot use session.getattribute()
- Moving least squares fitting experiment of PCL point cloud processing (62)
- 网上怎么炒股手机上炒股安全吗
猜你喜欢

Multi task face attribute analysis based on deep learning (based on paddlepaddle)

From violent recursion to dynamic programming, memory search

Time series data in industrial Internet of things

Icassp 2022 | KS transformer for multimodal emotion recognition

What is a video content recommendation engine?

认识复杂度和简单排序运算

生成式对抗网络的效果评估

Segment tree,,

Network Security Learning (I) virtual machine

Network Security Learning (V) DHCP
随机推荐
Pointrender parsing
Kubernetes scheduling concept and workflow
Network Security Learning (V) DHCP
聊聊 Redis 是如何进行请求处理
HLS编程入门
From violent recursion to dynamic programming, memory search
Old Du servlet JSP
PCD file of PCL point cloud processing to TXT file (single or multiple batch conversion) (63)
DDos攻击分类
Cross entropy loss
VC prompts to recompile every time you press F5 to run
10 key points and 5 measures for good project management
Icassp 2022 | KS transformer for multimodal emotion recognition
《JUC并发编程 - 高级篇》05 -共享模型之无锁 (CAS | 原子整数 | 原子引用 | 原子数组 | 字段更新器 | 原子累加器 | Unsafe类 )
Available parameters of ansible Playbook
The specified data is grouped and the number of repetitions is obtained in Oracle
Ranking of engineering project management software
Okaleido tiger NFT is about to log in to binance NFT platform, and the future market continues to be optimistic
RichTextBox save as picture
Use kettle to read the data in Excel file and store it in MySQL