// File: issue_13.v
// Generated by MyHDL 0.10
// Date: Tue May  8 20:56:21 2018


`timescale 1ns/10ps

module issue_13 (
    reset,
    clk,
    d,
    en,
    q
);


input reset;
input clk;
input [31:0] d;
input en;
output [7:0] q;
reg [7:0] q;



function integer MYHDL105_calculateHec;
    input [32-1:0] header;
    reg [8-1:0] hec;
    integer ii;
    reg bit;
begin: MYHDL108_RETURN
    hec = 8'h0;
    for (ii=32-1; ii>=0; ii=ii-1) begin
        bit = header[ii];
        hec[8-1:0] = {hec[7-1:2], ((bit ^ hec[1]) ^ hec[7]), ((bit ^ hec[0]) ^ hec[7]), (bit ^ hec[7])};
    end
    MYHDL105_calculateHec = (hec ^ 85);
    disable MYHDL108_RETURN;
end
endfunction


always @(posedge clk) begin: ISSUE_13_LOGIC
    if (reset == 1) begin
        q <= 0;
    end
    else begin
        if (en) begin
            q <= MYHDL105_calculateHec(d);
        end
    end
end

endmodule
