Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/sysc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ set(LIB_SOURCES
tlm/scc/scv/tlm_recorder.cpp
tlm/scc/pe/parallel_pe.cpp
tlm/scc/lwtr/tlm2_lwtr.cpp
tlm/scc/memory_map_collector.cpp
)

if(DEFINED SC_VERSION_MAJOR AND SC_VERSION_MAJOR GREATER 2)
Expand Down
2 changes: 1 addition & 1 deletion src/sysc/scc/ordered_semaphore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ auto ordered_semaphore::wait(unsigned priority) -> int {
// lock (take) the semaphore, return -1 if not available

auto ordered_semaphore::trywait() -> int {
if(in_use()) {
if(value == 0) {
return -1;
}
--value;
Expand Down
32 changes: 32 additions & 0 deletions src/sysc/tlm/scc/memory_map_collector.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*******************************************************************************
* Copyright 2026 MINRES Technologies GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/

#include "memory_map_collector.h"
#include <fmt/format.h>

namespace tlm {
namespace scc {
std::string memory_node::to_string(const std::string& prefix) const {
std::ostringstream os;
std::string filler(16 - prefix.length(), ' ');
os << fmt::format("{} 0x{:016x}:0x{:016x}{}{}\n", prefix, start, end, filler, name);
for(auto e : elemets)
os << e.to_string(prefix + " ");
return os.str();
}

} // namespace scc
} // namespace tlm
16 changes: 4 additions & 12 deletions src/sysc/tlm/scc/memory_map_collector.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2016, 2018 MINRES Technologies GmbH
* Copyright 2026 MINRES Technologies GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,12 +18,10 @@
#define _TLM_SCC_MEMORY_MAP_COLLECTOR_H_

#include <cstdint>
#include <fmt/format.h>
#include <limits>
#include <sstream>
#include <stdexcept>
#include <tlm>
#include <tlm_core/tlm_2/tlm_2_interfaces/tlm_fw_bw_ifs.h>

//! @brief SystemC TLM
namespace tlm {
Expand All @@ -38,14 +36,7 @@ struct memory_node {
: start(start)
, end(end) {}
memory_node() = default;
std::string to_string(std::string const& prefix = "") const {
std::ostringstream os;
std::string filler(16 - prefix.length(), ' ');
os << fmt::format("{} 0x{:016x}:0x{:016x}{}{}\n", prefix, start, end, filler, name);
for(auto e : elemets)
os << e.to_string(prefix + " ");
return os.str();
}
std::string to_string(const std::string& prefix = "") const;
};

struct memory_map_extension : tlm::tlm_extension<memory_map_extension> {
Expand All @@ -70,6 +61,7 @@ memory_node gather_memory(sc_core::sc_port_b<tlm::tlm_fw_transport_if<TYPES>>& p
trans.set_extension<memory_map_extension>(nullptr);
return std::move(root);
}

} // namespace scc
} // namespace tlm
#endif // _TLM_SCC_MEMORY_MAP_COLLECTOR_H_
#endif // _TLM_SCC_MEMORY_MAP_COLLECTOR_H_