39123811
Newbie level 6
- Joined
- Apr 17, 2013
- Messages
- 14
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,423
You start by defining the problem more precise. Different frequency ==> can be anything. What you show is just a very small subset of possible "different frequency" scenarios. In fact, a x2 frequency with edges nicely aligned as you show ... luxury problem. XD
So what is the exact clock relationship? And any datarate restrictions?
What do I know? Define problem. Get answer. *beep* *boop*
Of course you can solve it (with or withouh FSM) if you define what constitutes solved. For the "missed data bit" what do you define as the correct answer? For you current example it could be either 1 or 0, depending on your requirements... Nothing magic about it, but you will have to choose which part of the waveform is valid.
You are really getting your brain tied in knots. Simply, there is NO WAY to sample a data stream with a clock slower than the data rate. You will need to use some kind of storage element (FIFO, etc.). The question of a FSM is irrelevant; yes, you can use a FSM to control your FIFO, but you are going to need SOME KIND OF STORAGE. And your FSM is going to have to use your source clock.
Can you give me some clue about how to use a FSM to control FIFO enable to avoid data loss in the above situation?
Past me tried to make a bet with future me that you were going to ask that in the near future. "Want to bet he's going to ask that?" I asked. "Noooooooo" I said, "I remember our last bet."
Too bad really, I would have won EUR 10. :|
simple answer: Use the vendor's drop-in dual-clock FIFO. Your source clock drives the write port, your receive clock drives the read port. DONE! You don't have to worry about those pesky timing issues because somebody smarter than us already did (presumably).
I'm still confused about what you really want. Do you want to know HOW a FIFO works, or are you looking for a particular solution to a particular problem?
This article is a bit odd...
It is describing a serial data stream generated by a 2x clock and received by a 1X clock, with the clocks being in phase.
The first example shows the the data sequence 00110011 being sent by the faster clock domain to the slower clock domain. The slower clock domain will capture 0101. The article states that this means data was not lost. That is a matter of opinion! If you were meaning to send 'h33 and got 'h5, then you'd be p**sed off. If you were sending 'h3 by stretching the length of the four bits to be each one slow-clock period wide, then you'd be happy. I think this is what they were trying to describe.
But in the next example, they send 'h2F and show it being corrupted since two of the bits change too fast to be seen by the slow clock. Of course this is corrupted in this case.
The mention of an FSM only applies to the special case where you have complete control over the source and destination blocks and freedom to throttle data. For example, flag bits that are sent across clock domains in rate-adapt FIFOs. The faster domain is free to make the flag 2+ destination clocks long. Or if you are also designing the serial data generator, you are free to make the data slow enough to be sampled. But even in any event, no FSM is required to lengthen simple data signals - just a few flip flops in series and some OR gates will make a pulse stretcher.
For the general case in going from fast to slow, as has been mentioned, a rate-adapt (clock crossing) FIFO would be used. This assumes the FIFO can back-pressure the data source or the fast data arrives in bursts that will not overflow the FIFO.
Again, the description they give is not one I would have used.
r.b.
The key here is that the article (as r.b. said more politely than I) is basically useless. IF AND ONLY IF you've got two synchronous(important!!) clocks and IF AND ONLY IF you output the data from the fast domain at the rate of the slow domain THEN a FSM would work with no storage elements. Big deal. This is a trivial case.
For the more general cases of non-synchronous clocks, or fast data into a slower domain, you need to forget about your FSMs and worry about the other issues.
I'm softening my stance on the article. It actually says "For example, a finite state machine (FSM) can be used to generate source data at a rate, such that it is stable for at least 1 complete cycle of the destination clock. This can be generally useful for synchronous clocks when their frequencies are known. For asynchronous clock domain crossings, techniques like handshake and FIFO are more suitable."
You seem to have latched onto the "FSM" statement and ignored everything else.
You're going to ask this as a question in an interview????? You don't even understand it yourself, and you're going to ask somebody else to explain it? Pardon me, but I've got better things to do than to help you contrive stupid questions in an attempt to trip up people you are interviewing. I would certainly not want to work for someone who operates like this.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?