当前位置:网站首页>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为低电平时,不移位
//要输入新的值也需要移位三次才可以,很好的符合题目条件
...结束啦
边栏推荐
- 线性代数及矩阵论(七)
- 线性代数及矩阵论(八)
- Create a self-organizing / safe / controllable Lora network! Semtech responded for the first time to the impact of the "new regulations of the Ministry of industry and information technology"
- PostgreSQL weekly news - July 20, 2022
- 如何在构建阶段保护镜像安全
- MySQL数据库增删改查(基础操作命令详解)
- DGL Chapter 1 (official tutorial) personal notes
- Difference between reconnaissance aircraft and early warning aircraft
- Mysql database addition, deletion, modification and query (detailed explanation of basic operation commands)
- 2021年4月份自考
猜你喜欢

HTAP comes at a price

Microservice Architecture - service registry and service gateway (6.8) (Reprint)
![[deep learning]: day 5 of pytorch introduction to project practice: realize softmax regression from 0 to 1 (including source code)](/img/19/18d6e94a1e0fa4a75b66cf8cd99595.png)
[deep learning]: day 5 of pytorch introduction to project practice: realize softmax regression from 0 to 1 (including source code)

我为什么选择使用Go语言?

Unity shader realizes water wave effect with noise texture

DGL Chapter 1 (official tutorial) personal notes

配置V530交换机步骤

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

Janus series article 3 API usage guide videoroom creating a new video room

PostgreSQL weekly news - July 20, 2022
随机推荐
Goweb开发之Beego框架实战:第五节 项目搭建及注册用户
线性代数及矩阵论(十)
Comprehensively design an oppe homepage -- after sales service of the page
What does the service grid that has been popular for two years bring to microservices? (Reprinted)
Easypoi --- excel file export
Re12: read these3 semantic self segmentation for abstract summary of long legal documents in low
Make full use of English
Ugui learning notes (VI) get the information of the clicked UI
MySQL详细学习教程(建议收藏)
Easypoi multi sheet export by template
2022 Niuke multi school second CDE
Iris framework practice of goweb development: project summary and review
[deep learning]: day 6 of pytorch introduction to project practice: multi-layer perceptron (including code)
The 16th program design competition of Dalian University of Technology (Problem Solver)
Analysis of kubernetes service principle
Mysql database addition, deletion, modification and query (detailed explanation of basic operation commands)
Goweb开发之Beego框架实战:第三节 程序执行流程分析
Jupyter notebook win installation record
SUSE CEPH rapid deployment – storage6
全链路灰度在数据库上我们是怎么做的?