17 #ifndef _SPI_SPI_TLM_H_
18 #define _SPI_SPI_TLM_H_
20 #include <cci_configuration>
22 #include <scc/fifo_w_cb.h>
24 #include <scc/report.h>
25 #include <scc/sc_variable.h>
26 #include <tlm/nw/tlm_network_gp.h>
27 #include <tlm/nw/tlm_network_sockets.h>
28 #include <tlm/scc/tlm_gp_shared.h>
29 #include <tlm/scc/tlm_mm.h>
33 enum class SPI_PKT { DATA };
38 : target_id(target_id) {}
45 , target_id(target_id) {}
47 unsigned get_target_id()
const {
return target_id; }
50 unsigned target_id{0};
51 sc_core::sc_time sender_clk_period{sc_core::SC_ZERO_TIME};
56 using tlm_phase_type = ::tlm::tlm_phase;
82 using phase_type = spi_packet_types::tlm_phase_type;
86 sc_core::sc_vector<spi_pkt_initiator_socket<>> isck{
"isck"};
88 cci::cci_param<sc_core::sc_time> channel_delay{
"channel_delay", sc_core::SC_ZERO_TIME,
"delay of the SPI channel"};
90 spi_channel(sc_core::sc_module_name
const& nm,
size_t slave_count)
91 : sc_core::sc_module(nm)
92 , isck{
"isckt", slave_count} {
104 isck.at(trans.get_target_id())->b_transport(trans, t);
107 tlm::tlm_sync_enum nb_transport_fw(
transaction_type& trans, phase_type& phase, sc_core::sc_time& t)
override {
108 SCCTRACE(SCMOD) <<
"Received non-blocking transaction in fw path with phase " << phase.get_name();
109 if(phase == tlm::nw::REQUEST) {
110 auto idx = trans.get_target_id();
111 if(idx < isck.size()) {
112 phase_type ph = tlm::nw::INDICATION;
113 auto ret = isck.at(idx)->nb_transport_fw(trans, ph, t);
114 if(ph == tlm::nw::RESPONSE)
115 phase = tlm::nw::CONFIRM;
118 trans.set_response_status(tlm::TLM_ADDRESS_ERROR_RESPONSE);
119 phase = tlm::nw::CONFIRM;
120 return tlm::TLM_COMPLETED;
123 return tlm::TLM_ACCEPTED;
126 tlm::tlm_sync_enum nb_transport_bw(
transaction_type& trans, phase_type& phase, sc_core::sc_time& t)
override {
127 SCCTRACE(SCMOD) <<
"Received non-blocking transaction in bw path with phase " << phase.get_name();
128 if(phase == tlm::nw::RESPONSE) {
129 phase_type ph = tlm::nw::CONFIRM;
130 return tsck->nb_transport_bw(trans, ph, t);
132 return tlm::TLM_ACCEPTED;
135 unsigned int transport_dbg(
transaction_type& trans)
override {
return isck.at(trans.get_target_id())->transport_dbg(trans); }