scc 2026.07
SystemC components library
reordering_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#pragma once
17
18#include "target_info_if.h"
19#include <axi/pe/axi_target_pe.h>
20
22namespace axi {
24namespace pe {
25class tx_reorderer : public sc_core::sc_module, tlm::scc::pe::intor_fw_nb {
26public:
27 sc_core::sc_in<bool> clk_i{"clk_i"};
28
29 sc_core::sc_export<tlm::scc::pe::intor_fw_nb> fw_i{"fw_i"};
30
31 sc_core::sc_port<tlm::scc::pe::intor_bw_nb, 1, sc_core::SC_ZERO_OR_MORE_BOUND> bw_o{"bw_o"};
33 sc_core::sc_attribute<unsigned> min_latency{"min_latency", 10};
35 sc_core::sc_attribute<unsigned> max_latency{"max_latency", 100};
38 sc_core::sc_attribute<unsigned> window_size{"window_size", 2};
41 sc_core::sc_attribute<bool> prioritize_by_latency{"prioritize_by_latency", false};
43 sc_core::sc_attribute<bool> prioritize_by_qos{"prioritize_by_qos", false};
44
45 tx_reorderer(const sc_core::sc_module_name& nm);
52 void transport(tlm::tlm_generic_payload& payload, bool lt_transport = false) override;
59 void snoop_resp(tlm::tlm_generic_payload& payload, bool sync = false) override {}
60
61protected:
62 void clock_cb();
63 struct que_entry {
64 tlm::scc::tlm_gp_shared_ptr trans;
65 unsigned age{0};
66 que_entry(tlm::tlm_generic_payload& gp)
67 : trans(&gp) {}
68 };
69 std::array<std::unordered_map<unsigned, std::deque<que_entry>>, 3> reorder_buffer;
70};
71
74template <unsigned int BUSWIDTH = 32, typename TYPES = axi::axi_protocol_types, int N = 1,
75 sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND>
76class reordering_target : public sc_core::sc_module, public target_info_if {
77public:
78 using base = axi_target_pe;
79 using payload_type = base::payload_type;
80 using phase_type = base::phase_type;
81
82 sc_core::sc_in<bool> clk_i{"clk_i"};
83
85
90
91 reordering_target(const sc_core::sc_module_name& nm)
92 : sc_core::sc_module(nm)
93 , pe("pe", BUSWIDTH) {
94 sckt(pe);
95 pe.clk_i(clk_i);
96 pe.fw_o(reorder_buffer.fw_i);
97 reorder_buffer.clk_i(clk_i);
98 reorder_buffer.bw_o(pe.bw_i);
99 }
100
101 reordering_target() = delete;
102
103 reordering_target(reordering_target const&) = delete;
104
106
107 reordering_target& operator=(reordering_target const&) = delete;
108
109 reordering_target& operator=(reordering_target&&) = delete;
110
111 size_t get_outstanding_tx_count() override { return pe.getAllOutStandingTx(); }
112
113protected:
114 void end_of_elaboration() override {
115 auto* ifs = sckt.get_base_port().get_interface(0);
116 sc_assert(ifs != nullptr);
117 pe.set_bw_interface(ifs);
118 }
119
120public:
121 axi_target_pe pe;
122 tx_reorderer reorder_buffer{"reorder_buffer"};
123};
124} // namespace pe
125} // namespace axi
reordering_target(const sc_core::sc_module_name &nm)
the constructor
void snoop_resp(tlm::tlm_generic_payload &payload, bool sync=false) override
sc_core::sc_attribute< unsigned > window_size
void transport(tlm::tlm_generic_payload &payload, bool lt_transport=false) override
sc_core::sc_attribute< unsigned > min_latency
the minimum time a transaction will stay in the target
sc_core::sc_attribute< bool > prioritize_by_qos
use the QoS field for selection.
sc_core::sc_attribute< bool > prioritize_by_latency
sc_core::sc_attribute< unsigned > max_latency
the maximum time a transaction is allwed to stay in the target
protocol engine implementations
TLM2.0 components modeling AHB.
The AXI protocol traits class. Since the protocoll defines additional non-ignorable phases a dedicate...
Definition axi_tlm.h:919