scc 2025.09
SystemC components library
ahb_target.cpp
1/*******************************************************************************
2 * Copyright 2020-2022 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 "ahb_target.h"
18
19#include <scc/report.h>
20#include <systemc>
21#include <tuple>
22
23using namespace sc_core;
24using namespace tlm;
25using namespace ahb;
26using namespace ahb::pe;
27
28/******************************************************************************
29 * target
30 ******************************************************************************/
31
32ahb_target_b::ahb_target_b(const sc_core::sc_module_name& nm, sc_core::sc_port_b<tlm::tlm_bw_transport_if<tlm_base_protocol_types>>& port,
33 size_t transfer_width)
34: sc_module(nm)
35, socket_bw(port) {
36 add_attribute(wr_data_accept_delay);
37 add_attribute(rd_addr_accept_delay);
38 add_attribute(rd_data_beat_delay);
39 add_attribute(rd_resp_delay);
40 add_attribute(wr_resp_delay);
41 dont_initialize();
42 sensitive << clk_i.pos();
43}
44
45void ahb_target_b::end_of_elaboration() { clk_if = dynamic_cast<sc_core::sc_clock*>(clk_i.get_interface()); }
46
47void ahb_target_b::b_transport(payload_type& trans, sc_time& t) {
48 auto latency = operation_cb ? operation_cb(trans) : trans.is_read() ? rd_resp_delay.value : wr_resp_delay.value;
49 trans.set_dmi_allowed(false);
50 trans.set_response_status(tlm::TLM_OK_RESPONSE);
51 clk_if = dynamic_cast<sc_core::sc_clock*>(clk_i.get_interface());
52 if(clk_if) {
53 t += clk_if->period() * latency;
54 }
55}
56
57tlm_sync_enum ahb_target_b::nb_transport_fw(payload_type& trans, phase_type& phase, sc_time& t) {
58 // TODO:
59 return tlm::TLM_COMPLETED;
60}
61
62bool ahb_target_b::get_direct_mem_ptr(payload_type& trans, tlm_dmi& dmi_data) {
63 trans.set_dmi_allowed(false);
64 return false;
65}
66
67unsigned int ahb_target_b::transport_dbg(payload_type& trans) { return 0; }
68
69void ahb_target_b::operation_resp(payload_type& trans, bool sync) {
70 // TODO
71}
72
73void ahb_target_b::send_resp_thread() {
74 while(true) {
75 // waiting for responses to send
76 // TODO
77 }
78}
void operation_resp(payload_type &trans, bool sync=false)
sc_core::sc_attribute< unsigned > rd_resp_delay
the latency between request and response phase. Will be overwritten by the return of the callback fun...
Definition ahb_target.h:63
ahb_target_b(const sc_core::sc_module_name &nm, sc_core::sc_port_b< tlm::tlm_bw_transport_if< tlm::tlm_base_protocol_types > > &port, size_t transfer_width)
sc_core::sc_attribute< unsigned > wr_resp_delay
the latency between request and response phase. Will be overwritten by the return of the callback fun...
Definition ahb_target.h:68
protocol engine implementations
TLM2.0 components modeling AHB.
Definition ahb_tlm.cpp:19
SystemC TLM.
Definition dmi_mgr.h:19