当前位置:网站首页>Verilog daily question (vl28 plus and minus counter)
Verilog daily question (vl28 plus and minus counter)
2022-07-28 17:22:00 【Don't make any more errors】
Title Description
Please write a decimal counter module , When mode The signal is 1, The counter output signal is incremented , When mode The signal is 0, The counter output signal decreases . Every time I arrive 0, Give an indication signal zero.
The interface signal diagram of the module is as follows :


There is a problem with the waveform here , When the first rising edge comes , Already started adding one , there num It's an intermediate counter ,number Being assigned will slow down , But it can't be seen ... The question of niuke.com is really , still HDLbits Have fun .
After considering this , It's easy . The specific problem-solving process is as follows :
`timescale 1ns/1ns
module count_module(
input clk,
input rst_n,
input mode,
output reg [3:0]number,
output reg zero
);
reg [3:0] num; // Make a statement reg Variables as intermediate counts
always @(posedge clk or negedge rst_n) begin
if(!rst_n) num <= 0 ;
else if(num==9&&mode==1) num<=0; // Want to consider num=9 Continue to increase time-varying 0 The situation of
else if(num==0&&mode==0) num<=9; // Want to consider num=0 Continue to reduce time variation 9 The situation of
else if(mode==1) num<=num+1; //mode Control addition and subtraction
else if(mode==0) num<=num-1;
end
always @(posedge clk or negedge rst_n) begin
if(!rst_n) number <= 0; // take num Assign a value to number
else number <= num;
end
always @(posedge clk or negedge rst_n) begin
if(!rst_n) zero = 0;
else if(num==0) zero <= 1;
else zero <= 0;
end
endmodule
边栏推荐
- Realize the reset function of steering wheel UI with touch rotation and finger departure in unity
- C # traversal set
- The practice of the beego framework of goweb development: Section II project initialization configuration
- 批量下载文件
- Verilog 每日一题 (VL24 多bit MUX同步器 跨时域输出)
- Andthen of function interface
- Microservice Architecture - service registry and service gateway (6.8) (Reprint)
- Goweb开发之Beego框架实战:第四节 数据库配置及连接
- kubernetes service 原理解析
- : No such file or directory
猜你喜欢

飞马D200S无人机与机载激光雷达在大比例尺DEM建设中的应用

System clock failure of database fault tolerance

格雷码和二进制的转换及典型例题(4bits格雷码计数器)

我为什么选择使用Go语言?

Easypoi multi sheet export by template

连接设计与测试平台——SystemVerilog 接口知识点总结

How to protect image security during construction

在android开发过程中遇到.sqlite文件处理

DGL Chapter 1 (official tutorial) personal notes

Shopee code League 2022 - qualification round p3.connecting the numbers (segment tree / bipartite graph determination, to be discussed)
随机推荐
Round 1C 2022 - Code jam 2022 b.square (Mathematics, thinking)
批量下载文件
The longest substring of sword finger offer without repeated characters
MySQL详细学习教程(建议收藏)
Learn about service discovery in kubernetes
Unity shader transparent effect
Microservice Architecture - service registry and service gateway (6.8) (Reprint)
飞马D200S无人机与机载激光雷达在大比例尺DEM建设中的应用
Verilog 每日一题(VL4 移位运算与乘法)
C#遍历集合
Steps to configure V530 switch
Codeforces round 770 (Div. 2) e. fair share
Verilog 每日一题 (VL27 可置位计数器)
net框架
Unity3d simple implementation of water surface shader
Application of Pegasus d200s UAV and airborne lidar in large-scale DEM construction
Solve the problem of exclusive SQL Server database
Unity3d shader achieves ablation effect
Visual Studio 2015 团队开发之Azure DevOps篇
Azure Devops developed by visual studio 2015 team