当前位置:网站首页>Verilog 每日一题 (VL24 多bit MUX同步器 跨时域输出)
Verilog 每日一题 (VL24 多bit MUX同步器 跨时域输出)
2022-07-28 16:23:00 【别再出error了】
题目描述
在data_en为高期间,data_in将保持不变,data_en为高至少保持3个B时钟周期。表明,当data_en为高时,可将数据进行同步。
本题中data_in端数据变化频率很低,相邻两个数据间的变化,至少间隔10个B时钟周期。
电路的接口如下图所示。端口说明如下表所示。


解题:
这一题总体思路是将A时钟域输入信号,同步到B时钟域,并随B时钟上升沿到来而输出。这里的思路是在A时钟设立一个有效信号data_en,当data_en满三个周期有效时,data_out读取data_in的值,实现一个跨时钟域的输出。
详解如下:
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
);
integer i; //定义一个参数来打拍
always @(posedge clk_b or negedge brstn) begin
if(!arstn) dataout <= 0;
else if(i>=4) dataout <= data_in;
else dataout <= dataout; //当data_en为低电平时,dataout保持不变,而不是置零(一开始写错了)
end
always @(posedge clk_a or negedge arstn)begin
if(!brstn) i<=0;
else if(data_en) i <= i+1; //三个a周期后,i=4,需要满3个周期才行;
else i <= 0; //低电平 i置零,等待重新计数
end
endmodule这里的思路是声明一个参数i来打拍,在看别人的答案里,看到一种方法比较有意思值得学习一下:
...
else if(data_en)
data_a <= {data_a[11:0],data_in}; //打拍,利用移位寄存器
...
dataout <= data_a[15:12];
//输出最高4位,即打拍三次后才可以输出,而当en为低电平时,不移位
//要输入新的值也需要移位三次才可以,很好的符合题目条件
...结束啦
边栏推荐
- List of supplementary questions
- Andthen of function interface
- 配置V530交换机步骤
- Realization of reflection and refraction effect in unity shader cube texture
- Codeforces round 768 (Div. 2) e.paint the middle (greedy / interval relationship processing)
- wpf命令按钮透明样式
- 浏览器解码过程分析
- How do we do full link grayscale on the database?
- It is said that NVIDIA has held talks with Softbank and will offer more than US $32billion to acquire arm
- Visual Studio 2012/2015发布Web应用连同.cs源码一起发布
猜你喜欢

net框架

Atcoder regular contest 133 d.range XOR (digital dp+ classification discussion)

Unity shader global fog effect

Easypoi multi sheet export by template

Unity3d shader achieves ablation effect

Steps to configure V530 switch

Unity shader cartoon style rendering

高速电路中电阻的选择

带参数的微信小程序二维码生成

Valarray Library Learning
随机推荐
The 16th program design competition of Dalian University of Technology (Problem Solver)
Source code of voice live broadcast app
In 2020q2, shipments in the global tablet market soared by 26.1%: Huawei ranked third and Lenovo increased the most!
Vscode界面介绍
Goweb开发之Beego框架实战:第四节 数据库配置及连接
How do we do full link grayscale on the database?
Codeforces round 770 (Div. 2) e. fair share
Visual Studio 2012/2015发布Web应用连同.cs源码一起发布
Huawei mate 40 series exposure: large curvature hyperboloid screen, 5nm kylin 1020 processor! There will also be a version of Tianji 1000+
Goweb开发之Beego框架实战:第二节 项目初始化配置
Games101 section 13 ray tracing notes
Unity shader uses rendered texture to achieve glass effect
我为什么选择使用Go语言?
The 2021 ICPC ASIA Taipei Regional programming contest L. leadfoot (combinatorics /2-adic assignment function +kummer theorem)
Android Development - set cache
浏览器解码过程分析
高速电路中电容的选型和应用——详解
Janus series article 3 API usage guide videoroom creating a new video room
侦察机与预警机的区别
Analysis of browser decoding process