scc 2026.07
SystemC components library
memory_map_collector.h
1/*******************************************************************************
2 * Copyright 2026 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#ifndef _TLM_SCC_MEMORY_MAP_COLLECTOR_H_
18#define _TLM_SCC_MEMORY_MAP_COLLECTOR_H_
19
20#include <cstdint>
21#include <limits>
22#include <sstream>
23#include <stdexcept>
24#include <tlm>
25
27namespace tlm {
29namespace scc {
30struct memory_node {
31 uint64_t start{0};
32 uint64_t end{std::numeric_limits<uint64_t>::max()};
33 std::string name;
34 std::vector<memory_node> elemets;
35 memory_node(uint64_t start, uint64_t end)
36 : start(start)
37 , end(end) {}
38 memory_node() = default;
39 std::string to_string(const std::string& prefix = "") const;
40};
41
42struct memory_map_extension : tlm::tlm_extension<memory_map_extension> {
43 tlm_extension_base* clone() const override { return new memory_map_extension(*this); }
44 void copy_from(tlm_extension_base const& from) override { throw std::runtime_error("copying of memory_map_extension not allowed"); }
45
46 memory_map_extension(memory_node& node)
47 : node(node) {}
48 ~memory_map_extension() {}
49
50 memory_node& node;
51 uint64_t offset{0};
52};
53
54template <typename TYPES = tlm::tlm_base_protocol_types>
55memory_node gather_memory(sc_core::sc_port_b<tlm::tlm_fw_transport_if<TYPES>>& port) {
56 memory_node root;
57 auto ext = memory_map_extension(root);
58 /*TYPES::tlm_payload_type*/ tlm::tlm_generic_payload trans;
59 trans.set_extension(&ext);
60 port->transport_dbg(trans);
61 trans.set_extension<memory_map_extension>(nullptr);
62 return std::move(root);
63}
64
65} // namespace scc
66} // namespace tlm
67#endif // _TLM_SCC_MEMORY_MAP_COLLECTOR_H_
SCC TLM utilities.
Definition axis_tlm.h:56
SystemC TLM.
Definition dmi_mgr.h:19