当前位置:网站首页>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为低电平时,不移位
//要输入新的值也需要移位三次才可以,很好的符合题目条件
...结束啦
边栏推荐
- 部分情况下Error:(xx, xx) Failed to resolve: xxxxxx解决。
- Steps to configure V530 switch
- 浏览器解码过程分析
- Android Development - set cache
- Shopee code League 2022 - qualification round p3.connecting the numbers (segment tree / bipartite graph determination, to be discussed)
- 火了 2 年的服务网格究竟给微服务带来了什么?(转载)
- Facet experience -- the development side of dragon game client
- 《Kubernetes》你需要掌握的 Service 和 Ingress
- 配置V530交换机步骤
- Some notes on how unity objects move
猜你喜欢

Educational codeforces round 126 (rated for Div. 2) f.teleporters (two sets and two points)

Unity3d shader achieves ablation effect

Verilog 每日一题(VL6 数据串转并电路)

Unity editor learning (I) using features to change the display of fields in components

System clock failure of database fault tolerance

Goweb开发之Beego框架实战:第五节 项目搭建及注册用户

Proof of the third scene (f) in 22 years

Goweb开发之Beego框架实战:第三节 程序执行流程分析

mysql 最大建议行数2000w,靠谱吗?

22年多校第三场(F的证明
随机推荐
Leetcode 2022.04.10 China Merchants Bank special competition D. store promotion (DP)
Application of Pegasus d200s UAV and airborne lidar in large-scale DEM construction
微服务架构-服务注册中心和服务网关(6.8) (转载)
Goweb开发之Beego框架实战:第三节 程序执行流程分析
Proof of the third scene (f) in 22 years
2021年4月份自考
2022牛客多校第二场CDE
Fine-grained Fact Verification with Kernel GA Network
Source code of voice live broadcast app
Unity editor learning (I) using features to change the display of fields in components
MySQL详细学习教程(建议收藏)
Goweb开发之Beego框架实战:第一节 Beego框架介绍
充分利用----英文
wpf命令按钮透明样式
Comprehensively design an oppe homepage -- after sales service of the page
Facet experience -- the development side of dragon game client
Analysis of kubernetes service principle
如何在构建阶段保护镜像安全
Codeforces round 770 (Div. 2) e. fair share
Ugui learning notes (IV) ugui event system overview and Usage Summary