data/full_repos/permissive/50612019/parity_workelement.sv
1: b'%Error: data/full_repos/permissive/50612019/parity_workelement.sv:1: syntax error, unexpected IDENTIFIER, expecting PACKAGE-IDENTIFIER or STRING\nimport CAPI::*;\n       ^~~~\n%Error: data/full_repos/permissive/50612019/parity_workelement.sv:10: syntax error, unexpected IDENTIFIER, expecting TYPE-IDENTIFIER\n  pointer_t stripe1;\n  ^~~~~~~~~\n%Error: Exiting due to 2 error(s)\n'
module parity_workelement (
  input clock,
  input enable,
  input reset,
  input JobInterfaceInput job_in,
  input CommandInterfaceInput command_in,
  output CommandInterfaceOutput command_out,
  input BufferInterfaceInput buffer_in,
  output BufferInterfaceOutput buffer_out,
  input ResponseInterface response);

  state current_state;
  parity_request request;
  longint unsigned offset;
  logic [0:1023] stripe1_data;
  logic [0:1023] stripe2_data;
  logic [0:1023] parity_data;
  logic stripe_valid;

  assign command_out.abt = 3'b000,
         command_out.context_handle = 0,
         buffer_out.read_latency = 1,

         command_out.command_parity = ~^command_out.command,
         command_out.address_parity = ~^command_out.address,
         command_out.tag_parity = ~^command_out.tag,
         parity_data = stripe1_data ^ stripe2_data,
         buffer_out.read_parity = ^buffer_out.read_data;


  always_ff @ (posedge clock)
  begin

    if (reset) begin
      current_state = START;
      command_out.valid <= 0;

    end
    if(enable) begin
      case (current_state)
        START: begin
          command_out.size <= 128;
          command_out.command <= READ_CL_NA;
          command_out.tag <= REQUEST_READ;
          command_out.address <= job_in.address;
          command_out.valid <= 1;
          current_state = WAITING_FOR_REQUEST;
          request.size <= 0;
          request.stripe1 <= 0;
          request.stripe2 <= 0;
          request.parity <= 0;
          offset <= 0;
        end
        WAITING_FOR_REQUEST: begin
          command_out.valid <= 0;

          request.size <= swap_endianness(buffer_in.write_data[0:63]);
          request.stripe1 <= swap_endianness(buffer_in.write_data[64:127]);
          request.stripe2 <= swap_endianness(buffer_in.write_data[128:191]);
          request.parity <= swap_endianness(buffer_in.write_data[192:255]);
          if (response.valid &
              (response.tag == REQUEST_READ)) begin
            current_state <= REQUEST_STRIPES;
          end
        end
        REQUEST_STRIPES: begin
          command_out.valid <= 1;
          command_out.command <= READ_CL_NA;
          stripe_valid <= 0;
          if (command_out.tag == REQUEST_READ |
              command_out.tag == PARITY_WRITE) begin
            command_out.address <= request.stripe1 + offset;
            command_out.tag <= STRIPE1_READ;
          end else begin
            command_out.address <= request.stripe2 + offset;
            command_out.tag <= STRIPE2_READ;
            current_state <= WAITING_FOR_STRIPES;
          end
        end
        WAITING_FOR_STRIPES: begin
          command_out.valid <= 0;
          if (buffer_in.write_valid) begin
            case (buffer_in.write_tag)
              STRIPE1_READ: begin
                if (buffer_in.write_address == 0) begin
                  stripe1_data[0:511] <= buffer_in.write_data;
                end else begin
                  stripe1_data[512:1023] <= buffer_in.write_data;
                end
              end
              STRIPE2_READ: begin
                if (buffer_in.write_address == 0) begin
                  stripe2_data[0:511] <= buffer_in.write_data;
                end else begin
                  stripe2_data[512:1023] <= buffer_in.write_data;
                end
              end
            endcase
          end
          if (response.valid &
              (response.tag == STRIPE1_READ |
               response.tag == STRIPE2_READ)) begin
            if (stripe_valid) begin
              current_state <= WRITE_PARITY;
            end else begin
              stripe_valid <= 1;
            end
          end
        end
        WRITE_PARITY: begin
          if (command_out.tag == PARITY_WRITE) begin
            command_out.valid <= 0;
            if (buffer_in.read_address) begin
              buffer_out.read_data <= parity_data[0:511];
            end else begin
              buffer_out.read_data <= parity_data[512:1023];
            end
            if (response.valid && response.tag == PARITY_WRITE) begin
              if(offset + 128 >= request.size) begin
                current_state <= DONE;
              end else begin
                offset <= offset + 128;
                current_state <= REQUEST_STRIPES;
              end
            end
          end else begin
            command_out.command <= WRITE_NA;
            command_out.size <= 128;
            command_out.address <= request.parity + offset;
            command_out.tag <= PARITY_WRITE;
            command_out.valid <= 1;
          end
        end
        DONE: begin
          $display("Done");
          if (command_out.tag == DONE_WRITE) begin
            command_out.valid <= 0;
          end else begin
            command_out.tag <= DONE_WRITE;
            command_out.size <= 1;
            command_out.address <= job_in.address + 32;
            command_out.valid <= 1;
            buffer_out.read_data[256:263] <= 1;
          end
        end
      endcase
    end
  end

endmodule
module parity_workelement (
  input clock,
  input enable,
  input reset,
  input JobInterfaceInput job_in,
  input CommandInterfaceInput command_in,
  output CommandInterfaceOutput command_out,
  input BufferInterfaceInput buffer_in,
  output BufferInterfaceOutput buffer_out,
  input ResponseInterface response);


  state current_state;
  parity_request request;
  longint unsigned offset;
  logic [0:1023] stripe1_data;
  logic [0:1023] stripe2_data;
  logic [0:1023] parity_data;
  logic stripe_valid;

  assign command_out.abt = 3'b000,
         command_out.context_handle = 0,
         buffer_out.read_latency = 1,

         command_out.command_parity = ~^command_out.command,
         command_out.address_parity = ~^command_out.address,
         command_out.tag_parity = ~^command_out.tag,
         parity_data = stripe1_data ^ stripe2_data,
         buffer_out.read_parity = ^buffer_out.read_data;


  always_ff @ (posedge clock)
  begin

    if (reset) begin
      current_state = START;
      command_out.valid <= 0;

    end
    if(enable) begin
      case (current_state)
        START: begin
          command_out.size <= 128;
          command_out.command <= READ_CL_NA;
          command_out.tag <= REQUEST_READ;
          command_out.address <= job_in.address;
          command_out.valid <= 1;
          current_state = WAITING_FOR_REQUEST;
          request.size <= 0;
          request.stripe1 <= 0;
          request.stripe2 <= 0;
          request.parity <= 0;
          offset <= 0;
        end
        WAITING_FOR_REQUEST: begin
          command_out.valid <= 0;

          request.size <= swap_endianness(buffer_in.write_data[0:63]);
          request.stripe1 <= swap_endianness(buffer_in.write_data[64:127]);
          request.stripe2 <= swap_endianness(buffer_in.write_data[128:191]);
          request.parity <= swap_endianness(buffer_in.write_data[192:255]);
          if (response.valid &
              (response.tag == REQUEST_READ)) begin
            current_state <= REQUEST_STRIPES;
          end
        end
        REQUEST_STRIPES: begin
          command_out.valid <= 1;
          command_out.command <= READ_CL_NA;
          stripe_valid <= 0;
          if (command_out.tag == REQUEST_READ |
              command_out.tag == PARITY_WRITE) begin
            command_out.address <= request.stripe1 + offset;
            command_out.tag <= STRIPE1_READ;
          end else begin
            command_out.address <= request.stripe2 + offset;
            command_out.tag <= STRIPE2_READ;
            current_state <= WAITING_FOR_STRIPES;
          end
        end
        WAITING_FOR_STRIPES: begin
          command_out.valid <= 0;
          if (buffer_in.write_valid) begin
            case (buffer_in.write_tag)
              STRIPE1_READ: begin
                if (buffer_in.write_address == 0) begin
                  stripe1_data[0:511] <= buffer_in.write_data;
                end else begin
                  stripe1_data[512:1023] <= buffer_in.write_data;
                end
              end
              STRIPE2_READ: begin
                if (buffer_in.write_address == 0) begin
                  stripe2_data[0:511] <= buffer_in.write_data;
                end else begin
                  stripe2_data[512:1023] <= buffer_in.write_data;
                end
              end
            endcase
          end
          if (response.valid &
              (response.tag == STRIPE1_READ |
               response.tag == STRIPE2_READ)) begin
            if (stripe_valid) begin
              current_state <= WRITE_PARITY;
            end else begin
              stripe_valid <= 1;
            end
          end
        end
        WRITE_PARITY: begin
          if (command_out.tag == PARITY_WRITE) begin
            command_out.valid <= 0;
            if (buffer_in.read_address) begin
              buffer_out.read_data <= parity_data[0:511];
            end else begin
              buffer_out.read_data <= parity_data[512:1023];
            end
            if (response.valid && response.tag == PARITY_WRITE) begin
              if(offset + 128 >= request.size) begin
                current_state <= DONE;
              end else begin
                offset <= offset + 128;
                current_state <= REQUEST_STRIPES;
              end
            end
          end else begin
            command_out.command <= WRITE_NA;
            command_out.size <= 128;
            command_out.address <= request.parity + offset;
            command_out.tag <= PARITY_WRITE;
            command_out.valid <= 1;
          end
        end
        DONE: begin
          $display("Done");
          if (command_out.tag == DONE_WRITE) begin
            command_out.valid <= 0;
          end else begin
            command_out.tag <= DONE_WRITE;
            command_out.size <= 1;
            command_out.address <= job_in.address + 32;
            command_out.valid <= 1;
            buffer_out.read_data[256:263] <= 1;
          end
        end
      endcase
    end
  end

endmodule