当前位置:网站首页>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为低电平时,不移位
//要输入新的值也需要移位三次才可以,很好的符合题目条件
...结束啦
边栏推荐
- Shopee code League 2022 - qualification round p3.connecting the numbers (segment tree / bipartite graph determination, to be discussed)
- 微信小程序现金红包返回“IP地址非你在商户平台设置的可用IP地址”错误终极解决方法
- Goweb开发之Iris框架实战:项目总结与回顾
- WPF command button transparent style
- 一文了解 Kubernetes 中的服务发现
- Goweb开发之Beego框架实战:第一节 Beego框架介绍
- kubernetes service 原理解析
- 零基础利用Unity3D开发AR应用并远程下载3D模型
- Educational codeforces round 126 (rated for Div. 2) f.teleporters (two sets and two points)
- C#遍历集合
猜你喜欢

C# 导入Excel文件数据的几种方法

The 16th program design competition of Dalian University of Technology (Problem Solver)

Easypoi --- excel file export
![[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)

HTAP comes at a price

零基础利用Unity3D开发AR应用并远程下载3D模型

总数据量超万亿行,玉溪卷烟厂通过正确选择时序数据库轻松应对

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

influxdb2的使用

火了 2 年的服务网格究竟给微服务带来了什么?(转载)
随机推荐
Leetcode 2022.04.10 China Merchants Bank special competition D. store promotion (DP)
MySQL数据库增删改查(基础操作命令详解)
SUSE CEPH rapid deployment – storage6
Go language slow entry - process control statement
DGL Chapter 1 (official tutorial) personal notes
Unity3d simple implementation of water surface shader
Deep understanding of deepsea and salt deployment tools – storage6
SUSE CEPH add nodes, reduce nodes, delete OSD disks and other operations – storage6
Round 1A 2022 - Code jam 2022 c.weightlifting (interval DP)
Use of influxdb2
2022牛客多校第二场CDE
2021年4月份自考
Visual Studio 2012/2015发布Web应用连同.cs源码一起发布
堡垒机的作用
微信小程序现金红包返回“IP地址非你在商户平台设置的可用IP地址”错误终极解决方法
Unity editor learning (I) using features to change the display of fields in components
Self study examination in April 2021
Role of Fortress machine
Analysis of kubernetes service principle
Detailed steps for setting up SUSE storage6 environment – win10 + VMware Workstation