17 #include "apb_initiator.h"
18 #include <scc/report.h>
20 using namespace sc_core;
25 uint8_t log2n(uint8_t siz) {
return ((siz > 1) ? 1 + log2n(siz >> 1) : 0); }
29 apb_initiator_b::apb_initiator_b(sc_core::sc_module_name nm,
30 sc_core::sc_port_b<tlm::tlm_fw_transport_if<tlm::tlm_base_protocol_types>>& port,
size_t transfer_width,
34 , transfer_width_in_bytes(transfer_width / 8) {}
36 apb_initiator_b::~apb_initiator_b() =
default;
38 tlm::tlm_sync_enum apb_initiator_b::nb_transport_bw(payload_type& trans, phase_type& phase, sc_core::sc_time& t) {
40 peq.
notify(std::make_tuple(&trans, phase), t);
41 return tlm::TLM_ACCEPTED;
44 void apb_initiator_b::invalidate_direct_mem_ptr(sc_dt::uint64 start_range, sc_dt::uint64 end_range) {}
47 SCCTRACE(SCMOD) <<
"got transport req for id=" << &trans;
50 socket_fw->b_transport(trans, t);
53 SCCTRACE(SCMOD) <<
"start transport req for id=" << &trans;
54 trans.free_all_extensions();
55 tlm::tlm_phase phase{tlm::BEGIN_REQ};
57 auto res = socket_fw->nb_transport_fw(trans, phase, t);
58 if(res == tlm::TLM_COMPLETED || (res == tlm::TLM_UPDATED && phase != tlm::END_REQ && phase != tlm::BEGIN_RESP))
59 SCCFATAL(SCMOD) <<
"target did not respsond with END_REQ or BEGIN_RESP to a BEGIN_REQ";
60 if(res != tlm::TLM_UPDATED || phase != tlm::BEGIN_RESP) {
61 payload_type* gp{
nullptr};
62 while(phase != tlm::BEGIN_RESP) {
63 std::tie(gp, phase) = peq.
get();
65 SCCFATAL(SCMOD) <<
"target did send the wrong transaction";
66 if(phase != tlm::END_REQ && phase != tlm::BEGIN_RESP)
67 SCCFATAL(SCMOD) <<
"target did not respsond with END_REQ or BEGIN_RESP to a BEGIN_REQ";
68 if(phase == tlm::END_REQ)
69 wait(clk_i.posedge_event());
72 phase = tlm::END_RESP;
74 socket_fw->nb_transport_fw(trans, phase, t);
75 SCCTRACE(SCMOD) <<
"finished non-blocking protocol";
76 any_tx_finished.notify(SC_ZERO_TIME);
78 SCCTRACE(SCMOD) <<
"finished transport req for id=" << &trans;
void transport(payload_type &trans, bool blocking)
The forward transport function. It behaves blocking and is re-entrant.
protocol engine implementations
TLM2.0 components modeling APB.
void notify(const TYPE &entry, const sc_core::sc_time &t)
non-blocking push.