<commit_before>// vim : set fileencoding=utf-8 expandtab noai ts=4 sw=4 :
/// @addtogroup ahbctrl AHBCtrl
/// @{
/// @file ahbctrl.h
/// AHB Controller / Bus model. The decoder collects all AHB request from the
/// masters and forwards them to the appropriate slave.
///
/// @date 2010-2014
/// @copyright All rights reserved.
///            Any reproduction, use, distribution or disclosure of this
///            program, without the express, prior written consent of the
///            authors is strictly prohibited.
/// @author <NAME>
///

#ifndef MODELS_AHBCTRL_AHBCTRL_H_
#define MODELS_AHBCTRL_AHBCTRL_H_

#include <amba.h>
#include "common/gs_config.h"
#include <tlm.h>
#include <map>

#include "models/utils/ahbdevice.h"
#include "models/utils/clkdevice.h"
#include "signalkit/signalkit.h"
#include "common/msclogger.h"
#include "common/socrocket.h"
#include "common/gs_config.h"

class AHBCtrl : public sc_core::sc_module, public CLKDevice {
  public:
    GC_HAS_CALLBACKS();
    SC_HAS_PROCESS(AHBCtrl);
    SK_HAS_SIGNALS(AHBCtrl);

    // AMBA sockets
    // ------------------

    /// AHB slave multi-socket
    amba::amba_slave_socket<32, 0>  ahbIN;
    /// AHB master multi-socket
    amba::amba_master_socket<32, 0> ahbOUT;
    /// Broadcast of master_id and write address for dcache snooping
    signal<t_snoop>::out snoop;

    // Public functions
    // ----------------

    /// TLM blocking transport method
    void b_transport(
        uint32_t id,
        tlm::tlm_generic_payload &gp,  // NOLINT(runtime/references)
        sc_core::sc_time &delay);      // NOLINT(runtime/references)

    /// TLM non-blocking transport forward (for AHB slave multi-sock)
    tlm::tlm_sync_enum nb_transport_fw(
        uint32_t id,
        tlm::tlm_generic_payload &gp,  // NOLINT(runtime/references)
        tlm::tlm_phase &phase,         // NOLINT(runtime/references)
        sc_core::sc_time &delay);      // NOLINT(runtime/references)

    /// TLM non-blocking transport backward (for AHB master multi-sock)
    tlm::tlm_sync_enum nb_transport_bw(
        uint32_t id, tlm::tlm_generic_payload &gp,  // NOLINT(runtime/references)
        tlm::tlm_phase &phase,                      // NOLINT(runtime/references)
        sc_core::sc_time &delay);                   // NOLINT(runtime/references)

    /// TLM debug interface
    unsigned int transport_dbg(uint32_t id, tlm::tlm_generic_payload &gp);  // NOLINT(runtime/references)

    /// The arbiter thread. Responsible for arbitrating transactions in AT mode.
    void arbitrate();

    void AcceptThread();

    void RequestThread();

    void ResponseThread();

    void EndResponseThread();

    /// Collect common transport statistics.
    void transport_statistics(tlm::tlm_generic_payload &gp);  // NOLINT(runtime/references)

    /// Helper function - prints pending requests in arbiter
    void print_requests();

    /// Print common transport statistics.
    void print_transport_statistics(const char *name) const;

    /// Constructor
    AHBCtrl(
      sc_core::sc_module_name nm,  ///< SystemC name
      unsigned int ioaddr,        ///< The MSB address of the I/O area
      unsigned int iomask,        ///< The I/O area address mask
      unsigned int cfgaddr,       ///< The MSB address of the configuration area (PNP)
      unsigned int cfgmask,       ///< The address mask of the configuration area
      bool rrobin,                ///< 1 - round robin, 0 - fixed priority arbitration (only AT)
      bool split,                 ///< Enable support for AHB SPLIT response (only AT)
      unsigned int defmast,       ///< ID of the default master
      bool ioen,                  ///< AHB I/O area enable
      bool fixbrst,               ///< Enable support for fixed-length bursts
      bool fpnpen,                ///< Enable full decoding of PnP configuration records.
      bool mcheck,                ///< Check if there are any intersections between core memory regions.
      bool pow_mon,               ///< Enable power monitoring
      amba::amba_layer_ids ambaLayer);

    /// Reset Callback<commit_msg>AHBCtrl: constructor comments<commit_after>// vim : set fileencoding=utf-8 expandtab noai ts=4 sw=4 :
/// @addtogroup ahbctrl AHBCtrl
/// @{
/// @file ahbctrl.h
/// AHB Controller / Bus model. The decoder collects all AHB request from the
/// masters and forwards them to the appropriate slave.
///
/// @date 2010-2014
/// @copyright All rights reserved.
///            Any reproduction, use, distribution or disclosure of this
///            program, without the express, prior written consent of the
///            authors is strictly prohibited.
/// @author <NAME>
///

#ifndef MODELS_AHBCTRL_AHBCTRL_H_
#define MODELS_AHBCTRL_AHBCTRL_H_

#include <amba.h>
#include "common/gs_config.h"
#include <tlm.h>
#include <map>

#include "models/utils/ahbdevice.h"
#include "models/utils/clkdevice.h"
#include "signalkit/signalkit.h"
#include "common/msclogger.h"
#include "common/socrocket.h"
#include "common/gs_config.h"

class AHBCtrl : public sc_core::sc_module, public CLKDevice {
  public:
    GC_HAS_CALLBACKS();
    SC_HAS_PROCESS(AHBCtrl);
    SK_HAS_SIGNALS(AHBCtrl);

    // AMBA sockets
    // ------------------

    /// AHB slave multi-socket
    amba::amba_slave_socket<32, 0>  ahbIN;
    /// AHB master multi-socket
    amba::amba_master_socket<32, 0> ahbOUT;
    /// Broadcast of master_id and write address for dcache snooping
    signal<t_snoop>::out snoop;

    // Public functions
    // ----------------

    /// TLM blocking transport method
    void b_transport(
        uint32_t id,
        tlm::tlm_generic_payload &gp,  // NOLINT(runtime/references)
        sc_core::sc_time &delay);      // NOLINT(runtime/references)

    /// TLM non-blocking transport forward (for AHB slave multi-sock)
    tlm::tlm_sync_enum nb_transport_fw(
        uint32_t id,
        tlm::tlm_generic_payload &gp,  // NOLINT(runtime/references)
        tlm::tlm_phase &phase,         // NOLINT(runtime/references)
        sc_core::sc_time &delay);      // NOLINT(runtime/references)

    /// TLM non-blocking transport backward (for AHB master multi-sock)
    tlm::tlm_sync_enum nb_transport_bw(
        uint32_t id, tlm::tlm_generic_payload &gp,  // NOLINT(runtime/references)
        tlm::tlm_phase &phase,                      // NOLINT(runtime/references)
        sc_core::sc_time &delay);                   // NOLINT(runtime/references)

    /// TLM debug interface
    unsigned int transport_dbg(uint32_t id, tlm::tlm_generic_payload &gp);  // NOLINT(runtime/references)

    /// The arbiter thread. Responsible for arbitrating transactions in AT mode.
    void arbitrate();

    void AcceptThread();

    void RequestThread();

    void ResponseThread();

    void EndResponseThread();

    /// Collect common transport statistics.
    void transport_statistics(tlm::tlm_generic_payload &gp);  // NOLINT(runtime/references)

    /// Helper function - prints pending requests in arbiter
    void print_requests();

    /// Print common transport statistics.
    void print_transport_statistics(const char *name) const;

    /// Constructor
    AHBCtrl(
      sc_core::sc_module_name nm,  ///< SystemC name
      uint32_t ioaddr = 0xFFF,     ///< The MSB address of the I/O area
      uint32_t iomask = 0xFFF,     ///< The I/O area address mask
      uint32_t cfgaddr = 0xFF0,    ///< The MSB address of the configuration area (PNP)
      uint32_t cfgmask = 0xFF0,    ///< The address mask of the configuration area
      bool rrobin = false,         ///< 1 - round robin, 0 - fixed priority arbitration (only AT)
      bool split = false,          ///< Enable support for AHB SPLIT response (only AT)
      uint32_t defmast = 0,        ///< ID of the default master
      bool ioen = true,            ///< AHB I/O area enable
      bool fixbrst = false,        ///< Enable support for fixed-length bursts
      bool fpnpen = true,          ///< Enable full decoding of PnP configuration records.
      bool mcheck = true,          ///< Check if there are any intersections between core memory regions.
      bool pow_mon = false,        ///< Enable power monitoring
      amba::amba_layer_ids ambaLayer = amba::amba_LT);

    /// Reset Callback
{'fraction_non_alphanumeric': 0.11466666666666667, 'fraction_numerical': 0.008606060606060607, 'mean_word_length': 2.436484798000833, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '2065959', 'n_tokens_mistral': 2639, 'n_tokens_neox': 2486, 'n_words': 713}