fix CRC generation during ethernet transmission trigger CRC generator only once per byte get CRC value _after_ last byte
Stefan Schuermans

Stefan Schuermans commited on 2012-03-07 21:15:53
Showing 1 changed files, with 11 additions and 6 deletions.

... ...
@@ -64,6 +64,7 @@ BEGIN
64 64
                     i_if_data_ack,
65 65
                     i_frame_en, i_frame_data, i_frame_data_en,
66 66
                     s_crc_crc)
67
+        VARIABLE v_data: std_logic_vector(31 DOWNTO 0);
67 68
     BEGIN
68 69
         n_state          <= r_state;
69 70
         n_data_cnt       <= r_data_cnt;
... ...
@@ -117,29 +118,33 @@ BEGIN
117 118
                         ELSE
118 119
                             n_state          <= st_crc;
119 120
                             n_data_cnt       <= 4;
120
-                            n_data           <= s_crc_crc;
121 121
                         END IF;
122 122
                     ELSE
123 123
                         n_data_cnt          <= r_data_cnt - 1;
124 124
                         n_data(23 DOWNTO 0) <= r_data(31 DOWNTO 8);
125 125
                     END IF;
126
-                END IF;
127
-                o_if_data    <= r_data(7 DOWNTO 0);
128
-                o_if_data_en <= '1';
129 126
                     s_crc_en    <= '1';
130 127
                     s_crc_start <= r_crc_start;
131 128
                     s_crc_data  <= r_data(7 DOWNTO 0);
129
+                END IF;
130
+                o_if_data    <= r_data(7 DOWNTO 0);
131
+                o_if_data_en <= '1';
132 132
             WHEN st_crc =>
133
+                IF r_data_cnt = 4 THEN
134
+                    v_data := s_crc_crc; -- get CRC value on first CRC byte
135
+                ELSE
136
+                    v_data := r_data;
137
+                END IF;
133 138
                 IF i_if_data_ack = '1' THEN
134 139
                     IF r_data_cnt = 1 THEN
135 140
                         n_state    <= st_gap;
136 141
                         n_data_cnt <= 12 * 8 * 2; -- 12 octets, x2 because of clk
137 142
                     ELSE
138 143
                         n_data_cnt          <= r_data_cnt - 1;
139
-                        n_data(23 DOWNTO 0) <= r_data(31 DOWNTO 8);
144
+                        n_data(23 DOWNTO 0) <= v_data(31 DOWNTO 8);
140 145
                     END IF;
141 146
                 END IF;
142
-                o_if_data    <= r_data(7 DOWNTO 0);
147
+                o_if_data    <= v_data(7 DOWNTO 0);
143 148
                 o_if_data_en <= '1';
144 149
             WHEN st_gap =>
145 150
                 IF r_data_cnt = 1 THEN
146 151