data/full_repos/permissive/489147019/Testcases/mempool/rtl/common_cells/src/ecc_encode.sv
1: b"%Error: data/full_repos/permissive/489147019/Testcases/mempool/rtl/common_cells/src/ecc_encode.sv:22: syntax error, unexpected IDENTIFIER, expecting PACKAGE-IDENTIFIER\nmodule ecc_encode import ecc_pkg::*; #(\n                         ^~~~~~~\n%Error: data/full_repos/permissive/489147019/Testcases/mempool/rtl/common_cells/src/ecc_encode.sv:26: syntax error, unexpected parameter, expecting IDENTIFIER\n  parameter type data_t         = logic [DataWidth-1:0],\n  ^~~~~~~~~\n%Error: data/full_repos/permissive/489147019/Testcases/mempool/rtl/common_cells/src/ecc_encode.sv:27: syntax error, unexpected parameter, expecting IDENTIFIER\n  parameter type parity_t       = logic [get_parity_width(DataWidth)-1:0],\n  ^~~~~~~~~\n%Error: data/full_repos/permissive/489147019/Testcases/mempool/rtl/common_cells/src/ecc_encode.sv:28: syntax error, unexpected parameter, expecting IDENTIFIER\n  parameter type code_word_t    = logic [get_cw_width(DataWidth)-1:0],\n  ^~~~~~~~~\n%Error: data/full_repos/permissive/489147019/Testcases/mempool/rtl/common_cells/src/ecc_encode.sv:29: syntax error, unexpected parameter, expecting IDENTIFIER\n  parameter type encoded_data_t = struct packed {\n  ^~~~~~~~~\n%Error: data/full_repos/permissive/489147019/Testcases/mempool/rtl/common_cells/src/ecc_encode.sv:33: syntax error, unexpected ')', expecting ';'\n) (\n^\n%Error: data/full_repos/permissive/489147019/Testcases/mempool/rtl/common_cells/src/ecc_encode.sv:37: syntax error, unexpected output, expecting IDENTIFIER or '=' or do or final\n  output encoded_data_t data_o\n  ^~~~~~\n%Error: data/full_repos/permissive/489147019/Testcases/mempool/rtl/common_cells/src/ecc_encode.sv:44: syntax error, unexpected always_comb\n  always_comb begin : expand_data\n  ^~~~~~~~~~~\n%Error: data/full_repos/permissive/489147019/Testcases/mempool/rtl/common_cells/src/ecc_encode.sv:46: syntax error, unexpected IDENTIFIER\n    data = '0;\n    ^~~~\n%Error: data/full_repos/permissive/489147019/Testcases/mempool/rtl/common_cells/src/ecc_encode.sv:48: syntax error, unexpected IDENTIFIER\n    for (int unsigned i = 1; i < unsigned'($bits(code_word_t)) + 1; i++) begin\n                             ^\n%Error: data/full_repos/permissive/489147019/Testcases/mempool/rtl/common_cells/src/ecc_encode.sv:60: syntax error, unexpected IDENTIFIER\n    for (int unsigned i = 0; i < unsigned'($bits(parity_t)); i++) begin\n                             ^\n%Error: data/full_repos/permissive/489147019/Testcases/mempool/rtl/common_cells/src/ecc_encode.sv:61: syntax error, unexpected IDENTIFIER\n      for (int unsigned j = 1; j < unsigned'($bits(code_word_t)) + 1; j++) begin\n                               ^\n%Error: data/full_repos/permissive/489147019/Testcases/mempool/rtl/common_cells/src/ecc_encode.sv:70: syntax error, unexpected IDENTIFIER\n      for (int unsigned i = 0; i < unsigned'($bits(parity_t)); i++) begin\n                               ^\n%Error: Exiting due to 13 error(s)\n"
module ecc_encode import ecc_pkg::*; #(

  parameter  int unsigned DataWidth   = 64,

  parameter type data_t         = logic [DataWidth-1:0],
  parameter type parity_t       = logic [get_parity_width(DataWidth)-1:0],
  parameter type code_word_t    = logic [get_cw_width(DataWidth)-1:0],
  parameter type encoded_data_t = struct packed {
                                    logic parity;
                                    code_word_t code_word;
                                  }
) (

  input  data_t         data_i,

  output encoded_data_t data_o
);

  parity_t parity_code_word;
  code_word_t data, codeword;


  always_comb begin : expand_data
    automatic int unsigned idx;
    data = '0;
    idx = 0;
    for (int unsigned i = 1; i < unsigned'($bits(code_word_t)) + 1; i++) begin

      if (unsigned'(2**$clog2(i)) != i) begin
        data[i - 1] = data_i[idx];
        idx++;
      end
    end
  end


  always_comb begin : calculate_syndrome
    parity_code_word = 0;
    for (int unsigned i = 0; i < unsigned'($bits(parity_t)); i++) begin
      for (int unsigned j = 1; j < unsigned'($bits(code_word_t)) + 1; j++) begin
        if (|(unsigned'(2**i) & j)) parity_code_word[i] = parity_code_word[i] ^ data[j - 1];
      end
    end
  end


  always_comb begin : generate_codeword
      codeword = data;
      for (int unsigned i = 0; i < unsigned'($bits(parity_t)); i++) begin
        codeword[2**i-1] = parity_code_word[i];
      end
  end

  assign data_o.code_word = codeword;
  assign data_o.parity = ^codeword;

endmodule
module ecc_encode import ecc_pkg::*;
 #(

  parameter  int unsigned DataWidth   = 64,

  parameter type data_t         = logic [DataWidth-1:0],
  parameter type parity_t       = logic [get_parity_width(DataWidth)-1:0],
  parameter type code_word_t    = logic [get_cw_width(DataWidth)-1:0],
  parameter type encoded_data_t = struct packed {
                                    logic parity;
                                    code_word_t code_word;
                                  }
) (

  input  data_t         data_i,

  output encoded_data_t data_o
);

  parity_t parity_code_word;
  code_word_t data, codeword;


  always_comb begin : expand_data
    automatic int unsigned idx;
    data = '0;
    idx = 0;
    for (int unsigned i = 1; i < unsigned'($bits(code_word_t)) + 1; i++) begin

      if (unsigned'(2**$clog2(i)) != i) begin
        data[i - 1] = data_i[idx];
        idx++;
      end
    end
  end


  always_comb begin : calculate_syndrome
    parity_code_word = 0;
    for (int unsigned i = 0; i < unsigned'($bits(parity_t)); i++) begin
      for (int unsigned j = 1; j < unsigned'($bits(code_word_t)) + 1; j++) begin
        if (|(unsigned'(2**i) & j)) parity_code_word[i] = parity_code_word[i] ^ data[j - 1];
      end
    end
  end


  always_comb begin : generate_codeword
      codeword = data;
      for (int unsigned i = 0; i < unsigned'($bits(parity_t)); i++) begin
        codeword[2**i-1] = parity_code_word[i];
      end
  end

  assign data_o.code_word = codeword;
  assign data_o.parity = ^codeword;

endmodule