Skip to content

Commit f549985

Browse files
Merge pull request #716 from AndrewGoodrich/issue110
Issue110: tlm hierarchical binding
2 parents dfb8513 + 5759d0e commit f549985

File tree

3 files changed

+38
-15
lines changed

3 files changed

+38
-15
lines changed

src/sysc/communication/sc_communication_ids.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ SC_DEFINE_MESSAGE( SC_ID_ATTEMPT_TO_WRITE_TO_CLOCK_, 125,
101101
"attempt to write the value of an sc_clock instance" )
102102
SC_DEFINE_MESSAGE( SC_ID_SC_EXPORT_ALREADY_BOUND_, 126,
103103
"sc_export instance already bound" )
104-
SC_DEFINE_MESSAGE( SC_ID_OPERATION_ON_NON_SPECIALIZED_SIGNAL_, 127,
105-
"attempted specalized signal operation on non-specialized signal" )
104+
SC_DEFINE_MESSAGE( SC_ID_INVALID_HIERARCHICAL_BIND_, 127,
105+
"attempt to bind a multi-target socket to a non-multi-target socket" )
106106
SC_DEFINE_MESSAGE( SC_ID_ATTEMPT_TO_BIND_CLOCK_TO_OUTPUT_, 128,
107107
"attempted to bind sc_clock instance to sc_inout or sc_out" )
108108
SC_DEFINE_MESSAGE( SC_ID_INSERT_STUB_, 129,

src/sysc/utils/sc_report_handler.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -788,14 +788,14 @@ sc_actions sc_report_handler::get_catch_actions()
788788
// predefined messages
789789
//
790790

791-
const char SC_ID_REGISTER_ID_FAILED_[] = "register_id failed";
792-
const char SC_ID_UNKNOWN_ERROR_[] = "unknown error";
793-
const char SC_ID_WITHOUT_MESSAGE_[] = "";
794-
const char SC_ID_NOT_IMPLEMENTED_[] = "not implemented";
795-
const char SC_ID_INTERNAL_ERROR_[] = "internal error";
796-
const char SC_ID_ASSERTION_FAILED_[] = "assertion failed";
797-
const char SC_ID_OUT_OF_BOUNDS_[] = "out of bounds";
798-
const char SC_ID_ABORT_[] = "simulation aborted";
791+
const char SC_ID_REGISTER_ID_FAILED_[] = "register_id failed";
792+
const char SC_ID_UNKNOWN_ERROR_[] = "unknown error";
793+
const char SC_ID_WITHOUT_MESSAGE_[] = "";
794+
const char SC_ID_NOT_IMPLEMENTED_[] = "not implemented";
795+
const char SC_ID_INTERNAL_ERROR_[] = "internal error";
796+
const char SC_ID_ASSERTION_FAILED_[] = "assertion failed";
797+
const char SC_ID_OUT_OF_BOUNDS_[] = "out of bounds";
798+
const char SC_ID_ABORT_[] = "simulation aborted";
799799

800800
#define DEFINE_MSG(id,n) \
801801
{ \

src/tlm_core/tlm_2/tlm_sockets/tlm_target_socket.h

+28-5
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
#include "tlm_core/tlm_2/tlm_sockets/tlm_base_socket_if.h"
2424
#include "tlm_core/tlm_2/tlm_2_interfaces/tlm_fw_bw_ifs.h"
25-
25+
#include "sysc/communication/sc_communication_ids.h"
2626

2727
namespace tlm {
2828

@@ -123,15 +123,38 @@ class tlm_base_target_socket : public tlm_base_target_socket_b<BUSWIDTH, FW_IF,
123123
bind(s);
124124
}
125125

126+
127+
// "tlm_base_target_socket<>::bind(tlm_base_target_socket<>)"
128+
//
129+
// Bind a target socket to this object instance (target socket), a hierarchical bind.
130+
// The bind is done to both the port and export.
126131
//
127-
// Bind target socket to target socket (hierarchical bind)
128-
// - Binds both the export and the port
132+
// Arguments:
133+
// s = socket to be bound to this object instance.
129134
//
135+
// Notes:
136+
// (1) IEEE 1666 forbids the hierarchical bind of a multi-target socket to a non-multi-target
137+
// socket, so we check if the object to be bound is multi-target and this object instance
138+
// is not multi-target.
139+
// (2) The opposite hierarchical bind, a non-multi-target socket to a multi-target socket
140+
// will result in a compiler error, so we don't need to check that case.
141+
130142
virtual void bind(base_type& s)
131143
{
132-
// export
144+
// Look for an illegal bind (see note 1 above.)
145+
146+
if ( s.get_socket_category() == tlm::TLM_MULTI_TARGET_SOCKET ) {
147+
if ( tlm::TLM_MULTI_TARGET_SOCKET != get_socket_category() ) {
148+
SC_REPORT_ERROR(sc_core::SC_ID_INVALID_HIERARCHICAL_BIND_, this->name());
149+
}
150+
}
151+
152+
// bind the exports
153+
133154
(get_base_export())(s.get_base_export());
134-
// port
155+
156+
// bind the ports
157+
135158
(s.get_base_port())(get_base_port());
136159
}
137160

0 commit comments

Comments
 (0)