当前位置:网站首页>【牛客网刷题系列 之 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 仿真波形
待更新。。。
声明
本人所有系列的文章,仅供学习,不可商用,如有侵权,请告知,立删!!!
本人主要是记录学习过程,以供自己回头复习,再就是提供给后人参考,不喜勿喷!!!
如果觉得对你有用的话,记得收藏+评论!!!
边栏推荐
- 3. About cookies
- 【MIME笔记】
- 50亿,福建又诞生一只母基金
- 2022-07-04 matlab读取视频帧并保存
- [software test] from the direct employment of the boss of the enterprise version, looking at the resume, there is a reason why you are not covered
- UVALive – 4621 Cav 贪心 + 分析「建议收藏」
- [Blue Bridge Cup training 100 questions] sort scratch from small to large. Blue Bridge Cup scratch competition special prediction programming question centralized training simulation exercise question
- Zhong Xuegao wants to remain innocent in the world
- Flipping game (enumeration)
- 2022-07-04 matlab reads video frames and saves them
猜你喜欢

Comparison and selection of kubernetes Devops CD Tools

SD_ DATA_ RECEIVE_ SHIFT_ REGISTER
![[software test] from the direct employment of the boss of the enterprise version, looking at the resume, there is a reason why you are not covered](/img/73/cbbe82fd6bdfa8177f5bfcf683010d.jpg)
[software test] from the direct employment of the boss of the enterprise version, looking at the resume, there is a reason why you are not covered

I feel cheated. Wechat tests the function of "size number" internally, and two wechat can be registered with the same mobile number

Redis集群与扩展

50亿,福建又诞生一只母基金

高温火烧浑不怕,钟薛高想留清白在人间
![Kirk borne's selection of learning resources this week [click the title to download directly]](/img/df/98aa3edf0a70b870684963d52e7c72.png)
Kirk borne's selection of learning resources this week [click the title to download directly]

App capture of charles+postern

Desci: is decentralized science the new trend of Web3.0?
随机推荐
线程池的拒绝策略
2022上半年朋友圈都在传的10本书,找到了
Reject policy of thread pool
2022.07.04
AI来搞财富分配比人更公平?来自DeepMind的多人博弈游戏研究
UVALive – 4621 Cav 贪心 + 分析「建议收藏」
IP netns command (memo)
Redis cluster and expansion
Calculation of torque target value (ftorque) in servo torque control mode
线程池中的线程工厂
unity2d的Rigidbody2D的MovePosition函数移动时人物或屏幕抖动问题解决
从39个kaggle竞赛中总结出来的图像分割的Tips和Tricks
SD_ DATA_ RECEIVE_ SHIFT_ REGISTER
面试唯品会实习测试岗、抖音实习测试岗【真实投稿】
企业MES制造执行系统的分类与应用
Hongmeng smart home [1.0]
The live broadcast reservation channel is open! Unlock the secret of fast launching of audio and video applications
Learn open62541 -- [67] add custom enum and display name
Antisamy: a solution against XSS attack tutorial
Static routing configuration