24 lines
701 B
Systemverilog
24 lines
701 B
Systemverilog
`default_nettype none
|
|
|
|
// One reflected Ethernet CRC-32 byte update. Initialize crc_in to 0xffffffff,
|
|
// update over destination MAC through padding, then transmit ~crc in low-byte
|
|
// first order. Polynomial x^32+x^26+x^23+...+1 is 0xedb88320 reflected.
|
|
module ethernet_crc32 (
|
|
input wire logic [31:0] crc_in,
|
|
input wire logic [7:0] data_in,
|
|
output logic [31:0] crc_out
|
|
);
|
|
integer i;
|
|
logic [31:0] c;
|
|
always_comb begin
|
|
c = crc_in;
|
|
for (i = 0; i < 8; i = i + 1) begin
|
|
if (c[0] ^ data_in[i]) c = (c >> 1) ^ 32'hedb88320;
|
|
else c = (c >> 1);
|
|
end
|
|
crc_out = c;
|
|
end
|
|
endmodule
|
|
|
|
`default_nettype wire
|