当前位置:网站首页>Verilog——74LVC161计数器
Verilog——74LVC161计数器
2022-07-21 16:59:00 【爱学习的岳岳】
设计思路
根据功能表进行行为级建模,如下:
代码实现
设计模块
//filename:_74LVC161.v
module _74LVC161(
input CR,PE,CEP,CET,CP,
input [3:0] D,
output reg [3:0] Q,
output reg TC);
/* 参数说明: 输入: CR位置零输入端,PE为预置,CEP,CET为控制信号,CP为时钟信号,D为预置信号 输出: Q为输出端 TC进位信号 */
[email protected](posedge CP,negedge CR)
begin
if(~CR) begin Q<=4'b0000;TC=0; end //异步清零信号的优先级最高
else if(~PE) Q<=D; //预置信号
else
casex({
CEP,CET}) //使能信号
2'b0x: Q<=Q; //保持
2'bx0:begin Q<=Q; TC=0; end //保持
2'b11:begin Q=Q+1'b1; TC=(Q==4'b1111); end //计数
endcase
end
endmodule
测试模块
filename:tb_74LVC161.v
`timescale 1ns/1ns
module tb_74LVC161();
reg CR,PE,CEP,CET,CP;
reg [3:0] D;
wire [3:0] Q;
wire TC;
/* 参数说明: 输入: CR位置零输入端,PE为预置,CEP,CET为控制信号,CP为时钟信号,D为预置信号 输出: Q为输出端 TC进位信号 */
always
_74LVC161 U(CR,PE,CEP,CET,CP,D,Q,TC);
initial
$monitor($time,"\tCR=%b,PE=%b,CEP=%b,CET=%b,CP=%b,D=%b,Q=%b,TC=%b",CR,PE,CEP,CET,CP,D,Q,TC);
//时钟信号
initial
CP=1;
always
#5 CP=~CP;
//元件例化
initial
begin
//清零
CR=0;PE=1;D=4'b1100;CET=0;CEP=0;
#5;
//置数
CR=1;PE=0;D=4'b1100;CET=0;CEP=0;
#10;
//计数
CR=1;PE=1;D=4'b0000;CET=1;CEP=1;
#60;
//禁止计数
CR=1;PE=1;D=4'b0000;CET=1;CEP=0;
#20;
$stop;
end
endmodule
仿真结果
边栏推荐
猜你喜欢
AirFlow的Scheduling的start_date解释
原码一位乘法器
在 EXCEL 中,“插入已剪切单元格”的快捷键
生产环境TiDB集群缩容TiKV操作步骤
力扣每日一题(1)
Fast Fourier transform, Lagrange interpolation, three thousand words with examples, sister chapters, application of FFT and string matching
IDEA 如何自动导入(import)
Generating function (linear recursive relationship, generating function concept and formula derivation, violent calculation) 4000 word detailed analysis, with examples
如何在浏览器中使用 Blob 对象进行缓存
Unified payment callback interface of Alipay (applicable to H5, PC and APP)
随机推荐
在瑞达期货开户安全吗?怎么开户?
原码一位乘法器
Extjs4实例地址和中文文档地址
AttributeError:module ‘distutils’ has no attribute ‘version错误解决方法
服务器中激活刚安装好的anaconda
SSM project complete source code [easy to understand]
一个公用的dao类和util
R language ggplot2 visualization: visualize the scatter diagram, add formula labels to the data points in the scatter diagram, and use geom of ggrep package_ text_ The repl function avoids overlapping
R language uses oneway The test function performs one-way ANOVA. If there is the same variance between groups, set the var.equal parameter to true to obtain a more relaxed test
架构师进阶,微服务设计与治理的 16 条常用原则
p[0]作为for循环的判断条件
服务器切换不同的conda环境以及查看各个用户进程
[case design] event distributor - sharing and implementation of cross class event response ideas
Data sharing | simple temperature and humidity detection simulation based on SHT11
excel 如何根据身份证号自动匹配性别代码
Anaconda安装jupyter lab + jupyterlsp(代码提示,代码纠错)详细搭建过程
资料分享|HC-05蓝牙模块资料
Matrix multiplication and division of two elements "suggestions collection"
生成函数(线性递推关系,生成函数概念与公式推导,暴力计算)四千字详细解析,附例题
小波变换中的多贝西小波(DB小波函数)概述