17 #include "reordering_target.h"
19 axi::pe::tx_reorderer::tx_reorderer(
const sc_core::sc_module_name &nm): sc_core::sc_module(nm) {
20 add_attribute(min_latency);
21 add_attribute(max_latency);
22 add_attribute(prioritize_by_latency);
23 add_attribute(prioritize_by_qos);
24 SC_HAS_PROCESS(tx_reorderer);
27 sensitive<<clk_i.pos();
33 auto id = ext->get_id();
34 reorder_buffer[payload.get_command()][id].emplace_back(payload);
36 SCCFATAL(SCMOD)<<
"Transaction is not a AXI4 transaction";
39 void axi::pe::tx_reorderer::clock_cb() {
40 for(
unsigned cmd=tlm::TLM_READ_COMMAND; cmd<tlm::TLM_IGNORE_COMMAND; ++cmd) {
41 if(!reorder_buffer[cmd].empty()) {
42 std::vector<unsigned> r1{}, r2{};
43 r1.reserve(reorder_buffer[cmd].size());
44 r2.reserve(reorder_buffer[cmd].size());
47 for(
auto& e:reorder_buffer[cmd]) {
49 e.second.front().age++;
50 if(e.second.front().age>max_latency.value) {
51 r1.push_back(e.first);
52 }
else if(e.second.front().age>min_latency.value) {
53 r2.push_back(e.first);
54 lat_sum+=e.second.front().age;
61 for (
auto i = r1.begin() + 1; i != r1.end(); ++i) {
63 if (i != j) std::iter_swap(i, j);
67 auto& deq = reorder_buffer[cmd][e];
68 auto notok = bw_o->transport(*deq.front().trans);
69 if(notok==0) deq.pop_front();
71 }
else if(r2.size()>window_size.value) {
72 if(prioritize_by_qos.value) {
73 std::vector<unsigned> res;
74 auto& buf = reorder_buffer[cmd];
75 std::copy_if(std::begin(r2), std::end(r2), std::back_inserter(res), [max_qos, &buf](
unsigned e){
79 auto& deq = reorder_buffer[cmd][res.front()];
80 auto notok = bw_o->transport(*deq.front().trans);
81 if(notok==0) deq.pop_front();
87 if(prioritize_by_latency.value){
91 auto& deq = reorder_buffer[cmd][e];
92 part_sum+=deq.front().age;
94 auto notok = bw_o->transport(*deq.front().trans);
95 if(notok==0) deq.pop_front();
101 auto& deq = reorder_buffer[cmd][r2[rnd]];
102 auto notok = bw_o->transport(*deq.front().trans);
103 if(notok==0) deq.pop_front();
void transport(tlm::tlm_generic_payload &payload, bool lt_transport=false) override
static uint64_t uniform()
uint8_t get_qos() const
get the AxQOS (quality of service) value