当前位置:网站首页>Verilog daily question (vl27 settable counter)
Verilog daily question (vl27 settable counter)
2022-07-28 17:22:00 【Don't make any more errors】
Title Description
Please write a hexadecimal counter module , The counter output signal is incremented every time it reaches 0, Give an indication signal zero, When the set signal set Is valid , Set the current output as the input value set_num.
The interface signal diagram of the module is as follows :


Ideas : I can't see clearly in this oscillogram , actually rst_n Set up 1 after num For the first 0, Change again 1, I didn't pay attention to this at first, and I don't know why I was wrong . So the output number There must be a delay of one cycle .
Here we add an intermediate counter num To postpone the clock , When num<=num+1 when ,number <=num, because always Blocks are parallel , So at this time number assignment num, Nonblocking assignment num<=num+1 A simultaneous , And at this time num=0;
Thought of expansion , If you add another num2<=number, The assignment will be delayed by another cycle . You can add intermediate variables to increase the delay .
( This method can be recorded )
The rest of the idea is simple ,num=0 when zero=1,num from 0-15 loop .
`timescale 1ns/1ns
module count_module(
input clk,
input rst_n,
input set,
input [3:0] set_num,
output reg [3:0]number,
output reg zero
);
reg [3:0]num;
always @(posedge clk or negedge rst_n)begin
if (!rst_n) zero <= 1'd0;
else if (num == 0) zero <= 1;
else zero <= 1'b0;
end
always @(posedge clk or negedge rst_n) begin
if (!rst_n) num <= 4'b0;
else if(set) num <= set_num;
else num <= num + 1'd1;
end
always @(posedge clk or negedge rst_n) beign
if (!rst_n) number <= 1'd0;
else number <= num;
end
endmodule边栏推荐
- 微服务架构-服务注册中心和服务网关(6.8) (转载)
- Ugui learning notes (V) togglegroup makes multiple choice radio boxes
- 浏览器解码过程分析
- The maximum recommended number of rows for MySQL is 2000W. Is it reliable?
- Code implementation additive attention
- mysql 最大建议行数2000w,靠谱吗?
- The 16th program design competition of Dalian University of Technology (Problem Solver)
- Goweb开发之Iris框架实战:项目总结与回顾
- Codeforces round 770 (Div. 2) e. fair share
- The practice of beego framework developed by goweb: Section 4 database configuration and connection
猜你喜欢

Realization of reflection and refraction effect in unity shader cube texture

微服务架构-服务注册中心和服务网关(6.8) (转载)

Classroom attendance system based on QT design (using RDS for MySQL cloud database)

Verilog daily question (vl29 single port RAM)

Verilog 每日一题(VL26 简易秒表)

高速电路中电感的选型和应用

Visual Studio 2015 团队开发之Azure DevOps篇

火了 2 年的服务网格究竟给微服务带来了什么?(转载)

Unity editor learning (I) using features to change the display of fields in components

Unity3d shader achieves ablation effect
随机推荐
Leetcode 2022.04.10 China Merchants Bank special competition D. store promotion (DP)
Algorithm learning: leetcode interview question 09. implement queue with two stacks
解决SQL Server数据库独占的问题
Steps to configure V530 switch
System clock failure of database fault tolerance
线性代数及矩阵论(八)
Ugui learning notes (VI) get the information of the clicked UI
Games101 assignment04 job 04
CNSA与CASC和CASIC的区别
Unity shader procedural texture
Unity shader realizes water wave effect with noise texture
Using MVC in the UI of unity
配置V530交换机步骤
Round 1A 2022 - Code jam 2022 c.weightlifting (interval DP)
Introduction to vscade interface
Cf/atc/lc topic score website
The actual combat of the beego framework of goweb development: Section III program execution process analysis
堡垒机的作用
Analysis of kubernetes service principle
Unity shader screen post-processing