Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
16 years ago

Asynchronous load

This is a shift register question that I'm looking to get some light shed on. I have a 4 16bit shift registers that I'm using to detect a pattern. I feed bits into the shift regs until they match a pattern, at which point I replace the entire contents of the 4 shift registers with something else in a parallel load. The problem is that on one cycle, the pattern is detected and on the next clock cycle, the parallel load occurs. But also occurring on this cycle is the normal serial load. So the parallel load and the serial load collide and the parallel load seems to win and the 4 bits that I wanted to be shifted in serially are lost. Is it possible to do the comparison and load on the same cycle so that the first set of 4 bits on the serial input don't get lost? Is there a special shift register setting for this?

There's a setting for asynchronous load in lpm_shiftreg but its greyed out

Thanks

36 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I didn't really think about it. Now that I think about it, the only way I can forsee this possibly working is if the source of the data (an ethernet PHY board) runs at the same clock speed as the FPGA. How else would this be able to work correctly then? I'd still need to register the inputs though right? Just because they're running at the same speed, the clocks could be not completely in sync with each other right?

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    The PHY board transmits at 25 MHz and the FPGA runs at 50 MHz. So does that mean that for the simulation to be accurate, I should run the simulation clock at 50 MHz and provide a new set of 4 bits every 2 FPGA cycles?

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Wow it works so much better now! I can change to a different device/add or remove output ports and it all still works. The code didn't even really change that much except for the clock divider and registering those inputs.

    Something else I thought of, when I actually hook this up to hardware I'm going to have to 25 MHz clocks (one from the phy board, one from the fpga). The code I wrote relies on the fact that they are at the same speed so that the data I'm supplying is in line with the data I'm receiving. Could I use a FIFO as a buffer for the data and just pump it in at one clock speed (the phy board clock speed) and read it at another speed ( the fpga clock speed) and then as long as the fifo is long enough, I shouldn't have to worry about the clocks violating some setup time?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Yes a FIFO is one of the usual means to move data between unsynchronized clock domains. The Quartus FIFO MegaFunction has all options to handle this situation. Actually, the FIFO depth requirement isn't high, because Ethernet has a clock accuracy specification of +/- 100 ppm, so the required buffer elasticity isn't more than a few bytes, even with extra large frames.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    That's good to know. I've been messing around with the fifo buffer and the one thing I'm confused about is how the read and write request signals. I assume that I want to be reading and writing all the time. But if one clock is faster than the other (say my fpga clock is faster) then it will read the same value again if the buffer is empty. I've been messing around with this by using a 30mhz clock and a 25 mhz clock which is a huge stretch and I can see that if I just read and write all the time I'll run into problems.