当前位置:网站首页>【牛客网刷题系列 之 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 仿真波形
待更新。。。
声明
本人所有系列的文章,仅供学习,不可商用,如有侵权,请告知,立删!!!
本人主要是记录学习过程,以供自己回头复习,再就是提供给后人参考,不喜勿喷!!!
如果觉得对你有用的话,记得收藏+评论!!!
边栏推荐
- Calculation of torque target value (ftorque) in servo torque control mode
- 如何给“不卖笔”的晨光估值?
- unity2d的Rigidbody2D的MovePosition函数移动时人物或屏幕抖动问题解决
- Nat address translation
- Kirk borne's selection of learning resources this week [click the title to download directly]
- 高温火烧浑不怕,钟薛高想留清白在人间
- AI来搞财富分配比人更公平?来自DeepMind的多人博弈游戏研究
- Where does brain hole come from? New research from the University of California: creative people's neural connections will "take shortcuts"
- 学习open62541 --- [67] 添加自定义Enum并显示名字
- Continuous test (CT) practical experience sharing
猜你喜欢
Micro service remote debug, nocalhost + rainbow micro service development second bullet
Multimodal point cloud fusion and visual location based on image and laser
Policy mode - unity
ES6笔记一
Calculation of torque target value (ftorque) in servo torque control mode
面试唯品会实习测试岗、抖音实习测试岗【真实投稿】
[tpm2.0 principle and Application guide] Chapter 16, 17 and 18
Static routing configuration
Comparison and selection of kubernetes Devops CD Tools
前首富,沉迷种田
随机推荐
Charles+drony的APP抓包
Nat address translation
POJ 2392 Space Elevator
线程池的拒绝策略
【剑指 Offer】59 - I. 滑动窗口的最大值
50亿,福建又诞生一只母基金
Thread factory in thread pool
The top of slashdata developer tool is up to you!!!
I feel cheated. Wechat tests the function of "size number" internally, and two wechat can be registered with the same mobile number
For friends who are not fat at all, nature tells you the reason: it is a genetic mutation
国内的软件测试会受到偏见吗
【塔望方法论】塔望3W消费战略 - U&A研究法
Numpy——2.数组的形状
[information security laws and regulations] review
SD_ DATA_ SEND_ SHIFT_ REGISTER
The performance and efficiency of the model that can do three segmentation tasks at the same time is better than maskformer! Meta & UIUC proposes a general segmentation model with better performance t
Scientists have observed for the first time that the "electron vortex" helps to design more efficient electronic products
2022-07-04 matlab读取视频帧并保存
99% of people don't know that privatized deployment is also a permanently free instant messaging software!
链式二叉树的基本操作(C语言实现)