scc 2025.09
SystemC components library
replay_target.h
1/*
2 * Copyright 2020-2022 Arteris IP
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.axi_util.cpp
15 */
16
17#pragma once
18
19#include "target_info_if.h"
20#include <axi/pe/axi_target_pe.h>
21#include <cci_configuration>
22
24namespace axi {
26namespace pe {
27class replay_buffer : public sc_core::sc_module, tlm::scc::pe::intor_fw_nb {
28public:
29 sc_core::sc_in<bool> clk_i{"clk_i"};
30
31 sc_core::sc_export<tlm::scc::pe::intor_fw_nb> fw_i{"fw_i"};
32
33 sc_core::sc_port<tlm::scc::pe::intor_bw_nb, 1, sc_core::SC_ZERO_OR_MORE_BOUND> bw_o{"bw_o"};
34
35 cci::cci_param<std::string> replay_file_name{"replay_file_name", ""};
36
37 replay_buffer(const sc_core::sc_module_name& nm);
44 void transport(tlm::tlm_generic_payload& payload, bool lt_transport = false) override;
51 void snoop_resp(tlm::tlm_generic_payload& payload, bool sync = false) override {}
52
53 void end_of_reset() { reset_end_cycle = sc_core::sc_time_stamp() / clk_if->period(); }
54
55protected:
56 sc_core::sc_clock* clk_if{nullptr};
57 uint64_t reset_end_cycle{0};
58 using entry_t = std::tuple<uint64_t, unsigned>;
59 std::vector<std::vector<entry_t>> rd_sequence, wr_sequence;
60 sc_core::sc_time time_per_byte_rd, time_per_byte_wr, time_per_byte_total;
63 scc::fifo_w_cb<std::tuple<tlm::tlm_generic_payload*, unsigned>> wr_req2resp_fifo{"wr_req2resp_fifo"};
66 scc::fifo_w_cb<tlm::tlm_generic_payload*> wr_resp_fifo{"wr_resp_fifo"};
67 scc::ordered_semaphore total_arb{1};
68 double total_residual_clocks{0.0};
69 void end_of_elaboration() override;
70 void start_of_simulation() override;
71 void process_req2resp_fifos();
72 void start_rd_resp_thread();
73 void start_wr_resp_thread();
74};
75
79template <unsigned int BUSWIDTH = 32, typename TYPES = axi::axi_protocol_types, int N = 1,
80 sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND>
81class replay_target : public sc_core::sc_module, public target_info_if {
82public:
83 using base = axi_target_pe;
84 using payload_type = base::payload_type;
85 using phase_type = base::phase_type;
86
87 sc_core::sc_in<bool> clk_i{"clk_i"};
88
89 sc_core::sc_in<bool> rst_i{"rst_i"};
90
92
97 replay_target(const sc_core::sc_module_name& nm)
98 : sc_core::sc_module(nm)
99 , pe("pe", BUSWIDTH)
100 , repl_buffer("repl_buffer") {
101 sckt(pe);
102 pe.clk_i(clk_i);
103 repl_buffer.clk_i(clk_i);
104 pe.fw_o(repl_buffer.fw_i);
105 repl_buffer.bw_o(pe.bw_i);
106#if SYSTEMC_VERSION < 20250221
107 SC_HAS_PROCESS(replay_target);
108#endif
109 SC_METHOD(end_of_reset);
110 sensitive << rst_i.neg();
111 }
112
113 replay_target() = delete;
114
115 replay_target(replay_target const&) = delete;
116
117 replay_target(replay_target&&) = delete;
118
119 replay_target& operator=(replay_target const&) = delete;
120
121 replay_target& operator=(replay_target&&) = delete;
122
123 size_t get_outstanding_tx_count() override { return pe.getAllOutStandingTx(); }
124
125protected:
126 void end_of_reset() { repl_buffer.end_of_reset(); }
127 void end_of_elaboration() {
128 auto* ifs = sckt.get_base_port().get_interface(0);
129 sc_assert(ifs != nullptr);
130 pe.set_bw_interface(ifs);
131 }
132
133public:
134 axi_target_pe pe;
135 replay_buffer repl_buffer;
136};
137} // namespace pe
138} // namespace axi
void transport(tlm::tlm_generic_payload &payload, bool lt_transport=false) override
scc::fifo_w_cb< tlm::tlm_generic_payload * > rd_resp_fifo
queues to handle bandwidth limit
void snoop_resp(tlm::tlm_generic_payload &payload, bool sync=false) override
scc::fifo_w_cb< std::tuple< tlm::tlm_generic_payload *, unsigned > > rd_req2resp_fifo
queues realizing the latencies
replay_target(const sc_core::sc_module_name &nm)
the constructor
fifo with callbacks
Definition fifo_w_cb.h:38
The ordered_semaphore primitive channel class.
protocol engine implementations
TLM2.0 components modeling AHB.