19 #ifndef SC_INCLUDE_DYNAMIC_PROCESSES
20 #define SC_INCLUDE_DYNAMIC_PROCESSES
24 #include <axi/fsm/base.h>
27 #include <scc/mt19937_rng.h>
28 #include <scc/ordered_semaphore.h>
29 #include <scc/sc_variable.h>
30 #include <tlm/scc/pe/intor_if.h>
31 #include <tlm_utils/peq_with_cb_and_phase.h>
32 #include <unordered_set>
39 inline unsigned get_cci_randomized_value(cci::cci_param<int>
const& p) {
52 using payload_type = axi::axi_protocol_types::tlm_payload_type;
53 using phase_type = axi::axi_protocol_types::tlm_phase_type;
55 sc_core::sc_in<bool> clk_i{
"clk_i"};
57 sc_core::sc_port<tlm::scc::pe::intor_fw_nb, 1, sc_core::SC_ZERO_OR_MORE_BOUND> fw_o{
"fw_o"};
59 sc_core::sc_export<tlm::scc::pe::intor_bw_nb> bw_i{
"bw_i"};
94 void b_transport(payload_type& trans, sc_core::sc_time& t)
override;
96 tlm::tlm_sync_enum nb_transport_fw(payload_type& trans, phase_type& phase, sc_core::sc_time& t)
override;
98 bool get_direct_mem_ptr(payload_type& trans, tlm::tlm_dmi& dmi_data)
override;
100 unsigned int transport_dbg(payload_type& trans)
override;
111 void set_operation_cb(std::function<
unsigned(payload_type& trans)> cb) { operation_cb = cb; }
140 explicit axi_target_pe(
const sc_core::sc_module_name& nm,
size_t transfer_width, flavor_e flavor = flavor_e::AXI);
144 inline unsigned getAllOutStandingTx()
const {
145 return outstanding_rd_tx + outstanding_wr_tx + outstanding_ign_tx;
149 axi_target_pe() =
delete;
151 axi_target_pe(axi_target_pe
const&) =
delete;
153 axi_target_pe(axi_target_pe&&) =
delete;
155 axi_target_pe& operator=(axi_target_pe
const&) =
delete;
157 axi_target_pe& operator=(axi_target_pe&&) =
delete;
159 void end_of_elaboration()
override;
161 void start_of_simulation()
override;
173 unsigned operations_callback(payload_type& trans);
176 std::function<unsigned(payload_type& trans)> operation_cb;
179 void process_req2resp_fifos();
180 sc_core::sc_fifo<payload_type*> rd_resp_fifo{1}, wr_resp_fifo{1};
181 void start_rd_resp_thread();
182 void start_wr_resp_thread();
183 sc_core::sc_fifo<std::tuple<fsm::fsm_handle*, axi::fsm::protocol_time_point_e>> wr_resp_beat_fifo{128},
184 rd_resp_beat_fifo{128};
186 void send_wr_resp_beat_thread();
187 void send_rd_resp_beat_thread();
189 sc_core::sc_clock* clk_if{
nullptr};
190 std::unique_ptr<bw_intor_impl> bw_intor;
191 std::array<unsigned, 3> outstanding_cnt{{0, 0, 0}};
197 case tlm::TLM_READ_COMMAND:
198 return outstanding_rd_tx;
199 case tlm::TLM_WRITE_COMMAND:
200 return outstanding_wr_tx;
202 return outstanding_ign_tx;
207 case tlm::TLM_READ_COMMAND:
208 return outstanding_rd_tx;
209 case tlm::TLM_WRITE_COMMAND:
210 return outstanding_wr_tx;
212 return outstanding_ign_tx;
215 std::array<tlm::tlm_generic_payload*, 3> stalled_tx{
nullptr,
nullptr,
nullptr};
216 std::array<axi::fsm::protocol_time_point_e, 3> stalled_tp{{axi::fsm::CB_CNT, axi::fsm::CB_CNT, axi::fsm::CB_CNT}};
217 void nb_fw(payload_type& trans,
const phase_type& phase) {
218 auto delay = sc_core::SC_ZERO_TIME;
219 base::nb_fw(trans, phase, delay);
221 tlm_utils::peq_with_cb_and_phase<axi_target_pe> fw_peq{
this, &axi_target_pe::nb_fw};
222 std::unordered_set<unsigned> active_rdresp_id;
cci::cci_param< int > rd_addr_accept_delay
the latency between between BEGIN_REQ and END_REQ (ARVALID to ARREADY) -> APR
cci::cci_param< int > wr_data_accept_delay
the latency between between BEGIN(_PARTIAL)_REQ and END(_PARTIAL)_REQ (AWVALID to AWREADY and WVALID ...
cci::cci_param< bool > rd_data_interleaving
enable data interleaving on read responses if rd_data_beat_delay is greater than 0
const sc_core::sc_event & tx_finish_event()
fsm::fsm_handle * create_fsm_handle() override
void set_operation_cb(std::function< unsigned(payload_type &trans)> cb)
Set the operation callback function.
void operation_resp(payload_type &trans, unsigned clk_delay=0)
cci::cci_param< int > rd_data_beat_delay
the latency between between END(_PARTIAL)_RESP and BEGIN(_PARTIAL)_RESP (RREADY to RVALID) -> RBV
void setup_callbacks(fsm::fsm_handle *) override
cci::cci_param< int > rd_resp_delay
the latency between request and response phase. Will be overwritten by the return of the callback fun...
cci::cci_param< unsigned > max_outstanding_tx
the number of supported outstanding transactions. If this limit is reached the target starts to do ba...
cci::cci_param< int > wr_resp_delay
the latency between request and response phase. Will be overwritten by the return of the callback fun...
static uint64_t uniform()
The ordered_semaphore primitive channel class.
TLM2.0 components modeling AHB.
tlm::tlm_bw_transport_if< TYPES > axi_bw_transport_if
alias declaration for the backward interface:
tlm::tlm_fw_transport_if< TYPES > axi_fw_transport_if
alias declaration for the forward interface
base class of all AXITLM based adapters and interfaces.
void process_fsm_clk_queue()
processes the fsm_clk_queue and triggers the FSM accordingly. Should be registered as rising-edge clo...