当前位置:网站首页>【牛客网刷题系列 之 Verilog进阶挑战】~ 多bit MUX同步器
【牛客网刷题系列 之 Verilog进阶挑战】~ 多bit MUX同步器
2022-07-07 17:06:00 【AI很不错呦】
目录:
0. 前言
有几天没更新牛客刷题的博客了,最近有事在忙,只能尽量做到每天一更了!!!一边刷题,一边做点小demo,不断学习。
今天这个题主要是一个跨时钟域的多位数据传输,也是比较常见的一种题型,挺有用的,关于跨时钟域怎么处理,可以移步到我之前写的一篇博客,传送门
1. VL48 多bit MUX同步器
1.1 题目描述
在data_en为高期间,data_in将保持不变,data_en为高至少保持3个B时钟周期。表明,当data_en为高时,可将数据进行同步。
本题中data_in端数据变化频率很低,相邻两个数据间的变化,至少间隔10个B时钟周期。
1.1.1 信号示意图


1.1.2 波形示意图
无
1.1.3 输入描述
input clk_a ,
input clk_b ,
input arstn ,
input brstn ,
input [3:0] data_in ,
input data_en
1.1.4 输出描述
output reg [3:0] dataout
1.2 解题思路
我们根据题意大概框架如下:
其中,红色框框表示的是数据暂存 以及 使能暂存;蓝色框框表示跨时钟域处理,采用打两拍的形完成;绿色框框表示MUX选择以及暂存的结果输出。
1.3 代码实现
`timescale 1ns/1ns
module mux(
input clk_a ,
input clk_b ,
input arstn ,
input brstn ,
input [3:0] data_in ,
input data_en ,
output reg [3:0] dataout
);
//暂存data_en
reg data_en_reg;
always @ (posedge clk_a or negedge arstn) begin
if(!arstn) begin
data_en_reg <= 1'b0;
end
else begin
data_en_reg <= data_en;
end
end
//data_in
reg [3:0] data_in_reg;
always @ (posedge clk_a or negedge arstn) begin
if(!arstn) begin
data_in_reg <= 4'd0;
end
else begin
data_in_reg <= data_in;
end
end
//打两拍,跨时钟域过渡
reg data_en_ab1, data_en_ab2;
always @ (posedge clk_b or negedge brstn) begin
if(!brstn) begin
data_en_ab1 <= 1'b0;
data_en_ab2 <= 1'b0;
end
else begin
data_en_ab1 <= data_en_reg;
data_en_ab2 <= data_en_ab1;
end
end
// MUX
always @ (posedge clk_b or negedge brstn) begin
if(!brstn) begin
dataout <= 4'd0;
end
else begin
dataout <= data_en_ab2 ? data_in_reg : dataout;
end
end
endmodule
1.4 测试文件
待更新。。。
1.5 仿真波形
待更新。。。
声明
本人所有系列的文章,仅供学习,不可商用,如有侵权,请告知,立删!!!
本人主要是记录学习过程,以供自己回头复习,再就是提供给后人参考,不喜勿喷!!!
如果觉得对你有用的话,记得收藏+评论!!!
边栏推荐
- Golang client server login
- Realize payment function in applet
- "Decryption" Huawei machine vision Corps: Huawei is moving up and the industry is moving forward
- AI来搞财富分配比人更公平?来自DeepMind的多人博弈游戏研究
- testing and SQA_动态白盒測试[通俗易懂]
- 微信网页调试8.0.19换掉X5内核,改用xweb,所以x5调试方式已经不能用了,现在有了解决方案
- Short selling, overprinting and stock keeping, Oriental selection actually sold 2.66 million books in Tiktok in one month
- Learn open62541 -- [67] add custom enum and display name
- Three forms of multimedia technology commonly used in enterprise exhibition hall design
- Numpy——2.数组的形状
猜你喜欢

DeSci:去中心化科学是Web3.0的新趋势?

Former richest man, addicted to farming

Redis cluster and expansion

Zhong Xuegao wants to remain innocent in the world

Tsinghua, Cambridge and UIC jointly launched the first Chinese fact verification data set: evidence-based, covering many fields such as medical society

gsap动画库

企业展厅设计中常用的三种多媒体技术形式

【塔望方法论】塔望3W消费战略 - U&A研究法

2022.07.04

CVPR 2022 - learning non target knowledge for semantic segmentation of small samples
随机推荐
Basic operation of chain binary tree (implemented in C language)
Big Ben (Lua)
POJ 1182 :食物链(并查集)[通俗易懂]
PTA 1102 教超冠军卷
2022.07.04
GSAP animation library
我感觉被骗了,微信内测 “大小号” 功能,同一手机号可注册两个微信
Hongmeng smart home [1.0]
虚拟数字人里的生意经
Short selling, overprinting and stock keeping, Oriental selection actually sold 2.66 million books in Tiktok in one month
For friends who are not fat at all, nature tells you the reason: it is a genetic mutation
【软件测试】从企业版BOSS直聘,看求职简历,你没被面上是有原因的
Nat address translation
Wechat web debugging 8.0.19 replace the X5 kernel with xweb, so the X5 debugging method can no longer be used. Now there is a solution
Learn open62541 -- [67] add custom enum and display name
Review of network attack and defense
CVPR 2022 - learning non target knowledge for semantic segmentation of small samples
Hutool - lightweight DB operation solution
50亿,福建又诞生一只母基金
企业展厅设计中常用的三种多媒体技术形式