Rules | Recent posts | topic RSS | Search | Register  | Log in

VHDL Code for CRC-5 Checksum circuit for USB Error correct

 
Post new topic  Reply to topic    EDAboard.com Forum Index -> PLD, SPLD, GAL, CPLD, FPGA Design
Author Message
govandi999



Joined: 10 Jun 2005
Posts: 10
Helped: 3


Post13 May 2008 9:36   VHDL Code for CRC-5 Checksum circuit for USB Error correct

We have to design a module which is a simple CRC-5 check sum circuit that will implement the polynomial (1 + x2 + x5). This polynomial is used for error correction in USB. The block diagram is as follows:



We have to design a circuit that takes the 32 bit input and after 32 cycles produces the 5 bit CRC. The operation of the circuit is explained below
1) Start ← 1
2) The Din is used to calculate the CRC for the next 32 clk cycles. At each cycle
Dout <= Din
3) The CRC is output during the next 5 cycles.

At each clock cycle the CRC is calculated as follows

NewCRC(0) := DIN xor OLDCRC(4);
NewCRC(1) := OLDCRC(0);
NewCRC(2) := DIN xor OLDCRC(1) xor OLDCRC(4);
NewCRC(3) := OLDCRC(2);
NewCRC(4) := OLDCRC(3);

We have to write a VHDL code for the CRC generator.

I have written the following code but there is some problem, can you please correct it.

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity CRC5 is
port ( START : in std_logic;
CLK : in std_logic;
DIN : in std_logic;
DOUT : out std_logic
);
end CRC5;

architecture BEH of CRC5 is

signal temp : std_logic;
SIGNAL NewCRC : STD_LOGIC_VECTOR(4 DOWNTO 0);
SIGNAL OLDCRC : STD_LOGIC_VECTOR(4 DOWNTO 0);

begin

PROCESS (CLK)

VARIABLE COUNT : INTEGER := 0;

begin
IF (CLK'EVENT AND CLK ='1') THEN

IF (START ='1') THEN

temp <= Din;
Dout <= temp;

COUNT := COUNT +1;

IF (COUNT = 32) THEN

NewCRC(0) <= temp xor OLDCRC(4);
NewCRC(1) <= OLDCRC(0);
NewCRC(2) <= temp xor OLDCRC(1) xor OLDCRC(4);
NewCRC(3) <= OLDCRC(2);
NewCRC(4) <= OLDCRC(3);

end if;

end if;
end if;

end process;

DOUT <= NewCRC(0);
DOUT <= NewCRC(1);
DOUT <= NewCRC(2);
DOUT <= NewCRC(3);
DOUT <= NewCRC(4);

end BEH;
Back to top
ieropsaltic



Joined: 25 Sep 2006
Posts: 185
Helped: 42


Post13 May 2008 11:07   Re: VHDL Code for CRC-5 Checksum circuit for USB Error corre

You use OLDCRC without putting values in them and they aren't inputs. So, you need first to assign values to them during operation. Would you post your algorithm in more detail so that we can help you more?
Back to top
tkbits



Joined: 04 Dec 2004
Posts: 215
Helped: 30


Post14 May 2008 17:54   Re: VHDL Code for CRC-5 Checksum circuit for USB Error corre

The way the code is written, you have several different values going to the single-bit DOUT simultaneously. At each clock cycle, the most significant bit of the CRC will be DOUT.

You have coded START as an enable signal. Is START a start signal or an enable signal ? If START is a start signal, I would expect it to load a seed value into NewCRC. START would then be set to 0 to enable clocking.

You're missing a way to transfer the NewCRC value to OLDCRC. As an alternative, after (CLK'EVENT AND CLK='1'), the signal assignment CRC(4) <= CRC(3); means "new" CRC(4) gets the value of "old" CRC(3).
Back to top
smqasim



Joined: 20 Jun 2004
Posts: 152
Helped: 59


Post16 May 2008 17:10   VHDL Code for CRC-5 Checksum circuit for USB Error correct

Can you rectify the code Mr. tkbits.

Last edited by smqasim on 18 May 2008 9:16; edited 1 time in total
Back to top
CMOS



Joined: 06 Jan 2004
Posts: 666
Helped: 24


Post17 May 2008 7:05   Re: VHDL Code for CRC-5 Checksum circuit for USB Error corre

See page 2 in this file...You might get some pointers from it.
http://www.edn.com/contents/images/80300di.pdf
Back to top
Post new topic  Reply to topic    EDAboard.com Forum Index -> PLD, SPLD, GAL, CPLD, FPGA Design
Page 1 of 1 All times are GMT + 2 Hours


Abuse
Administrator
Moderators
topic RSS 
sitemap