scc  2024.06
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 "../../interfaces/axi/axi_target.h"
18 
19 #include <scc/mt19937_rng.h>
20 #include <scc/report.h>
21 #include <tlm/scc/tlm_gp_shared.h>
22 
23 using namespace axi;
24 
25 inline 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 
31 axi_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  SC_HAS_PROCESS(axi_target_base);
35  SC_THREAD(trans_queue);
36 }
37 
38 unsigned axi_target_base::access(tlm::tlm_generic_payload& trans) {
39  peq.notify(&trans);
40  return std::numeric_limits<unsigned>::max();
41 }
42 
43 void axi_target_base::trans_queue() {
44  auto delay = sc_core::SC_ZERO_TIME;
45  while(true) {
46  tlm::scc::tlm_gp_shared_ptr trans = peq.get();
47  isck->b_transport(*trans, delay);
48  pe.operation_resp(*trans,
49  trans->is_write() ? get_cci_randomized_value(pe.wr_resp_delay) : get_cci_randomized_value(pe.rd_resp_delay));
50  }
51 }
axi_target class instantiates the AXI Protocol Engine. It accesses the Protocol Engine with access() ...
Definition: axi_target.h:37
void operation_resp(payload_type &trans, unsigned clk_delay=0)
cci::cci_param< int > rd_resp_delay
the latency between request and response phase. Will be overwritten by the return of the callback fun...
Definition: axi_target_pe.h:87
cci::cci_param< int > wr_resp_delay
the latency between request and response phase. Will be overwritten by the return of the callback fun...
Definition: axi_target_pe.h:92
static uint64_t uniform()
Definition: mt19937_rng.h:60
TLM2.0 components modeling AHB.
Definition: axi_initiator.h:30
void notify(const TYPE &entry, const sc_core::sc_time &t)
non-blocking push.
Definition: peq.h:77
TYPE get()
blocking get
Definition: peq.h:128