Skip to content

Commit

Permalink
Give socket lists tracing properties
Browse files Browse the repository at this point in the history
  • Loading branch information
janweinstock committed Dec 6, 2023
1 parent 072b0da commit ca70b3d
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions include/vcml/protocols/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@ using multi_initiator_socket = base_initiator_socket<FW, BW, WIDTH, 0>;
template <typename FW, typename BW, unsigned int WIDTH = 1>
using multi_target_socket = base_target_socket<FW, BW, WIDTH, 0>;

template <typename T, typename = std::void_t<>>
struct supports_tracing : std::false_type {};

template <typename T>
struct supports_tracing<T, std::void_t<decltype(std::declval<T>().trace_all)>>
: std::true_type {};

template <typename SOCKET>
class socket_array : public sc_object
{
Expand All @@ -132,14 +139,20 @@ class socket_array : public sc_object
revmap_type m_ids;

public:
property<bool> trace_all;
property<bool> trace_errors;

socket_array(const char* nm):
sc_object(nm),
m_next(0),
m_max(SIZE_MAX),
m_space(VCML_AS_DEFAULT),
m_sockets(),
m_ids() {
// nothing to do
m_ids(),
trace_all(this, "trace", false),
trace_errors(this, "trace_errors", false) {
trace_all.inherit_default();
trace_errors.inherit_default();
}

socket_array(const char* nm, size_t max): socket_array(nm) { m_max = max; }
Expand Down Expand Up @@ -175,6 +188,11 @@ class socket_array : public sc_object
hierarchy_guard guard(this);
string nm = mkstr("%s[%zu]", basename(), idx);
socket = new SOCKET(nm.c_str(), m_space);
if constexpr (supports_tracing<SOCKET>::value) {
socket->trace_all.set_default(trace_all);
socket->trace_errors.set_default(trace_errors);
}

m_ids[socket] = idx;
m_next = max(m_next, idx + 1);
return *socket;
Expand Down

0 comments on commit ca70b3d

Please sign in to comment.