当前位置:网站首页>Digital stopwatch based on Verilog HDL
Digital stopwatch based on Verilog HDL
2022-07-24 22:55:00 【Don't recognize Xueba】
Tools :quartus18.1 lite
Code
module biao_v(clk,reset,pause,msh,msl,sh,sl,minh,minl);
// among msh It is the ten digits of the hundredth of a second ,msl Is a bit of a hundredth of a second ,sh Is the ten digits of the second ,sl Is a bit of second ,minh Ten points ,minl Is divided into two digits
input clk,reset,pause;// The clock , Reset , Pause
output [3:0] msh,msl,sh,sl,minh,minl;// Output
reg [3:0] msh,msl,sh,sl,minh,minl;// register
reg count1,count2;// register
// Set hundredths of a second
always @(posedge clk or posedge reset)// Clock rising edge or reset rising edge
begin
if(reset)// When the signal is reset
begin
{msh,msl}<=0;// Ten bits per hundredth of a second and one bit per hundredth of a second 0
count1<=0;// register count1 Fu 0
end
else if(!pause)// When the signal is not reset, not pause
begin
if(msl==9)// If the hundredth of a second is 9
begin
msl<=0;// Hundredths of a second 0
if(msh==9)// If the tenth digit of a hundredth of a second is 9
begin
msh<=0;// Ten bits per hundredth of a second 0
count1<=1;// register count1 Fu 1
end
else// If the tenth digit of a hundredth of a second is not 9
msh<=msh+1;// Ten digits of a hundredth of a second plus 1
end
else// If the hundredth of a second is not 9
begin
msl<=msl+1;// One hundredth of a second plus 1
count1<=0;// register coount1 Fu 0
end
end
end
// Set seconds
always @(posedge count1 or posedge reset)// The signal is a register count1 Rising edge or reset rising edge
begin
if(reset)// The signal is reset
begin
{sh,sl}<=0;// Ten bits and one bit of the second 0
count2<=0;// register count2 Fu 0
end
else if(sl==9)// The bits of seconds are 9
begin
sl<=0;// Second bit assignment 0
if(sh==5)// The tenth digit of a second is 5
begin
sh<=0;// Ten bits per second 0
count2<=1;// register count2 Fu 1
end
else // Ten seconds is not 5
sh<=sh+1;// Ten seconds plus 1
end
else// The second bit is not 9
begin
sl<=sl+1;// Seconds plus 1
count2<=0;// register count2 Fu 0
end
end
// Set points
[email protected](posedge count2 or posedge reset)// register count2 Rising edge or reset rising edge
begin
if(reset)// The signal is reset
begin
minh<=0;// Ten Fu 0
minl<=0;// Sub position Fu 0
end
else if(minl==9)// The signal is divided into bits 9
begin
minl<=0;// Sub position Fu 0
if(minh==5)// Ten points are 5
minh<=0;// Ten Fu 0
else// Ten is not 5
minh<=minh+1;// Ten points plus 1
end
else// It's not 9 Nor is it reset
minl<=minl+1;// Divide by one and add 1
end
endmodule
result
From the functional simulation results, we can see , Only ten bits per hundredth of a second have changed
In fact, I know a little about this program myself , I don't know much about the specific principle 

Reference resources :https://blog.csdn.net/qq_43643118/article/details/117031719
边栏推荐
- Which is the best interface documentation tool at home and abroad?
- Notes of Teacher Li Hongyi's 2020 in-depth learning series lecture 1
- Can the income of CICC securities' new customer financial products reach 6%? How to open an account?
- 【零基础】php代码审计之sql注入
- [cloud native] Devops (IV): integrated sonar Qube
- VC prompts to recompile every time you press F5 to run
- 用VS Code搞Qt6:编译源代码与基本配置
- IP first experiment hdcl encapsulates PPP, chap, mGRE
- 物联网平台返回数据解析时遇到org.json.JSONException: No value for Value怎么办
- Application programming of communication heartbeat signal for communication abnormality judgment
猜你喜欢
![Luogu p2024 [noi2001] food chain](/img/7f/6ccbc19942f0d4a153025346496834.png)
Luogu p2024 [noi2001] food chain

Use kettle to read the data in Excel file and store it in MySQL

老杜Servlet-JSP

IndexTree

Baidu online disk +chrome plug-in

Implementation of graph structure, from point to edge and then to graph

The rule created by outlook mail is invalid. Possible reasons

QT6 with vs Code: compiling source code and basic configuration

一文读懂Elephant Swap的LaaS方案的优势之处

《ArchSummit:珍爱微服务底层框架演进》
随机推荐
中金证券新课理财产品的收益有百分之六吗?我想要开户理财
Violent recursion - detailed explanation of Queen n & how to optimize with bit operation
聊聊 Redis 是如何进行请求处理
Understanding complexity and simple sorting operation
Icassp 2022 | KS transformer for multimodal emotion recognition
Network Security Learning (IV) user and group management, NTFS
Solve the problem that JSP cannot use session.getattribute()
Some analysis of slow MySQL query
物联网平台返回数据解析时遇到org.json.JSONException: No value for Value怎么办
Backgroundworker enables time-consuming operations without affecting interface response
Luogu p2024 [noi2001] food chain
Talk about how redis handles requests
Ranking of engineering project management software
TrinityCore魔兽世界服务器-注册网站
HLS编程入门
10 key points and 5 measures for good project management
Read and understand the advantages of the LAAS scheme of elephant swap
AVL tree of ordered table
Get the solution to the slow running speed of Mengxin Xiaobai computer! ٩ ( ‘ ω‘ )و get! ٩ ( ‘ ω‘ )و
Network Security Learning (V) DHCP