在线咨询
eetop公众号 创芯大讲堂 创芯人才网
切换到宽版

EETOP 创芯网论坛 (原名:电子顶级开发网)

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
楼主: hiwzy

[讨论] 今天华为面试题:异步FIFO读时钟是写时钟的100倍,或者写是读的100倍会出现什么问题?

[复制链接]
发表于 2017-8-24 19:38:05 | 显示全部楼层
问题想问的重点应该是看你知不知道格雷码。。找点资料看看,再联想下跨时钟域设计就能理解了。。没有那么多玄机在里面。。

不过话说回来,楼主,应该说幸好他不满意。。不然他满意了,你就去华为跟他一起写FIFO了。。。
发表于 2018-2-1 16:48:03 | 显示全部楼层




看完还是没明白有啥问题,这文章中也说了'may have problems'.1)full信号是在写时钟域产生的
2) empty信号是在读时钟域产生的

写时钟域只要不full就可以一直写,它压根不care empty信号
出问题的情况只可能是上层有协议把full 和empty同时同步到另外一个clock domain里面去干事情,比如说full_sync,empty_sync,在写代码的时候没考虑到full_sync和empty_sync可能同时为1的情况
发表于 2018-2-1 19:36:31 | 显示全部楼层
没有问题,这有啥问题

老子做个FIFO,还不允许读写时钟不一样,谁他妈规定的!
发表于 2018-4-19 09:59:18 | 显示全部楼层
同意六楼的分析,楼主说的没毛病!
发表于 2018-4-20 11:03:35 | 显示全部楼层
read through the whole reply. I also provide my opinion.

1. For Async_FIFO:
    The whole diagram has 3 parts: write, CDC between read and write, and read
    CDC may have the meta stability issue, that's why we need to use gray code
    For 100<->1 clock rate, I think it's not related to CDC. I try to simplify it with sync fifo, with two clock, but two clock are synchronous, like generated clock to avoid CDC issue first.

2. Sync FIFO
    2.1 If write clock is 100 times of read clock
          In write part, main signals has two parts: 1. write   2. fifo_full
          Since write is too fast, and write clock will sample rd_pointer fast and compare with wr_pointer. The control part will report full without issue.
          In read part, , signals also has tow parts: 1. read, 2. fifo_empty
          there are two case:
            a. write and read both work, since write is too fast, it will not have chance to catch wr_pointer, so it will not have chance to set empty signal. so no issue here.
            b. write sotp and read work, wr_pointer keeps unchange, if rd_pointer catch wr_pointer, it will set empty signal, no issue either.
          2.2 read clock is 100 times faster than write clock
             In read part, read clock is faster. When both write and read work, if rd_ptr catches wr_ptr, it will assert fifo_empty, since it's fast, sample miss will not happen. When write stops, there is no issue
            In write part, if both work, wr_pointer has no chance to catch rd_ptr, there is no issue and fifo_full will not be set
             If read part stops and wr part work, sampling issue has not issue, fifo_full will set regularily.

So, for sync_fifo, I don't think 100 times will have problem.

Let's come back to async_fifo. The big difference is CDC. If we suppose no CDC issue, what's the difference between async_fifo and sync_fifo logically. CDC issue is already solved mostly with Gray code for wr_pointer and rd_pointer. I remember there is a paper to talk about aync_fifo design. Some one call it fifo2.pdf.
发表于 2018-4-21 08:07:07 | 显示全部楼层
回复 1# hiwzy
时钟周期差异越大,速度慢的一侧出现亚稳态的可能性越大。gray码不是万能的,以写快读满举例:读的连续2个cycle抓写指针wpt1,wpt2。因为写速率快,虽然写侧是gray码发的连续指针,
但是读侧2个rclk上升沿抓到的wpt1,wpt2是不连续的,频差越大wpt1和wpt2的码字差异越大。
wpt bus各个bit到rclk的path是有略微差异的,后端平衡的越好wpt bus被抓错的概率越小。
对于频差太大,系统级应该设计每次按包传送。
fifo对连续两次抓到的指针差值也要进行冗余判断,比如发现指针后退了就有问题。
对前端代码可以对握手的读写指针总线每一位加不同的delay,然后仿真验证。
比如:
assign rd_wpt[0] = 0.2 wpt[0];
assign rd_wpt[1] = 0.3 wpt[1];
always @(posedge rdclk)
   begin
        rd_wpt_reg1 <= rd_wpt;
        rd_wpt_reg2 <= rd_wpt_reg1;
   end
发表于 2018-4-22 08:18:03 | 显示全部楼层
回复 4# xcan2012

写满标志是使用下一个写地址和读指针比较,而读指针是读地址经过写时钟延迟2拍得到,同样读空标志也是一样,即用于比较的数据都是在同一时钟域中的信号。中间会有多周期约束,感觉不会有特殊的setup/hold的问题
发表于 2018-4-22 08:59:56 | 显示全部楼层
回复 54# lxq124lxq


   同意会同时产生满、空信号,但是经过5000ns的延迟后会出现正确的状态即:满、非空,而且fifo的深度是多少不会影响这5000ns的延迟等待
发表于 2018-4-22 09:39:32 | 显示全部楼层
grey码不是用于解决function的问题。

CDC的问题基本靠synchronizer来解决。synchronizer解决的是CDC的可靠性问题,但不是消除,只能增加MTBF。如果要对MTBF要求高的话,就要增加后面synchronizer的DFF级数,另外第一级synchronizing flop在有些工艺库中可以使用meta-harder flop以提高MTBF.

synchronizer只能解决一个信号的跳变。如果是address bus,因为是整个bus顺序跳变,不能用synchronizer,gray码是比较好的解决方案。这些都是为了解决reliability的问题,不是function的问题。

所以如果没有Meta stability的问题,时钟差异大是无所谓的。

另外,看到有人说半满标志,那个是给DMA master用的。为了提高bus的使用效率,DMA master采用burst发送,如果半满的话,DMA master就不发送下面的packet。
发表于 2018-6-20 23:02:04 | 显示全部楼层
thanks for your sharing
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

站长推荐 上一条 /3 下一条

×

小黑屋| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-4-20 05:58 , Processed in 0.032261 second(s), 5 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表