scc 2025.09
SystemC components library
axi_target.cpp
1/*******************************************************************************
2 * Copyright 2021 MINRES Technologies GmbH
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.
15 *******************************************************************************/
16
17#include "axi_target.h"
18
19#include <scc/mt19937_rng.h>
20#include <scc/report.h>
21#include <tlm/scc/tlm_gp_shared.h>
22
23using namespace axi;
24
25inline unsigned get_cci_randomized_value(cci::cci_param<int> const& p) {
26 if(p.get_value() < 0)
27 return scc::MT19937::uniform(0, -p.get_value());
28 return p.get_value();
29}
30
31axi_target_base::axi_target_base(const sc_core::sc_module_name& nm, axi::pe::axi_target_pe& pe)
32: sc_module(nm)
33, pe(pe) {
34#if SYSTEMC_VERSION < 20250221
35 SC_HAS_PROCESS(axi_target_base);
36#endif
37 SC_THREAD(trans_queue);
38}
39
40unsigned axi_target_base::access(tlm::tlm_generic_payload& trans) {
41 peq.notify(&trans);
42 return std::numeric_limits<unsigned>::max();
43}
44
45void axi_target_base::trans_queue() {
46 auto delay = sc_core::SC_ZERO_TIME;
47 while(true) {
48 tlm::scc::tlm_gp_shared_ptr trans = peq.get();
49 isck->b_transport(*trans, delay);
50 pe.operation_resp(*trans,
51 trans->is_write() ? get_cci_randomized_value(pe.wr_resp_delay) : get_cci_randomized_value(pe.rd_resp_delay));
52 }
53}
axi_target class instantiates the AXI Protocol Engine. It accesses the Protocol Engine with access() ...
Definition axi_target.h:37
static uint64_t uniform()
Definition mt19937_rng.h:60
T * get() const noexcept
Return the stored pointer.
protocol engine implementations
TLM2.0 components modeling AHB.