19 #include <chi/chi_tlm.h> 
   20 #include <tlm/scc/pe/intor_if.h> 
   21 #include <scc/ordered_semaphore.h> 
   23 #include <scc/sc_variable.h> 
   24 #include <cci_configuration> 
   26 #include <tlm_utils/peq_with_get.h> 
   28 #include <unordered_map> 
   44         public sc_core::sc_module,
 
   49     using payload_type = chi::chi_protocol_types::tlm_payload_type;
 
   50     using phase_type = chi::chi_protocol_types::tlm_phase_type;
 
   51     using cb_function_t = std::function<void(chi::pe::channel_e, payload_type&)>;
 
   53     sc_core::sc_in<bool> clk_i{
"clk_i"};
 
   55     sc_core::sc_export<tlm::scc::pe::intor_fw_b> fw_i{
"fw_i"};
 
   57     sc_core::sc_port<tlm::scc::pe::intor_bw_b, 1, sc_core::SC_ZERO_OR_MORE_BOUND> bw_o{
"bw_o"};
 
   59     void b_snoop(payload_type& trans, sc_core::sc_time& t) 
override;
 
   61     tlm::tlm_sync_enum nb_transport_bw(payload_type& trans, phase_type& phase, sc_core::sc_time& t) 
override;
 
   63     void invalidate_direct_mem_ptr(sc_dt::uint64 start_range, sc_dt::uint64 end_range) 
override;
 
   65     size_t get_transferwith_in_bytes()
 const { 
return transfer_width_in_bytes; }
 
   75     void transport(payload_type& trans, 
bool blocking) 
override;
 
   82     void snoop_resp(payload_type& trans, 
bool sync = 
false) 
override;
 
   99     cci::cci_param<unsigned> src_id{
"src_id", 1};
 
  101     cci::cci_param<unsigned> tgt_id{
"tgt_id", 0}; 
 
  103     cci::cci_param<bool> data_interleaving{
"data_interleaving", 
true};
 
  105     cci::cci_param<bool> strict_income_order{
"strict_income_order", 
false};
 
  107     cci::cci_param<bool> use_legacy_mapping{
"use_legacy_mapping", 
false};
 
  109     cci::cci_param<unsigned> snp_req_credit_limit{
"snp_req_credit_limit", std::numeric_limits<unsigned>::max()};
 
  111     void add_protocol_cb(channel_e e, cb_function_t cb) {
 
  116     void end_of_elaboration()
 override { clk_if = 
dynamic_cast<sc_core::sc_clock*
>(clk_i.get_interface()); }
 
  118     unsigned calculate_beats(payload_type& p) {
 
  120         return p.get_data_length() < transfer_width_in_bytes ? 1 : p.get_data_length() / transfer_width_in_bytes;
 
  123     void snoop_dispatch();
 
  125     void snoop_handler(payload_type* trans);
 
  127     const size_t transfer_width_in_bytes;
 
  129     std::string instance_name;
 
  137     void grant_credit(
unsigned amount=1);
 
  139     sc_core::sc_port_b<chi::chi_fw_transport_if<chi_protocol_types>>& socket_fw;
 
  144         : peq(sc_core::sc_gen_unique_name(name.c_str())) {}
 
  146     std::unordered_map<uintptr_t, tx_state*> tx_state_by_trans;
 
  148     std::vector<tx_state*> tx_state_pool;
 
  150     std::unordered_map<unsigned, scc::ordered_semaphore> active_tx_by_id;
 
  154     tlm_utils::peq_with_get<payload_type> snp_peq{
"snp_peq"}, snp_dispatch_que{
"snp_dispatch_que"};
 
  156     unsigned thread_avail{0}, thread_active{0};
 
  170     sc_core::sc_event any_tx_finished;
 
  172     sc_core::sc_time clk_period{10, sc_core::SC_NS};
 
  177     void send_comp_ack(payload_type& trans, tx_state*& txs);
 
  179     unsigned get_clk_cnt() { 
return m_clock_counter; }
 
  181     void create_data_ext(payload_type& trans);
 
  183     void exec_read_write_protocol(
const unsigned int txn_id, payload_type& trans,
 
  185     void exec_atomic_protocol(
const unsigned int txn_id, payload_type& trans,
 
  187     void send_cresp_response(payload_type& trans);
 
  190     unsigned m_clock_counter{0};
 
  191     unsigned m_prev_clk_cnt{0};
 
  193     sc_core::sc_clock* clk_if{
nullptr};
 
  200     std::array<cb_function_t, chi::pe::CH_CNT> protocol_cb;
 
  207           sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND>
 
  212     using payload_type = base::payload_type;
 
  213     using phase_type = base::phase_type;
 
  222         this->instance_name = socket.name();
 
void transport(payload_type &trans, bool blocking) override
The forward transport function. It behaves blocking and is re-entrant.
void snoop_resp(payload_type &trans, bool sync=false) override
triggers a non-blocking snoop response if the snoop callback does not do so.
chi_rn_initiator(const sc_core::sc_module_name &nm, chi::chi_initiator_socket< BUSWIDTH, TYPES, N, POL > &socket_)
the constructor
The ordered_semaphore primitive channel class.
TLM2.0 components modeling CHI.
tlm::tlm_fw_transport_if< TYPES > chi_fw_transport_if
alias declaration for the forward interface
The AXI protocol traits class. Since the protocoll defines additional non-ignorable phases a dedicate...