19 #include <axi/axi_tlm.h>
20 #include <axi/fsm/protocol_fsm.h>
21 #include <tlm/scc/pe/intor_if.h>
22 #include <scc/ordered_semaphore.h>
25 #include <tlm_utils/peq_with_get.h>
27 #include <unordered_map>
33 public sc_core::sc_module,
39 using payload_type = axi::axi_protocol_types::tlm_payload_type;
40 using phase_type = axi::axi_protocol_types::tlm_phase_type;
42 sc_core::sc_in<bool> clk_i{
"clk_i"};
44 sc_core::sc_export<tlm::scc::pe::intor_fw_b> fw_i{
"fw_i"};
46 sc_core::sc_port<tlm::scc::pe::intor_bw_b, 1, sc_core::SC_ZERO_OR_MORE_BOUND> bw_o{
"bw_o"};
48 void b_snoop(payload_type& trans, sc_core::sc_time& t)
override;
50 tlm::tlm_sync_enum nb_transport_bw(payload_type& trans, phase_type& phase, sc_core::sc_time& t)
override;
52 void invalidate_direct_mem_ptr(sc_dt::uint64 start_range, sc_dt::uint64 end_range)
override;
54 size_t get_transferwith_in_bytes()
const {
return transfer_width_in_bytes; }
64 void transport(payload_type& trans,
bool blocking)
override;
71 void snoop_resp(payload_type& trans,
bool sync =
false)
override;
74 size_t transfer_width, flavor_e flavor);
91 sc_core::sc_attribute<bool> data_interleaving{
"data_interleaving",
false};
93 sc_core::sc_attribute<unsigned>
artv{
"artv", 1};
95 sc_core::sc_attribute<unsigned>
awtv{
"awtv", 1};
97 sc_core::sc_attribute<unsigned>
wbv{
"wbv", 1};
99 sc_core::sc_attribute<unsigned>
rbr{
"rbr", 0};
101 sc_core::sc_attribute<unsigned>
br{
"br", 0};
103 sc_core::sc_attribute<unsigned>
rla{
"rla", 1};
105 sc_core::sc_attribute<unsigned>
ba{
"ba", 1};
120 void add_protocol_cb(axi::fsm::protocol_time_point_e e, std::function<
void(payload_type&,
bool)> cb) {
121 assert(e < axi::fsm::CB_CNT);
127 unsigned calculate_beats(payload_type& p) {
128 sc_assert(p.get_data_length() > 0);
129 return p.get_data_length() < transfer_width_in_bytes ? 1 : p.get_data_length() / transfer_width_in_bytes;
134 const size_t transfer_width_in_bytes;
136 const flavor_e flavor;
138 sc_core::sc_port_b<axi::axi_fw_transport_if<axi_protocol_types>>& socket_fw;
141 payload_type* active_tx{
nullptr};
144 std::unordered_map<void*, tx_state*> tx_state_by_tx;
145 std::unordered_map<unsigned, scc::ordered_semaphore*> id_mtx;
147 tlm_utils::peq_with_get<payload_type> snp_peq{
"snp_peq"};
149 std::unordered_map<void*, tx_state*> snp_state_by_id;
157 sc_core::sc_event any_tx_finished;
159 sc_core::sc_time clk_period{10, sc_core::SC_NS};
162 sc_core::sc_clock* clk_if{
nullptr};
163 void end_of_elaboration()
override;
164 void clk_counter() { m_clock_counter++; }
165 unsigned get_clk_cnt() {
return m_clock_counter; }
169 unsigned m_clock_counter{0};
170 unsigned m_prev_clk_cnt{0};
171 unsigned snoops_in_flight{0};
173 std::array<std::function<void(payload_type&,
bool)>, axi::fsm::CB_CNT> protocol_cb;
180 sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND>
185 using payload_type = base::payload_type;
186 using phase_type = base::phase_type;
192 :
axi_initiator_b(nm, socket_.get_base_port(), BUSWIDTH, flavor_e::AXI)
215 sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND>
220 using payload_type = base::payload_type;
221 using phase_type = base::phase_type;
227 :
axi_initiator_b(nm, socket_.get_base_port(), BUSWIDTH, flavor_e::ACEL)
250 sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND>
255 using payload_type = base::payload_type;
256 using phase_type = base::phase_type;
262 :
axi_initiator_b(nm, socket_.get_base_port(), BUSWIDTH, flavor_e::ACE)
ace_initiator(const sc_core::sc_module_name &nm, axi::ace_initiator_socket< BUSWIDTH, TYPES, N, POL > &socket_)
the constructor
ace_lite_initiator(const sc_core::sc_module_name &nm, axi::axi_initiator_socket< BUSWIDTH, TYPES, N, POL > &socket_)
the constructor
sc_core::sc_attribute< unsigned > artv
Read address valid to next read address valid.
void snoop_resp(payload_type &trans, bool sync=false) override
triggers a non-blocking snoop response if the snoop callback does not do so.
sc_core::sc_attribute< unsigned > rbr
Read data valid to same beat ready.
void add_protocol_cb(axi::fsm::protocol_time_point_e e, std::function< void(payload_type &, bool)> cb)
register a callback for a certain time point
sc_core::sc_attribute< unsigned > ba
Write response handshake to acknowledge.
sc_core::sc_attribute< unsigned > rla
Read last data handshake to acknowledge.
sc_core::sc_attribute< unsigned > awtv
Write address valid to next write address valid.
sc_core::sc_attribute< bool > enable_id_serializing
Quirks enable.
sc_core::sc_attribute< unsigned > br
Write response valid to ready.
sc_core::sc_attribute< unsigned > wbv
Write data handshake to next beat valid.
void transport(payload_type &trans, bool blocking) override
The forward transport function. It behaves blocking and is re-entrant.
sc_core::sc_attribute< unsigned > outstanding_snoops
number of snoops which can be handled
axi_initiator(const sc_core::sc_module_name &nm, axi::axi_initiator_socket< BUSWIDTH, TYPES, N, POL > &socket_)
the constructor
The ordered_semaphore primitive channel class.
TLM2.0 components modeling AHB.
tlm::tlm_fw_transport_if< TYPES > axi_fw_transport_if
alias declaration for the forward interface
The AXI protocol traits class. Since the protocoll defines additional non-ignorable phases a dedicate...