Forum Discussion

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

CRC Calculation - VHDL

Hello to all forum members!!!

I'll be glad to get your's suggestions to solve my problem.

I am interested to make the CRC Calculation as fast as possible (without using the MegaWizard function).

In order to make the calculation as fast as possible, I used the "variables" and not the signals. The purpose of VHDL Code is doing something like 250 xor actions(5 actions on every byte while the data telegram build from 53 bytes). During the sumalition (ModelSim) I got the right results. Pending one clock the result is ready!

Of course, it's uncompareable to real FPGA chip perfomance.

I did the Quartus TimeQuest analyze with 50MHz oscillator. The result was really bad. The parameters that failed are:

  • Report SetUp Summary

  • Fmax is something like 20Mhz

And now the question's time :) How can the setup time be affected if I didn't use the clock during calculation (before CRC it was OK)? As i know, SetUp time is a parameter that defines how much time the data has to be stable before changing the clk edge. How can I increase the Fmax of the design.(before CRC Fmax was ~ 120MHz)

thanks for every offer!!!

Y.

17 Replies

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

    How many bits do you process in one clock cycle?

    I have implemented the CRC32 with 64 bits in one clock cycle and can run it with 156.25 MHz in a Startix V without any problems. And this is a straight forward implementation without any pipelining.

    By the way it is possible to pipeline CRC computations. There is a bunch of publications that describe how to do this. The one that I currently favor is:

    y. sun, m.s. kim, "a table-based algorithm for pipelined crc calculation," 2010 ieee international conference on communication (http://ieeexplore.ieee.org/xpl/login.jsp?tp=&arnumber=5501903&url=http%3a%2f%2fieeexplore.ieee.org%2fxpls%2fabs_all.jsp%3farnumber%3d5501903)
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    And ....

    You can do a CRC16 with 5 XOR per byte (and some shifts which are free in harware), I doubt the same is true of CRC32.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Which CRC are you computing?

    Sounds a bit like CRC16.

    You might be able to make use of the fact that you can XOR together two packets and still have a valid CRC (if you correctly allow for the initial value and final inversion).

    So maybe you can xor together the CRC value for each bit.

    While this is now 53*8 XORs, they can be done in parallel - so only 10 deep.

    If large parts of the packet are fixed, they can be excluded from the dynamic crc.

    OTOH why don't you defer the CRC calculation until teh data is serialised?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Why? Use signals and parallelize all the stuff as much, as possible. We use CRC32 with signals giving result in 1 clk cycle.

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

    But if I choose to use "signals" it can take something like 250 cycles at least. Also, I have to say that every next value is dependent from the previous one.

    What do you mean when you are talking "think about the circuit" ? To build circuit by myself from logic elements?

    Do you have the good explanation for the pipeline maybe? I tried to seek the good topic about it but didn't find anything seriously...Maybe do you have the good code example to pipeline?

    Tnx for your answer
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    to increase the fmax, you need to pipeline the design. 250 XORs is a lot to do in a single clock. And to do that you'll need signals not variables. Before you design ANYTHING with VHDL, you need to think about the circuit before you write any code.