<commit_before>/* Copyright 2017 <NAME> <<EMAIL>> & <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License. */

#ifndef SERIALIZER_H_
#define SERIALIZER_H_

#include<systemc.h>
#include<common/clock_divider.h>

/**
 * Shift register Template
 * @param width size of the shift register
 */
template<int inputs>
  SC_MODULE (serializer) {
    /** Input CLK */
    sc_in_clk clk_in;
    /** Parallel input */
    sc_in<sc_lv<inputs> > par_in;
    /** Serial output */
    sc_out<sc_logic> ser_out;
    /** Output selector */
    uint output_selector;

    /**
     * Serializer Process
     */
    void prc_serializer () {
      sc_lv<inputs> latch;

      latch = par_in;

      ser_out = latch[output_selector];

      output_selector++;

      // If selector overflows reset the counter
      if (output_selector >= inputs) {
        output_selector = 0;
      }
    }

    /**
     * Constructor
     */
    SC_CTOR (serializer) {

      output_selector = 0;

      SC_METHOD (prc_serializer);
      sensitive << clk_in.pos();

    }
  };

#endif<commit_msg>chg: dev: Change Serializer endianness<commit_after>/* Copyright 2017 <NAME> <<EMAIL>> & <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License. */

#ifndef SERIALIZER_H_
#define SERIALIZER_H_

#include<systemc.h>

/**
 * Shift register Template
 * @param width size of the shift register
 */
template<int inputs>
  SC_MODULE (serializer) {
    /** Input CLK */
    sc_in_clk clk_in;
    /** Parallel input */
    sc_in<sc_lv<inputs> > par_in;
    /** Serial output */
    sc_out<sc_logic> ser_out;
    /** Output selector */
    int output_selector;

    /**
     * Serializer Process
     */
    void prc_serializer () {
      sc_lv<inputs> latch;

      latch = par_in;

      ser_out = latch[output_selector];

      output_selector--;

      // If selector overflows reset the counter
      if (output_selector < 0) {
        output_selector = inputs - 1;
      }
    }

    /**
     * Constructor
     */
    SC_CTOR (serializer) {

      output_selector = inputs - 1;

      SC_METHOD (prc_serializer);
      sensitive << clk_in.pos();

    }
  };

#endif
{'fraction_non_alphanumeric': 0.10258043963045556, 'fraction_numerical': 0.00669002867155145, 'mean_word_length': 2.747016706443914, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3597786', 'n_tokens_mistral': 972, 'n_tokens_neox': 929, 'n_words': 308}