scc  2024.06
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 <axi/pe/axi_target_pe.h>
20 #include <cci_configuration>
21 #include "target_info_if.h"
22 
24 namespace axi {
26 namespace pe {
27 class replay_buffer: public sc_core::sc_module, tlm::scc::pe::intor_fw_nb {
28 public:
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() {
54  reset_end_cycle=sc_core::sc_time_stamp()/clk_if->period();
55  }
56 protected:
57  sc_core::sc_clock* clk_if{nullptr};
58  uint64_t reset_end_cycle{0};
59  using entry_t = std::tuple<uint64_t, unsigned>;
60  std::vector<std::vector<entry_t>> rd_sequence, wr_sequence;
61  sc_core::sc_time time_per_byte_rd, time_per_byte_wr, time_per_byte_total;
64  scc::fifo_w_cb<std::tuple<tlm::tlm_generic_payload*, unsigned>> wr_req2resp_fifo{"wr_req2resp_fifo"};
67  scc::fifo_w_cb<tlm::tlm_generic_payload*> wr_resp_fifo{"wr_resp_fifo"};
68  scc::ordered_semaphore total_arb{1};
69  double total_residual_clocks{0.0};
70  void end_of_elaboration() override;
71  void start_of_simulation() override;
72  void process_req2resp_fifos();
73  void start_rd_resp_thread();
74  void start_wr_resp_thread();
75 
76 };
81 template <unsigned int BUSWIDTH = 32, typename TYPES = axi::axi_protocol_types, int N = 1,
82  sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND>
83 class replay_target : public sc_core::sc_module, public target_info_if {
84 public:
85  using base = axi_target_pe;
86  using payload_type = base::payload_type;
87  using phase_type = base::phase_type;
88 
89  sc_core::sc_in<bool> clk_i{"clk_i"};
90 
91  sc_core::sc_in<bool> rst_i{"rst_i"};
92 
94 
99  replay_target(const sc_core::sc_module_name& nm)
100  : sc_core::sc_module(nm)
101  , pe("pe", BUSWIDTH)
102  , repl_buffer("repl_buffer"){
103  sckt(pe);
104  pe.clk_i(clk_i);
105  repl_buffer.clk_i(clk_i);
106  pe.fw_o(repl_buffer.fw_i);
107  repl_buffer.bw_o(pe.bw_i);
108  SC_HAS_PROCESS(replay_target);
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 
125 protected:
126  void end_of_reset() {
127  repl_buffer.end_of_reset();
128  }
129  void end_of_elaboration(){
130  auto* ifs = sckt.get_base_port().get_interface(0);
131  sc_assert(ifs!=nullptr);
132  pe.set_bw_interface(ifs);
133  }
134 public:
135  axi_target_pe pe;
136  replay_buffer repl_buffer;
137 };
138 } // namespace pe
139 } // 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
Definition: replay_target.h:66
void snoop_resp(tlm::tlm_generic_payload &payload, bool sync=false) override
Definition: replay_target.h:51
scc::fifo_w_cb< std::tuple< tlm::tlm_generic_payload *, unsigned > > rd_req2resp_fifo
queues realizing the latencies
Definition: replay_target.h:63
replay_target(const sc_core::sc_module_name &nm)
the constructor
Definition: replay_target.h:99
fifo with callbacks
Definition: fifo_w_cb.h:38
The ordered_semaphore primitive channel class.
TLM2.0 components modeling AHB.
Definition: axi_initiator.h:30
The AXI protocol traits class. Since the protocoll defines additional non-ignorable phases a dedicate...
Definition: axi_tlm.h:920