HDLBits 系列(14) Latch and Dff and Edge detect
目录
D Latch
DFF + GATE
Mux + DFF
MUX2 + DFF
FSM
JK 触发器
Edgedetect(边沿检测)
双边沿检测
D Latch
Implement the following circuit:
这是一个锁存器,高电平跟随,低电平保持,于是设计:
module top_module (input d, input ena,output q);always@(*)beginif(ena) q = d;else ;endendmodule
DFF + GATE
Implement the following circuit:
module top_module (input clk,input in, output out);always@(posedge clk) beginout <= in ^ out;endendmodule
Mux + DFF
Taken from ECE253 2015 midterm question 5
Consider the sequential circuit below:
Assume that you want to implement hierarchical Verilog code for this circuit, using three instantiations of a submodule that has a flip-flop and multiplexer in it. Write a Verilog module (containing one flip-flop and multiplexer) named top_module for this submodule.
假设您要使用其中具有触发器和多路复用器的子模块的三个实例化来为此电路实现分层的Verilog代码。 为此子模块编写一个名为top_module的Verilog模块(包含一个触发器和多路复用器)。
要求写出其中一个子模块即可:
module top_module (input clk,input L,input r_in,input q_in,output reg Q);wire mid;assign mid = L ? r_in : q_in;always@(posedge clk) beginQ <= mid;endendmodule
其实读者应该自己用例化的方式,把整个电路实现了。
MUX2 + DFF
Consider the n-bit shift register circuit shown below:
Write a Verilog module named top_module for one stage of this circuit, including both the flip-flop and multiplexers.
module top_module (input clk,input w, R, E, L,output Q
);reg Q;wire mid1, mid2;assign mid1 = E ? w : Q;assign mid2 = L ? R : mid1;always@(posedge clk) beginQ <= mid2;endendmodule
FSM
Given the finite state machine circuit as shown, assume that the D flip-flops are initially reset to zero before the machine begins.
Build this circuit.
module top_module (input clk,input x,output z
);
reg q1, q2, q3;
always@(posedge clk) beginq1 <= q1 ^ x;q2 <= ~q2 & x;q3 <= ~q3 | x;
endassign z = ~(q1 | q2 | q3);endmodule
JK 触发器
A JK flip-flop has the below truth table. Implement a JK flip-flop with only a D-type flip-flop and gates. Note: Qold is the output of the D flip-flop before the positive clock edge.
J | K | Q |
---|---|---|
0 | 0 | Qold |
0 | 1 | 0 |
1 | 0 | 1 |
1 | 1 | ~Qold |
module top_module (input clk,input j,input k,output Q); always@(posedge clk) beginif(~j & ~k) Q <= Q;else if(j&k) Q <= ~Q;else if(~j & k) Q <= 0;else Q <= 1;endendmodule
Edgedetect(边沿检测)
For each bit in an 8-bit vector, detect when the input signal changes from 0 in one clock cycle to 1 the next (similar to positive edge detection). The output bit should be set the cycle after a 0 to 1 transition occurs.
Here are some examples. For clarity, in[1] and pedge[1] are shown separately.
对于8位向量中的每个位,检测输入信号何时从一个时钟周期的0变为下一时钟周期的1(类似于上升沿检测)。 输出位应在发生0到1转换后的周期内进行设置。
这里有些例子。 为了清楚起见,分别显示了in [1]和pedge [1]。
module top_module (input clk,input [7:0] in,output [7:0] pedge
);reg [7:0] in_r1, in_r2;always@(posedge clk) beginin_r1 <= in;in_r2 <= in_r1;endassign pedge = ~in_r2 & in_r1;endmodule
双边沿检测
For each bit in an 8-bit vector, detect when the input signal changes from one clock cycle to the next (detect any edge). The output bit should be set the cycle after a 0 to 1 transition occurs.
Here are some examples. For clarity, in[1] and anyedge[1] are shown separately
module top_module (input clk,input [7:0] in,output [7:0] anyedge
);reg [7:0] in_r1, in_r2;always@(posedge clk) beginin_r1 <= in;in_r2 <= in_r1;endassign anyedge = in_r2 ^ in_r1;endmodule
HDLBits 系列(14) Latch and Dff and Edge detect相关推荐
- HDLBits 系列(0)专题目录
本篇博文是近来总结HDLBits系列的目录,点击蓝色字体即可进入查看具体内容. HDLBits 系列(1)从HDLBits中获取灵感,整顿自己,稳步前行 HDLBits 系列(2)如何避免生成锁存器? ...
- HDLBits 系列(31)Serial Receiver and Datapath
目录 序言 原题复现 我的设计 序言 上篇博文: HDLBits 系列(30)Serial Receiver 写了串行接收器如何接收8位串行数据,正确接收8位串行数据后给一个接收完毕标志信号,这篇博文 ...
- python平稳性检验_时间序列预测基础教程系列(14)_如何判断时间序列数据是否是平稳的(Python)...
时间序列预测基础教程系列(14)_如何判断时间序列数据是否是平稳的(Python) 发布时间:2019-01-10 00:02, 浏览次数:620 , 标签: Python 导读: 本文介绍了数据平稳 ...
- SAP PM 初级系列14 - 维修工单的凭证流
SAP PM 初级系列14 - 维修工单的凭证流 众所周之,SAP系统非常讲究单据之间的LINK关系.很多单据,都是通过凭证流,或者relationship browser等按钮或者菜单,来查询这些单 ...
- SAP PM 入门系列14 – PM模块与其它模块的集成
SAP PM 入门系列14 – PM模块与其它模块的集成 SAP PM与其他模块(如物料管理,生产计划,人事管理以及销售和分销)都有高度紧密的集成.以下是使用Plant Maintenance进行集成 ...
- HDLBits 系列(29)PS/2 mouse protocol(PS/2 packet parser and datapath)
目录 序言 原题传送 题目解释 我的设计 序言 上篇博客: HDLBits 系列(28)PS/2 mouse protocol(PS/2 packet parser) 只对PS/2 mouse pro ...
- C# 视频监控系列(14):总结贴——VC++代码转成C#小结
前言 关键字:c++ to C# 原计划是再写一篇H264播放器转换AVI的文章才开始写总结的,至今未能成功,由于时间问题并且也暂时没有这个需求,所以决定从原计划中去掉这一章节直接进入总结贴,然后结束 ...
- ASP.NET MVC+EF框架+EasyUI实现权限管理系列(14)-主框架搭建
ASP.NET MVC+EF框架+EasyUI实现权限管理系列(14)-主框架搭建 原文:ASP.NET MVC+EF框架+EasyUI实现权限管理系列(14)-主框架搭建 ASP.NET MV ...
- c# 找出目录下的所有子目录_C# 基础知识系列- 14 IO篇 文件的操作(2)
前接上一篇内容. 如果是第一次捧场的小伙伴,为了您阅读的连贯性,烦请扫一眼<C# 基础知识系列- 14 IO篇 文件的操作(1)>.本篇是IO之文件操作的第二篇,介绍一下目录和路径的相关类 ...
最新文章
- 危机时保路人还是保乘客?无人车伦理困境背后:谁来制定算法规则
- redis java对象操作
- scala:对象object
- sql server死锁_SQL Server死锁定义和概述
- 学完之后,有什么证书发吗?要另外收费吗?收费多少? 学员每天的上课时间是怎样安排的?...
- 减法运算的借位标志cf_数学|有理数运算法则及题型汇总
- vue教程1-03 v-for循环
- winform npoi 将execl转换成datatable,导入数据库
- 【线性代数】20 基变换,基变换公式,坐标变换公式
- 嵌入式软件工程师总结(1)
- 大一计算机期末考试操作题word,Word大一计算机考试操作题
- typecho博客,typecho插件,typecho博客搭建
- matlab 不显示图中的x,y轴
- UFR II、PCL、PostScript打印机驱动区别
- vertica 数据库 linux,CentOS 7下安装vertica记录
- 体验魅力Cognos BI 10 系列,第1 部分: 第一次安装
- 【转】为什么需要异步
- c语言点阵式注释语句,LED点阵显示与C语言编程(基础篇)_希希_百度空间
- 群辉 RAID1 数据恢复小记
- Ubuntu安装使用SVN
热门文章
- ASP.NET State Service
- 难道这又是个未解之谜?--- 关于DLL中使用ADODATASET出错的问题
- VC++ .NET 2003学习
- wxml 点击图片下载_微信小程序通过ipfs-api 实现图片文件在私有ipfs网络的上传与下载显示...
- python线程暂停恢复退出_python中的暂停和恢复线程
- mysql sp cursoropen_三个重要的游标sp_cursoropen_MySQL
- java中继承和多态的实验,Java中的继承和多态
- javca中redis获取value_接口测试:如何从redis中获取短信验证码
- 自带浏览器_三星手机自带浏览器下载量突破 10 亿次
- Chrome开发者工具详解(2)-Network面板