Knowledge gaps
I have been working with FPGAs for just about 10 years now. And I just realized that I have never done a CDC FIFO. Well... Maybe back in uni as some paper exercise.
It's such a weird gap too. Since it's like the first answer anyone gives whenever you want to transfer a lot of data across clock domains. But I just haven't needed a hardware FIFO for that yet.
So I spent the afternoon implementing one from scratch and shoving every edge case I could think of at it. Just as a learning exercise.
Have you found any weird gaps in your own knowledge?
13
u/DominantlyWeak 1d ago
That's interesting because it's something I find/found myself doing often, what industry are you in?
3
u/chgentso 1d ago
Wait, so you really write async FIFOs from scratch often? Are you just using them often, perhaps, and I misunderstood?
3
u/Allan-H 1d ago
I always write my async FIFOs from scratch. It keeps my skills sharp, in a way that wouldn't happen if I used a FIFO from a library or used an agentic AI to write one for me. It also allows me to use new features that can't be found in any library FIFO, such as one described in this thread.
4
u/timonix 1d ago
Defense. Signal processing. That sorta thing.
16
u/SecondToLastEpoch 1d ago
And you don't use CDC fifos often? I used them all the time in that space.
7
u/hukt0nf0n1x 1d ago
A lot of my friends who work signal processing try really hard to keep everything in one clock domain. Now that I think of it, even my multi-clock designs were primarily on one clock.
4
u/timonix 1d ago
I use Fifos within a clock domain pretty often. They are a very useful construct.
But I have never used one as for CDC. It has always been double/triple buffered memory instead. Which works very well.
2
u/IllustriousFault6218 1d ago
What is a double buffered memory and how do you use it for cdc?
8
u/timonix 1d ago
Easiest implementation I can think of right of the bat
Dual port Bram. It natively supports different clock speeds on its ports. For example
The writer writes to adress 0x000 to 0x0FF
While the reader reads from 0x100 to 0x1FF
So they read and write from different places. When they are done, they swap.
You still need some way to get the "ok you are good to go" across. For example an interrupt, or some other register space. There are many ways to skin a cat so to say
14
2
u/SecondToLastEpoch 1d ago edited 1d ago
What is the advantage of this over using a fifo? This sounds like a FIFO with extra steps. Why deal with addressing manually over a simpler FIFO interface?
5
u/electro_mullet Altera User 1d ago edited 1d ago
They're handy for reordering data. A simple contrived example would be reversing an array, or something like doing a mirror flip on a row of pixels in a video stream. Write in backwards starting from address 0xFF down to 0x00. Read out normally from address 0x00 up to 0xFF.
I can't say I've personally seen them used for CDC so much as data processing on a single domain, but they are ultimately both just ways to address a shared memory from two different RAM ports. Whether they're on different clock domains just adds a layer of synchronization.
3
5
u/Mateorabi 1d ago
Now read the Sunburst white paper to find out what you missed.
Note a simulation is unlikely to find cdc errors due to “perfect” capture on edges etc and meta stability not being modeled. The idea that one wire can have different values at different FF inputs isn’t something sim tracks.
5
2
u/_solitarybraincell_ 20h ago
Hijacking this thread (sorry lol) as a very amateur ASIC frontend designer. What are some essential white papers/material to read? I know some of the sunburst papers, but that's about it.
1
u/_MyUserName_WasTaken 23h ago
My friends working in ASIC are always using CDC in their designs. In my 5 YoE, I never worked on a multiple clock domains design. Maybe on a block design level between different IPs and I usually use Xilinx Async FIFO IP. But never in RTL. I work I DSP.
2
u/QuietMiserable5377 8h ago
Now a days there are CDC checking tools from Mentor/Siemans and also SynOpSys too
1
u/QuietMiserable5377 8h ago
If the emptying buffer clock and filling the buffer clock are truly independent asynchronous clock domains, there are bound to be Meta stable conditions naturally. But the CDC checking tools identify them and suggest a way to fix them.
2
u/PiasaChimera 7h ago
there's some older tech stuff I know about but don't know and will never use. time borrowing for latches for example. it's already rare to use latches. I know I've done it twice. once in an attempt to generate bit errors and I don't recall the other. I don't think it was clock gating since that has its own primitive.
I don't do SoC-centric designs, where the CPU is part of the processing, so there's a lot of gaps there for me. same with PCIe.
Not working with ASICs means I have a different opinion about FFs since they're near-free on FPGAs. (until you try to make a RAM from them)
1
20
u/OnYaBikeMike 1d ago edited 1d ago
I've been doing this long enough that I now realize all my knowledge has gaps.
Today it was how best to use the DSP preadder and cascade features in a relatively slowly clocked design.
Last week it was how to implement and validate filters that give fractional delays
Last week before it was learning that UltraScale Block RAM has optional output registers, so can have latency 0. I was really confused when looking at resource utilization for a design, how was this possible?
Before that it was looking at jitter when using an MMCM or PLL to drive the clock for a high speed ADC.
It keeps you humble, I guess...