OpenCores
Issue List
Corrupted data, bug found #29
Open tionex opened this issue almost 12 years ago
tionex commented almost 12 years ago

Hi

in some scenarios where wrong frames are received, the first valid frame received afterwards can have corrupted data.

The problem is in can_bsp.v line 1017..1026

always @ (posedge clk or posedge rst) begin if (rst) byte_cnt <= 3'h0; else if (write_data_to_tmp_fifo) byte_cnt <=#Tp byte_cnt + 1'b1; else if (sample_point & go_rx_crc_lim) byte_cnt <=#Tp 3'h0; end

This byte_cnt holds the index where to write a received data to a temporary buffer. The problem is, this is reset to 0 after the data is complete. In case a frame started correctly and in the middle of the data an error happens, the byte_cnt is not reset and the next frame starts to write the data at the wrong index. To fix this, the byte_cnt should be reset when the frame is going to receive the data bytes:

always @ (posedge clk or posedge rst) begin if (rst) byte_cnt <= 3'h0; else if (write_data_to_tmp_fifo) byte_cnt <=#Tp byte_cnt + 1'b1; else if (go_rx_data) byte_cnt <=#Tp 3'h0; end

cu Frank


Assignee
No one
Labels
Request