Hallo zusammen,
Als Ethernet Anfänger, habe mich mit dem Ethernet Projekt von fpga4fun
gefasst, ein Problem habe ich aber immer noch, die CRC32 Berechnung
Teil. die code habe ich in VHDL übersetzt, aber mein Ergebniss stimmt
nicht. zum beispiel für die sequence:
"00 10 A4 7B EA 80 00 12 34 56 78 90 08 00 45 00 00 2E B3 FE 00 00 80 11
05 40 C0 A8 00 2C C0 A8 00 04 04 00 04 00 00 1A 2D E8 00 01 02 03 04 05
06 07 08 09 0A 0B 0C 0D 0E 0F 10"(von Ethernet destination address bis
Payload), der checksum sollte: 11 B3 31 88 1B sein. Meine Berechnung mit
dem gleich sequence lifert kein richtigue Ergebniss.
Der code Teil von fpga4fun, für die crc32 Berechnung ist:
// generate the CRC32
1 | reg [31:0] CRC;
|
2 | reg CRCflush; always @(posedge clk20) if(CRCflush) CRCflush <= SendingPacket; else if(readram) CRCflush <= (rdaddress==7'h44);
|
3 | reg CRCinit; always @(posedge clk20) if(readram) CRCinit <= (rdaddress==7);
|
4 | wire CRCinput = CRCflush ? 0 : (ShiftData[0] ^ CRC[31]);
|
5 | always @(posedge clk20) if(ShiftCount[0]) CRC <= CRCinit ? ~0 : ({CRC[30:0],1'b0} ^ ({32{CRCinput}} & 32'h04C11DB7));
|
Mein Übersetzung in VHDL ist:
1 | PROCESS(TX_CLK)
|
2 | BEGIN
|
3 | if rising_edge(TX_CLK) then
|
4 | if (CRCflush = '1') then
|
5 | CRCflush <= SendingPacket;
|
6 | elsif(readram = '1') then
|
7 | if (rdaddress = "1000100") then--68 END OF DATA
|
8 | CRCflush <= '1';
|
9 | end if;
|
10 | end if;
|
11 | end if;
|
12 | END PROCESS;
|
13 |
|
14 | PROCESS(TX_CLK)
|
15 | BEGIN
|
16 | if rising_edge(TX_CLK) then
|
17 | if (readram = '1') then
|
18 | if (rdaddress = "0000111") then--7 END OF PREAMBLE
|
19 | CRCinit <= '1';
|
20 | else
|
21 | CRCinit <= '0';
|
22 | end if;
|
23 | end if;
|
24 | end if;
|
25 | END PROCESS;
|
26 |
|
27 | PROCESS(TX_CLK)
|
28 | BEGIN
|
29 | if rising_edge(TX_CLK) then
|
30 | if (CRCflush = '1') then
|
31 | CRCinput <= '0';
|
32 | else
|
33 | CRCinput <= (ShiftData(0) XOR CRC(31));
|
34 |
|
35 | end if;
|
36 | end if;
|
37 | END PROCESS;
|
38 |
|
39 | PROCESS(TX_CLK)
|
40 | BEGIN
|
41 | if rising_edge(TX_CLK) then
|
42 | if (CRCinit = '1') then
|
43 | CRC_pre <= X"FFFFFFFF";
|
44 | else
|
45 |
|
46 | CRC_pre <= ((CRC(30 downto 0) & '0') XOR (CRCinput & CRCinput & CRCinput & CRCinput & CRCinput & CRCinput & CRCinput & CRCinput & CRCinput & CRCinput & CRCinput & CRCinput & CRCinput & CRCinput & CRCinput & CRCinput & CRCinput & CRCinput & CRCinput & CRCinput & CRCinput & CRCinput & CRCinput & CRCinput & CRCinput & CRCinput & CRCinput & CRCinput & CRCinput & CRCinput & CRCinput & CRCinput AND "00000100110000010001110110110111"));
|
47 | end if;
|
48 | end if;
|
49 | END PROCESS;
|
50 |
|
51 |
|
52 | PROCESS(TX_CLK)
|
53 | BEGIN
|
54 | if rising_edge(TX_CLK) then
|
55 | if (ShiftCount(0) = '1') then
|
56 | CRC <= CRC_pre;
|
57 | end if;
|
58 | end if;
|
59 | END PROCESS;
|
Meinen Fragen sind folgende:
habe ich Fehler in die Übersetzung gemacht wenn ja, welche?
Kann mein code überhaupt ein richtige CRC32 berechnen?
Please help! und sorry für mein schlecht deutsche Sprache.