2886|0

6892

帖子

0

TA的资源

五彩晶圆(高级)

楼主
 

标志信号跨越两个时钟处理方法 [复制链接]

A flag to another clock domainIf the signal that needs to cross the clock domains is just a pulse (i.e. it lasts just one clock cycle), we call it a "flag". The previous design usually doesn't work (the flag might be missed, or be seen for too long, depending on the ratio of the clocks used).
We still want to use a synchronizer, but one that works for flags.

The trick is to transform the flags into level changes, and then use the two flip-flops technique.
module Flag_CrossDomain(    clkA, FlagIn_clkA,     clkB, FlagOut_clkB);// clkA domain signalsinput clkA, FlagIn_clkA;// clkB domain signalsinput clkB;output FlagOut_clkB;reg FlagToggle_clkA;reg [2:0] SyncA_clkB;// this changes level when a flag is seenalways @(posedge clkA) if(FlagIn_clkA) FlagToggle_clkA <= ~FlagToggle_clkA;// which can then be sync-ed to clkBalways @(posedge clkB) SyncA_clkB <= {SyncA_clkB[1:0], FlagToggle_clkA};// and recreate the flag from the level changeassign FlagOut_clkB = (SyncA_clkB[2] ^ SyncA_clkB[1]);endmodule
Now if you want the clkA domain to receive an acknowledgment (that clkB received the flag), add a busy signal.

module FlagAck_CrossDomain(    clkA, FlagIn_clkA, Busy_clkA,     clkB, FlagOut_clkB);// clkA domain signalsinput clkA, FlagIn_clkA;output Busy_clkA;// clkB domain signalsinput clkB;output FlagOut_clkB;reg FlagToggle_clkA;reg [2:0] SyncA_clkB;reg [1:0] SyncB_clkA;always @(posedge clkA) if(FlagIn_clkA & ~Busy_clkA) FlagToggle_clkA <= ~FlagToggle_clkA;always @(posedge clkB) SyncA_clkB <= {SyncA_clkB[1:0], FlagToggle_clkA};always @(posedge clkA) SyncB_clkA <= {SyncB_clkA[0], SyncA_clkB[2]};assign FlagOut_clkB = (SyncA_clkB[2] ^ SyncA_clkB[1]);assign Busy_clkA = FlagToggle_clkA ^ SyncB_clkA[1];endmodule
此帖出自FPGA/CPLD论坛
点赞 关注
 

回复
举报
您需要登录后才可以回帖 登录 | 注册

随便看看
查找数据手册?

EEWorld Datasheet 技术支持

相关文章 更多>>
关闭
站长推荐上一条 1/9 下一条

 
EEWorld订阅号

 
EEWorld服务号

 
汽车开发圈

About Us 关于我们 客户服务 联系方式 器件索引 网站地图 最新更新 手机版

站点相关: 国产芯 安防电子 汽车电子 手机便携 工业控制 家用电子 医疗电子 测试测量 网络通信 物联网

北京市海淀区中关村大街18号B座15层1530室 电话:(010)82350740 邮编:100190

电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2025 EEWORLD.com.cn, Inc. All rights reserved
快速回复 返回顶部 返回列表