当前位置:网站首页>基于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
边栏推荐
- QT6 with vs Code: compiling source code and basic configuration
- 洛谷 P2024 [NOI2001] 食物链
- 【1184. 公交站间的距离】
- 激光雷达障碍物检测与追踪实战——cuda版欧式聚类
- How to adjust the default output of vscode to the debugging console to the terminal and the problem of garbled code in both
- Luogu p2024 [noi2001] food chain
- 先工程实践,还是先工程思想?—— 一位本科生从学oi到学开发的感悟
- 线段树,,
- 如何创建和管理自定义的配置信息
- Backgroundworker enables time-consuming operations without affecting interface response
猜你喜欢

Nvida tensorrt deployment (I)

Morris traversal

Get the solution to the slow running speed of Mengxin Xiaobai computer! ٩ ( ‘ ω‘ )و get! ٩ ( ‘ ω‘ )و

Outlook邮件创建的规则失效,可能的原因

Some analysis of slow MySQL query
![[database learning] redis parser & single thread & Model](/img/70/c84eb02d45e35fede4dd1b1ff04392.png)
[database learning] redis parser & single thread & Model

阿里云SSL证书

Okaleido tiger NFT即将登录Binance NFT平台,后市持续看好

"Yuan universe 2086" outsold "San ti" in one-day sales and won the champion of JD books' one-day science fiction list

Talk about how redis handles requests
随机推荐
Monotonic stack structure
新手哪个证券开户最好 开户最安全
WPF opens external programs and activates them when needed
DDos攻击分类
Projection regularization of line point set in PCL point cloud processing (56)
Background image and QR code synthesis
Moving least squares fitting experiment of PCL point cloud processing (62)
General syntax and classification of SQL language (II)
About constant modifier const
IndexTree2D
Glidemodule appglidemodule and generated API details
QT6 with vs Code: compiling source code and basic configuration
On the open and closed principle
力扣 1184. 公交站间的距离
Update structure of maximum or minimum value in the window - maximum value in the window
《ArchSummit:珍爱微服务底层框架演进》
IP first experiment hdcl encapsulates PPP, chap, mGRE
[cloud native kubernetes] kubernetes cluster advanced resource object staterulesets
生成式对抗网络的效果评估
TrinityCore魔兽世界服务器-注册网站