scc 2025.09
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 <axi/pe/axi_target_pe.h>
19#include "target_info_if.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 {}
60protected:
61 void clock_cb();
62 struct que_entry {
63 tlm::scc::tlm_gp_shared_ptr trans;
64 unsigned age{0};
65 que_entry(tlm::tlm_generic_payload& gp):trans(&gp){}
66 };
67 std::array<std::unordered_map<unsigned , std::deque<que_entry>>, 3> reorder_buffer;
68};
69
72template <unsigned int BUSWIDTH = 32, typename TYPES = axi::axi_protocol_types, int N = 1,
73 sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND>
74class reordering_target : public sc_core::sc_module, public target_info_if {
75public:
76 using base = axi_target_pe;
77 using payload_type = base::payload_type;
78 using phase_type = base::phase_type;
79
80 sc_core::sc_in<bool> clk_i{"clk_i"};
81
83
88
89 reordering_target(const sc_core::sc_module_name& nm)
90 : sc_core::sc_module(nm)
91 , pe("pe", BUSWIDTH) {
92 sckt(pe);
93 pe.clk_i(clk_i);
94 pe.fw_o(reorder_buffer.fw_i);
95 reorder_buffer.clk_i(clk_i);
96 reorder_buffer.bw_o(pe.bw_i);
97 }
98
99 reordering_target() = delete;
100
101 reordering_target(reordering_target const&) = delete;
102
104
105 reordering_target& operator=(reordering_target const&) = delete;
106
107 reordering_target& operator=(reordering_target&&) = delete;
108
109 size_t get_outstanding_tx_count() override { return pe.getAllOutStandingTx();}
110
111protected:
112 void end_of_elaboration() override {
113 auto* ifs = sckt.get_base_port().get_interface(0);
114 sc_assert(ifs!=nullptr);
115 pe.set_bw_interface(ifs);
116 }
117public:
118 axi_target_pe pe;
119 tx_reorderer reorder_buffer{"reorder_buffer"};
120};
121} // namespace pe
122} // 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:920