Line 3... |
Line 3... |
// Filename: rxecrc.v
|
// Filename: rxecrc.v
|
//
|
//
|
// Project: OpenArty, an entirely open SoC based upon the Arty platform
|
// Project: OpenArty, an entirely open SoC based upon the Arty platform
|
//
|
//
|
// Purpose: To detect any CRC errors in the packet as received. The CRC
|
// Purpose: To detect any CRC errors in the packet as received. The CRC
|
// is not stripped as part of this process.
|
// is not stripped as part of this process. However, any bytes
|
|
// following the CRC, up to four, will be stripped from the output.
|
//
|
//
|
// Creator: Dan Gisselquist, Ph.D.
|
// Creator: Dan Gisselquist, Ph.D.
|
// Gisselquist Technology, LLC
|
// Gisselquist Technology, LLC
|
//
|
//
|
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
Line 65... |
Line 66... |
|
|
wire [3:0] lownibble;
|
wire [3:0] lownibble;
|
assign lownibble = r_crc[3:0] ^ i_d;
|
assign lownibble = r_crc[3:0] ^ i_d;
|
|
|
wire [31:0] shifted_crc;
|
wire [31:0] shifted_crc;
|
assign shifted_crc = { 4'h0, r_crc[27:0] };
|
assign shifted_crc = { 4'h0, r_crc[31:4] };
|
always @(posedge i_clk)
|
always @(posedge i_clk)
|
if (i_ce)
|
if (i_ce)
|
begin
|
begin
|
|
|
r_crc_q0 <= r_crc[31:4];
|
r_crc_q0 <= r_crc[31:4];
|
Line 79... |
Line 80... |
r_crc_q4 <= r_crc_q3[15:4];
|
r_crc_q4 <= r_crc_q3[15:4];
|
r_crc_q5 <= r_crc_q4[11:4];
|
r_crc_q5 <= r_crc_q4[11:4];
|
r_crc_q6 <= r_crc_q5[ 7:4];
|
r_crc_q6 <= r_crc_q5[ 7:4];
|
|
|
r_buf <= { r_buf[9:0], i_v, i_d };
|
r_buf <= { r_buf[9:0], i_v, i_d };
|
if (((!i_ce)&&(!o_v))||(i_cancel))
|
if (((!i_v)&&(!o_v))||(i_cancel))
|
begin
|
begin
|
r_crc <= 32'hffff_ffff;
|
r_crc <= 32'hffff_ffff;
|
r_err <= 1'b0;
|
r_err <= 1'b0;
|
|
|
r_mq[6:0] <= 7'h0;
|
r_mq[6:0] <= 7'h0;
|
Line 113... |
Line 114... |
4'hd: r_crc <= shifted_crc ^ `CRCBIT8 ^ `CRCBIT4 ^ `CRCBIT1;
|
4'hd: r_crc <= shifted_crc ^ `CRCBIT8 ^ `CRCBIT4 ^ `CRCBIT1;
|
4'he: r_crc <= shifted_crc ^ `CRCBIT8 ^ `CRCBIT4 ^ `CRCBIT2;
|
4'he: r_crc <= shifted_crc ^ `CRCBIT8 ^ `CRCBIT4 ^ `CRCBIT2;
|
4'hf: r_crc <= shifted_crc ^ `CRCBIT8 ^ `CRCBIT4 ^ `CRCBIT2 ^ `CRCBIT1;
|
4'hf: r_crc <= shifted_crc ^ `CRCBIT8 ^ `CRCBIT4 ^ `CRCBIT2 ^ `CRCBIT1;
|
endcase
|
endcase
|
|
|
r_mq[0] <= (i_v)&&(i_d == r_crc[3:0]);
|
r_mq[0] <= (i_v)&&(i_d == (~r_crc[3:0]));
|
r_mq[1] <= (r_mq[0])&&(i_v)&&(i_d == r_crc_q0[3:0]);
|
r_mq[1] <= (r_mq[0])&&(i_v)&&(i_d == (~r_crc_q0[3:0]));
|
r_mq[2] <= (r_mq[1])&&(i_v)&&(i_d == r_crc_q1[3:0]);
|
r_mq[2] <= (r_mq[1])&&(i_v)&&(i_d == (~r_crc_q1[3:0]));
|
r_mq[3] <= (r_mq[2])&&(i_v)&&(i_d == r_crc_q2[3:0]);
|
r_mq[3] <= (r_mq[2])&&(i_v)&&(i_d == (~r_crc_q2[3:0]));
|
r_mq[4] <= (r_mq[3])&&(i_v)&&(i_d == r_crc_q3[3:0]);
|
r_mq[4] <= (r_mq[3])&&(i_v)&&(i_d == (~r_crc_q3[3:0]));
|
r_mq[5] <= (r_mq[4])&&(i_v)&&(i_d == r_crc_q4[3:0]);
|
r_mq[5] <= (r_mq[4])&&(i_v)&&(i_d == (~r_crc_q4[3:0]));
|
r_mq[6] <= (r_mq[5])&&(i_v)&&(i_d == r_crc_q5[3:0]);
|
r_mq[6] <= (r_mq[5])&&(i_v)&&(i_d == (~r_crc_q5[3:0]));
|
//r_mq7<=(r_mq6)&&(i_v)&&(i_d == r_crc_q6[3:0]);
|
//r_mq7<=(r_mq6)&&(i_v)&&(i_d == r_crc_q6[3:0]);
|
|
|
r_mp <= { r_mp[2:0],
|
r_mp <= { r_mp[2:0],
|
(r_mq[6])&&(i_v)&&(i_d == r_crc_q6[3:0]) };
|
(r_mq[6])&&(i_v)&&(i_d == (~r_crc_q6[3:0])) };
|
|
|
// Now, we have an error if ...
|
// Now, we have an error if ...
|
// On the first empty, none of the prior N matches
|
// On the first empty, none of the prior N matches
|
// matched.
|
// matched.
|
r_err <= (r_err)||((i_en)&&(!i_v)&&(r_buf[4])&&(r_mp == 4'h0));
|
r_err <= (r_err)||((i_en)&&(!i_v)&&(r_buf[4])&&(r_mp == 4'h0));
|