scc 2025.09
SystemC components library
ordered_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 <axi/pe/axi_target_pe.h>
20#include <cci_configuration>
21#include "target_info_if.h"
22
24namespace axi {
26namespace pe {
27class rate_limiting_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
39 cci::cci_param<int>& rd_resp_delay;
44 cci::cci_param<int>& wr_resp_delay;
48 cci::cci_param<double> rd_bw_limit_byte_per_sec{"rd_bw_limit_byte_per_sec", -1.0};
52 cci::cci_param<double> wr_bw_limit_byte_per_sec{"wr_bw_limit_byte_per_sec", -1.0};
56 cci::cci_param<double> total_bw_limit_byte_per_sec{"total_bw_limit_byte_per_sec", -1.0};
57
58 rate_limiting_buffer(const sc_core::sc_module_name& nm, cci::cci_param<int>& rd_resp_delay, cci::cci_param<int>& wr_resp_delay);
59
60 virtual ~rate_limiting_buffer() = default;
67 void transport(tlm::tlm_generic_payload& payload, bool lt_transport = false) override;
74 void snoop_resp(tlm::tlm_generic_payload& payload, bool sync = false) override {}
75protected:
76 sc_core::sc_clock* clk_if{nullptr};
77 sc_core::sc_time time_per_byte_rd, time_per_byte_wr, time_per_byte_total;
80 scc::fifo_w_cb<std::tuple<tlm::tlm_generic_payload*, unsigned>> wr_req2resp_fifo{"wr_req2resp_fifo"};
83 scc::fifo_w_cb<tlm::tlm_generic_payload*> wr_resp_fifo{"wr_resp_fifo"};
84 scc::ordered_semaphore total_arb{1};
85 double total_residual_clocks{0.0};
86 void end_of_elaboration() override;
87 void start_of_simulation() override;
88
89 void process_req2resp_fifos();
90 void start_rd_resp_thread();
91 void start_wr_resp_thread();
92
93};
94
98template <unsigned int BUSWIDTH = 32, typename TYPES = axi::axi_protocol_types, int N = 1,
99 sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND>
100class ordered_target : public sc_core::sc_module, public target_info_if {
101public:
102 using base = axi_target_pe;
103 using payload_type = base::payload_type;
104 using phase_type = base::phase_type;
105 sc_core::sc_in<bool> clk_i{"clk_i"};
106
108
113 ordered_target(const sc_core::sc_module_name& nm)
114 : sc_core::sc_module(nm)
115 , pe("pe", BUSWIDTH)
116 , rate_limit_buffer("rate_limit_buffer", pe.rd_resp_delay, pe.wr_resp_delay){
117 sckt(pe);
118 pe.clk_i(clk_i);
119 rate_limit_buffer.clk_i(clk_i);
120 pe.fw_o(rate_limit_buffer.fw_i);
121 rate_limit_buffer.bw_o(pe.bw_i);
122 }
123
124 ordered_target() = delete;
125
126 ordered_target(ordered_target const&) = delete;
127
128 ordered_target(ordered_target&&) = delete;
129
130 ordered_target& operator=(ordered_target const&) = delete;
131
132 ordered_target& operator=(ordered_target&&) = delete;
133
134 size_t get_outstanding_tx_count() override { return pe.getAllOutStandingTx();}
135
136protected:
137 void end_of_elaboration(){
138 auto* ifs = sckt.get_base_port().get_interface(0);
139 sc_assert(ifs!=nullptr);
140 pe.set_bw_interface(ifs);
141 }
142public:
143 axi_target_pe pe;
144 rate_limiting_buffer rate_limit_buffer;
145};
146} // namespace pe
147} // namespace axi
ordered_target(const sc_core::sc_module_name &nm)
the constructor
cci::cci_param< int > & rd_resp_delay
the latency between request and response phase. Will be overwritten by the return of the callback fun...
scc::fifo_w_cb< std::tuple< tlm::tlm_generic_payload *, unsigned > > rd_req2resp_fifo
queues realizing the min latency
cci::cci_param< double > total_bw_limit_byte_per_sec
the bandwidth limit for read accesses. A value of -1 disables the limiting
void snoop_resp(tlm::tlm_generic_payload &payload, bool sync=false) override
scc::fifo_w_cb< tlm::tlm_generic_payload * > rd_resp_fifo
queues to handle bandwidth limit
void transport(tlm::tlm_generic_payload &payload, bool lt_transport=false) override
cci::cci_param< double > rd_bw_limit_byte_per_sec
the bandwidth limit for read accesses. A value of -1 disables the limiting
cci::cci_param< double > wr_bw_limit_byte_per_sec
the bandwidth limit for write accesses. A value of -1 disables the limiting
cci::cci_param< int > & wr_resp_delay
the latency between request and response phase. Will be overwritten by the return of the callback fun...
fifo with callbacks
Definition fifo_w_cb.h:38
The ordered_semaphore primitive channel class.
protocol engine implementations
TLM2.0 components modeling AHB.