Skip to content

Commit 052d47a

Browse files
committed
router: Add a warning message when a target address is not found
1 parent 7ff8d09 commit 052d47a

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/components/scc/router.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#include <limits>
2121
#include <scc/utilities.h>
22+
#include <scc/report.h>
2223
#include <sysc/utils/sc_vector.h>
2324
#include <tlm.h>
2425
#include <tlm/scc/initiator_mixin.h>
@@ -131,6 +132,13 @@ template <unsigned BUSWIDTH = LT, typename TARGET_SOCKET_TYPE = tlm::tlm_target_
131132
* @param remap if true address will be rewritten in accesses to be 0-based at the target
132133
*/
133134
void set_target_range(size_t idx, uint64_t base, uint64_t size, bool remap = true);
135+
/**
136+
* @fn void set_warn_on_address_error(bool)
137+
* @brief enable warning message on address not found error
138+
*
139+
* @param enable if true enable warning message
140+
*/
141+
void set_warn_on_address_error(bool enable) { warn_on_address_error = enable; }
134142
/**
135143
* @fn void b_transport(int, tlm::tlm_generic_payload&, sc_core::sc_time&)
136144
* @brief tagged blocking transport method
@@ -186,6 +194,7 @@ template <unsigned BUSWIDTH = LT, typename TARGET_SOCKET_TYPE = tlm::tlm_target_
186194
util::range_lut<unsigned> addr_decoder;
187195
std::unordered_map<std::string, size_t> target_name_lut;
188196
bool check_overlap_on_add_target;
197+
bool warn_on_address_error{false};
189198
};
190199

191200
template <unsigned BUSWIDTH, typename TARGET_SOCKET_TYPE>
@@ -260,6 +269,9 @@ void router<BUSWIDTH, TARGET_SOCKET_TYPE>::b_transport(int i, tlm::tlm_generic_p
260269
size_t idx = addr_decoder.getEntry(address);
261270
if(idx == addr_decoder.null_entry) {
262271
if(default_idx == std::numeric_limits<size_t>::max()) {
272+
if(warn_on_address_error) {
273+
SCCWARN(SCMOD) << "target address=0x" << std::hex << address << " not found for " << (trans.get_command() == tlm::TLM_READ_COMMAND ? "read" : "write") << " transaction.";
274+
}
263275
trans.set_response_status(tlm::TLM_ADDRESS_ERROR_RESPONSE);
264276
return;
265277
}
@@ -283,6 +295,9 @@ bool router<BUSWIDTH, TARGET_SOCKET_TYPE>::get_direct_mem_ptr(int i, tlm::tlm_ge
283295
size_t idx = addr_decoder.getEntry(address);
284296
if(idx == addr_decoder.null_entry) {
285297
if(default_idx == std::numeric_limits<size_t>::max()) {
298+
if(warn_on_address_error) {
299+
SCCWARN(SCMOD) << "target address=0x" << std::hex << address << " not found for " << (trans.get_command() == tlm::TLM_READ_COMMAND ? "read" : "write") << " transaction.";
300+
}
286301
trans.set_response_status(tlm::TLM_ADDRESS_ERROR_RESPONSE);
287302
return false;
288303
}
@@ -311,6 +326,9 @@ unsigned router<BUSWIDTH, TARGET_SOCKET_TYPE>::transport_dbg(int i, tlm::tlm_gen
311326
size_t idx = addr_decoder.getEntry(address);
312327
if(idx == addr_decoder.null_entry) {
313328
if(default_idx == std::numeric_limits<size_t>::max()) {
329+
if(warn_on_address_error) {
330+
SCCWARN(SCMOD) << "target address=0x" << std::hex << address << " not found for " << (trans.get_command() == tlm::TLM_READ_COMMAND ? "read" : "write") << " transaction.";
331+
}
314332
trans.set_response_status(tlm::TLM_ADDRESS_ERROR_RESPONSE);
315333
return 0;
316334
}

0 commit comments

Comments
 (0)