From e345154b19939db37fb391111d4dad190c62e81c Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Wed, 12 Dec 2018 16:43:18 -0800 Subject: systemc: Rename tlm_core header files to have a .hh extentension. This makes those files more consistent with other headers in gem5. The top level headers (tlm and tlm.h) and the tlm_utils headers were left alone since the user might reasonably expect those to have a well known name. The tlm_core headers by comparison are an implementation detail, and users shouldn't include them directly by name. Change-Id: Ibc82e8159e47717c79d76f50ed96fdd619294a06 Reviewed-on: https://gem5-review.googlesource.com/c/15067 Reviewed-by: Anthony Gutierrez Maintainer: Anthony Gutierrez --- .../ext/tlm_core/2/sockets/base_socket_if.h | 57 ------ .../ext/tlm_core/2/sockets/base_socket_if.hh | 57 ++++++ .../ext/tlm_core/2/sockets/initiator_socket.h | 204 ------------------- .../ext/tlm_core/2/sockets/initiator_socket.hh | 204 +++++++++++++++++++ src/systemc/ext/tlm_core/2/sockets/sockets.h | 26 --- src/systemc/ext/tlm_core/2/sockets/sockets.hh | 26 +++ src/systemc/ext/tlm_core/2/sockets/target_socket.h | 223 --------------------- .../ext/tlm_core/2/sockets/target_socket.hh | 223 +++++++++++++++++++++ 8 files changed, 510 insertions(+), 510 deletions(-) delete mode 100644 src/systemc/ext/tlm_core/2/sockets/base_socket_if.h create mode 100644 src/systemc/ext/tlm_core/2/sockets/base_socket_if.hh delete mode 100644 src/systemc/ext/tlm_core/2/sockets/initiator_socket.h create mode 100644 src/systemc/ext/tlm_core/2/sockets/initiator_socket.hh delete mode 100644 src/systemc/ext/tlm_core/2/sockets/sockets.h create mode 100644 src/systemc/ext/tlm_core/2/sockets/sockets.hh delete mode 100644 src/systemc/ext/tlm_core/2/sockets/target_socket.h create mode 100644 src/systemc/ext/tlm_core/2/sockets/target_socket.hh (limited to 'src/systemc/ext/tlm_core/2/sockets') diff --git a/src/systemc/ext/tlm_core/2/sockets/base_socket_if.h b/src/systemc/ext/tlm_core/2/sockets/base_socket_if.h deleted file mode 100644 index 29f3397b9..000000000 --- a/src/systemc/ext/tlm_core/2/sockets/base_socket_if.h +++ /dev/null @@ -1,57 +0,0 @@ -/***************************************************************************** - - Licensed to Accellera Systems Initiative Inc. (Accellera) under one or - more contributor license agreements. See the NOTICE file distributed - with this work for additional information regarding copyright ownership. - Accellera licenses this file to you 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. - - *****************************************************************************/ - -#ifndef __SYSTEMC_EXT_TLM_CORE_2_SOCKETS_BASE_SOCKET_IF_H__ -#define __SYSTEMC_EXT_TLM_CORE_2_SOCKETS_BASE_SOCKET_IF_H__ - -#include - -namespace tlm -{ - -enum tlm_socket_category -{ - TLM_UNKNOWN_SOCKET = 0, - TLM_INITIATOR_SOCKET = 0x1, - TLM_TARGET_SOCKET = 0x2, - - TLM_MULTI_SOCKET = 0x10, - - TLM_MULTI_INITIATOR_SOCKET = TLM_INITIATOR_SOCKET | TLM_MULTI_SOCKET, - TLM_MULTI_TARGET_SOCKET = TLM_TARGET_SOCKET | TLM_MULTI_SOCKET -}; - -class tlm_base_socket_if -{ - public: - virtual sc_core::sc_port_base &get_port_base() = 0; - virtual sc_core::sc_port_base const &get_port_base() const = 0; - virtual sc_core::sc_export_base &get_export_base() = 0; - virtual sc_core::sc_export_base const &get_export_base() const = 0; - virtual unsigned int get_bus_width() const = 0; - virtual sc_core::sc_type_index get_protocol_types() const = 0; - virtual tlm_socket_category get_socket_category() const = 0; - - protected: - virtual ~tlm_base_socket_if() {} -}; - -} // namespace tlm - -#endif // __SYSTEMC_EXT_TLM_CORE_2_SOCKETS_BASE_SOCKET_IF_H__ diff --git a/src/systemc/ext/tlm_core/2/sockets/base_socket_if.hh b/src/systemc/ext/tlm_core/2/sockets/base_socket_if.hh new file mode 100644 index 000000000..29f3397b9 --- /dev/null +++ b/src/systemc/ext/tlm_core/2/sockets/base_socket_if.hh @@ -0,0 +1,57 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you 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. + + *****************************************************************************/ + +#ifndef __SYSTEMC_EXT_TLM_CORE_2_SOCKETS_BASE_SOCKET_IF_H__ +#define __SYSTEMC_EXT_TLM_CORE_2_SOCKETS_BASE_SOCKET_IF_H__ + +#include + +namespace tlm +{ + +enum tlm_socket_category +{ + TLM_UNKNOWN_SOCKET = 0, + TLM_INITIATOR_SOCKET = 0x1, + TLM_TARGET_SOCKET = 0x2, + + TLM_MULTI_SOCKET = 0x10, + + TLM_MULTI_INITIATOR_SOCKET = TLM_INITIATOR_SOCKET | TLM_MULTI_SOCKET, + TLM_MULTI_TARGET_SOCKET = TLM_TARGET_SOCKET | TLM_MULTI_SOCKET +}; + +class tlm_base_socket_if +{ + public: + virtual sc_core::sc_port_base &get_port_base() = 0; + virtual sc_core::sc_port_base const &get_port_base() const = 0; + virtual sc_core::sc_export_base &get_export_base() = 0; + virtual sc_core::sc_export_base const &get_export_base() const = 0; + virtual unsigned int get_bus_width() const = 0; + virtual sc_core::sc_type_index get_protocol_types() const = 0; + virtual tlm_socket_category get_socket_category() const = 0; + + protected: + virtual ~tlm_base_socket_if() {} +}; + +} // namespace tlm + +#endif // __SYSTEMC_EXT_TLM_CORE_2_SOCKETS_BASE_SOCKET_IF_H__ diff --git a/src/systemc/ext/tlm_core/2/sockets/initiator_socket.h b/src/systemc/ext/tlm_core/2/sockets/initiator_socket.h deleted file mode 100644 index 686f930c4..000000000 --- a/src/systemc/ext/tlm_core/2/sockets/initiator_socket.h +++ /dev/null @@ -1,204 +0,0 @@ -/***************************************************************************** - - Licensed to Accellera Systems Initiative Inc. (Accellera) under one or - more contributor license agreements. See the NOTICE file distributed - with this work for additional information regarding copyright ownership. - Accellera licenses this file to you 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. - - *****************************************************************************/ - -#ifndef __SYSTEMC_EXT_TLM_CORE_2_SOCKETS_INITIATOR_SOCKET_H__ -#define __SYSTEMC_EXT_TLM_CORE_2_SOCKETS_INITIATOR_SOCKET_H__ - -#include "tlm_core/2/interfaces/fw_bw_ifs.h" -#include "tlm_core/2/sockets/base_socket_if.h" - -namespace tlm -{ - -template , - typename BW_IF=tlm_bw_transport_if<>> -class tlm_base_initiator_socket_b -{ - public: - virtual ~tlm_base_initiator_socket_b() {} - - virtual sc_core::sc_port_b &get_base_port() = 0; - virtual sc_core::sc_port_b const &get_base_port() const = 0; - virtual BW_IF &get_base_interface() = 0; - virtual BW_IF const &get_base_interface() const = 0; - virtual sc_core::sc_export &get_base_export() = 0; - virtual sc_core::sc_export const &get_base_export() const = 0; -}; - -template -class tlm_base_target_socket_b; - -template -class tlm_base_target_socket; - -template , - typename BW_IF=tlm_bw_transport_if<>, int N=1, - sc_core::sc_port_policy POL=sc_core::SC_ONE_OR_MORE_BOUND> -class tlm_base_initiator_socket : - public tlm_base_socket_if, - public tlm_base_initiator_socket_b, - public sc_core::sc_port -{ - public: - typedef FW_IF fw_interface_type; - typedef BW_IF bw_interface_type; - typedef sc_core::sc_port port_type; - - typedef sc_core::sc_export export_type; - - typedef tlm_base_target_socket_b< - BUSWIDTH, fw_interface_type, bw_interface_type> - base_target_socket_type; - typedef tlm_base_initiator_socket_b< - BUSWIDTH, fw_interface_type, bw_interface_type> base_type; - - template - friend class tlm_base_target_socket; - - public: - tlm_base_initiator_socket() : - port_type(sc_core::sc_gen_unique_name("tlm_base_initiator_socket")), - m_export(sc_core::sc_gen_unique_name( - "tlm_base_initiator_socket_export")) - {} - - explicit tlm_base_initiator_socket(const char *name) : port_type(name), - m_export(sc_core::sc_gen_unique_name( - (std::string(name) + "_export").c_str())) - {} - - virtual const char* kind() const { return "tlm_base_initiator_socket"; } - - // - // Bind initiator socket to target socket - // - Binds the port of the initiator socket to the export of the target - // socket - // - Binds the port of the target socket to the export of the initiator - // socket - // - virtual void - bind(base_target_socket_type &s) - { - // initiator.port -> target.export - (get_base_port())(s.get_base_interface()); - // target.port -> initiator.export - (s.get_base_port())(get_base_interface()); - } - - void operator () (base_target_socket_type &s) { bind(s); } - - // - // Bind initiator socket to initiator socket (hierarchical bind) - // - Binds both the export and the port - // - virtual void - bind(base_type &s) - { - // port - (get_base_port())(s.get_base_port()); - // export - (s.get_base_export())(get_base_export()); - } - - void operator() (base_type &s) { bind(s); } - - // - // Bind interface to socket - // - Binds the interface to the export of this socket - // - virtual void bind(bw_interface_type &ifs) { (get_base_export())(ifs); } - void operator() (bw_interface_type &s) { bind(s); } - - // Implementation of tlm_base_socket_if functions - virtual sc_core::sc_port_base &get_port_base() { return *this; } - virtual sc_core::sc_port_base const & - get_port_base() const - { - return *this; - } - virtual sc_core::sc_export_base &get_export_base() { return m_export; } - virtual sc_core::sc_export_base const & - get_export_base() const - { - return m_export; - } - virtual unsigned int get_bus_width() const { return BUSWIDTH; } - virtual tlm_socket_category - get_socket_category() const - { - return TLM_INITIATOR_SOCKET; - } - - // Implementation of tlm_base_target_socket_b functions - virtual sc_core::sc_port_b &get_base_port() { return *this; } - virtual sc_core::sc_port_b const & - get_base_port() const - { - return *this; - } - - virtual BW_IF &get_base_interface() { return m_export; } - virtual BW_IF const &get_base_interface() const { return m_export; } - - virtual sc_core::sc_export &get_base_export() { return m_export; } - virtual sc_core::sc_export const & - get_base_export() const - { - return m_export; - } - - protected: - export_type m_export; -}; - -// -// Convenience socket classes -// - -template -class tlm_initiator_socket : public tlm_base_initiator_socket< - BUSWIDTH, tlm_fw_transport_if, - tlm_bw_transport_if, N, POL> -{ - public: - tlm_initiator_socket() : tlm_base_initiator_socket< - BUSWIDTH, tlm_fw_transport_if, - tlm_bw_transport_if, N, POL>() - {} - - explicit tlm_initiator_socket(const char *name) : - tlm_base_initiator_socket, - tlm_bw_transport_if, N, POL>(name) - {} - - virtual const char *kind() const { return "tlm_initiator_socket"; } - - virtual sc_core::sc_type_index - get_protocol_types() const - { - return typeid(TYPES); - } -}; - -} // namespace tlm - -#endif /* __SYSTEMC_EXT_TLM_CORE_2_SOCKETS_INITIATOR_SOCKET_H__ */ diff --git a/src/systemc/ext/tlm_core/2/sockets/initiator_socket.hh b/src/systemc/ext/tlm_core/2/sockets/initiator_socket.hh new file mode 100644 index 000000000..91c147bc9 --- /dev/null +++ b/src/systemc/ext/tlm_core/2/sockets/initiator_socket.hh @@ -0,0 +1,204 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you 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. + + *****************************************************************************/ + +#ifndef __SYSTEMC_EXT_TLM_CORE_2_SOCKETS_INITIATOR_SOCKET_HH__ +#define __SYSTEMC_EXT_TLM_CORE_2_SOCKETS_INITIATOR_SOCKET_HH__ + +#include "tlm_core/2/interfaces/fw_bw_ifs.hh" +#include "tlm_core/2/sockets/base_socket_if.hh" + +namespace tlm +{ + +template , + typename BW_IF=tlm_bw_transport_if<>> +class tlm_base_initiator_socket_b +{ + public: + virtual ~tlm_base_initiator_socket_b() {} + + virtual sc_core::sc_port_b &get_base_port() = 0; + virtual sc_core::sc_port_b const &get_base_port() const = 0; + virtual BW_IF &get_base_interface() = 0; + virtual BW_IF const &get_base_interface() const = 0; + virtual sc_core::sc_export &get_base_export() = 0; + virtual sc_core::sc_export const &get_base_export() const = 0; +}; + +template +class tlm_base_target_socket_b; + +template +class tlm_base_target_socket; + +template , + typename BW_IF=tlm_bw_transport_if<>, int N=1, + sc_core::sc_port_policy POL=sc_core::SC_ONE_OR_MORE_BOUND> +class tlm_base_initiator_socket : + public tlm_base_socket_if, + public tlm_base_initiator_socket_b, + public sc_core::sc_port +{ + public: + typedef FW_IF fw_interface_type; + typedef BW_IF bw_interface_type; + typedef sc_core::sc_port port_type; + + typedef sc_core::sc_export export_type; + + typedef tlm_base_target_socket_b< + BUSWIDTH, fw_interface_type, bw_interface_type> + base_target_socket_type; + typedef tlm_base_initiator_socket_b< + BUSWIDTH, fw_interface_type, bw_interface_type> base_type; + + template + friend class tlm_base_target_socket; + + public: + tlm_base_initiator_socket() : + port_type(sc_core::sc_gen_unique_name("tlm_base_initiator_socket")), + m_export(sc_core::sc_gen_unique_name( + "tlm_base_initiator_socket_export")) + {} + + explicit tlm_base_initiator_socket(const char *name) : port_type(name), + m_export(sc_core::sc_gen_unique_name( + (std::string(name) + "_export").c_str())) + {} + + virtual const char* kind() const { return "tlm_base_initiator_socket"; } + + // + // Bind initiator socket to target socket + // - Binds the port of the initiator socket to the export of the target + // socket + // - Binds the port of the target socket to the export of the initiator + // socket + // + virtual void + bind(base_target_socket_type &s) + { + // initiator.port -> target.export + (get_base_port())(s.get_base_interface()); + // target.port -> initiator.export + (s.get_base_port())(get_base_interface()); + } + + void operator () (base_target_socket_type &s) { bind(s); } + + // + // Bind initiator socket to initiator socket (hierarchical bind) + // - Binds both the export and the port + // + virtual void + bind(base_type &s) + { + // port + (get_base_port())(s.get_base_port()); + // export + (s.get_base_export())(get_base_export()); + } + + void operator() (base_type &s) { bind(s); } + + // + // Bind interface to socket + // - Binds the interface to the export of this socket + // + virtual void bind(bw_interface_type &ifs) { (get_base_export())(ifs); } + void operator() (bw_interface_type &s) { bind(s); } + + // Implementation of tlm_base_socket_if functions + virtual sc_core::sc_port_base &get_port_base() { return *this; } + virtual sc_core::sc_port_base const & + get_port_base() const + { + return *this; + } + virtual sc_core::sc_export_base &get_export_base() { return m_export; } + virtual sc_core::sc_export_base const & + get_export_base() const + { + return m_export; + } + virtual unsigned int get_bus_width() const { return BUSWIDTH; } + virtual tlm_socket_category + get_socket_category() const + { + return TLM_INITIATOR_SOCKET; + } + + // Implementation of tlm_base_target_socket_b functions + virtual sc_core::sc_port_b &get_base_port() { return *this; } + virtual sc_core::sc_port_b const & + get_base_port() const + { + return *this; + } + + virtual BW_IF &get_base_interface() { return m_export; } + virtual BW_IF const &get_base_interface() const { return m_export; } + + virtual sc_core::sc_export &get_base_export() { return m_export; } + virtual sc_core::sc_export const & + get_base_export() const + { + return m_export; + } + + protected: + export_type m_export; +}; + +// +// Convenience socket classes +// + +template +class tlm_initiator_socket : public tlm_base_initiator_socket< + BUSWIDTH, tlm_fw_transport_if, + tlm_bw_transport_if, N, POL> +{ + public: + tlm_initiator_socket() : tlm_base_initiator_socket< + BUSWIDTH, tlm_fw_transport_if, + tlm_bw_transport_if, N, POL>() + {} + + explicit tlm_initiator_socket(const char *name) : + tlm_base_initiator_socket, + tlm_bw_transport_if, N, POL>(name) + {} + + virtual const char *kind() const { return "tlm_initiator_socket"; } + + virtual sc_core::sc_type_index + get_protocol_types() const + { + return typeid(TYPES); + } +}; + +} // namespace tlm + +#endif /* __SYSTEMC_EXT_TLM_CORE_2_SOCKETS_INITIATOR_SOCKET_HH__ */ diff --git a/src/systemc/ext/tlm_core/2/sockets/sockets.h b/src/systemc/ext/tlm_core/2/sockets/sockets.h deleted file mode 100644 index 53d1819a7..000000000 --- a/src/systemc/ext/tlm_core/2/sockets/sockets.h +++ /dev/null @@ -1,26 +0,0 @@ -/***************************************************************************** - - Licensed to Accellera Systems Initiative Inc. (Accellera) under one or - more contributor license agreements. See the NOTICE file distributed - with this work for additional information regarding copyright ownership. - Accellera licenses this file to you 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. - - *****************************************************************************/ - -#ifndef __SYSTEMC_EXT_TLM_CORE_2_SOCKETS_SOCKETS_H__ -#define __SYSTEMC_EXT_TLM_CORE_2_SOCKETS_SOCKETS_H__ - -#include "tlm_core/2/sockets/initiator_socket.h" -#include "tlm_core/2/sockets/target_socket.h" - -#endif /* __SYSTEMC_EXT_TLM_CORE_2_SOCKETS_SOCKETS_H__ */ diff --git a/src/systemc/ext/tlm_core/2/sockets/sockets.hh b/src/systemc/ext/tlm_core/2/sockets/sockets.hh new file mode 100644 index 000000000..781c51a26 --- /dev/null +++ b/src/systemc/ext/tlm_core/2/sockets/sockets.hh @@ -0,0 +1,26 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you 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. + + *****************************************************************************/ + +#ifndef __SYSTEMC_EXT_TLM_CORE_2_SOCKETS_SOCKETS_HH__ +#define __SYSTEMC_EXT_TLM_CORE_2_SOCKETS_SOCKETS_HH__ + +#include "tlm_core/2/sockets/initiator_socket.hh" +#include "tlm_core/2/sockets/target_socket.hh" + +#endif /* __SYSTEMC_EXT_TLM_CORE_2_SOCKETS_SOCKETS_HH__ */ diff --git a/src/systemc/ext/tlm_core/2/sockets/target_socket.h b/src/systemc/ext/tlm_core/2/sockets/target_socket.h deleted file mode 100644 index 7493c97dc..000000000 --- a/src/systemc/ext/tlm_core/2/sockets/target_socket.h +++ /dev/null @@ -1,223 +0,0 @@ -/***************************************************************************** - - Licensed to Accellera Systems Initiative Inc. (Accellera) under one or - more contributor license agreements. See the NOTICE file distributed - with this work for additional information regarding copyright ownership. - Accellera licenses this file to you 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. - - *****************************************************************************/ - -#ifndef __SYSTEMC_EXT_TLM_CORE_2_SOCKETS_TARGET_SOCKET_H__ -#define __SYSTEMC_EXT_TLM_CORE_2_SOCKETS_TARGET_SOCKET_H__ - -#include "tlm_core/2/interfaces/fw_bw_ifs.h" -#include "tlm_core/2/sockets/base_socket_if.h" - -namespace tlm -{ - -template , - typename BW_IF=tlm_bw_transport_if<>> -class tlm_base_target_socket_b -{ - public: - virtual ~tlm_base_target_socket_b() {} - - virtual sc_core::sc_port_b &get_base_port() = 0; - virtual sc_core::sc_export &get_base_export() = 0; - virtual FW_IF &get_base_interface() = 0; -}; - -template -class tlm_base_initiator_socket_b; - -template -class tlm_base_initiator_socket; - -template , - typename BW_IF=tlm_bw_transport_if<>, int N=1, - sc_core::sc_port_policy POL=sc_core::SC_ONE_OR_MORE_BOUND> -class tlm_base_target_socket : - public tlm_base_socket_if, - public tlm_base_target_socket_b, - public sc_core::sc_export -{ - public: - typedef FW_IF fw_interface_type; - typedef BW_IF bw_interface_type; - typedef sc_core::sc_port port_type; - - typedef sc_core::sc_export export_type; - typedef tlm_base_initiator_socket_b< - BUSWIDTH, fw_interface_type, bw_interface_type> - base_initiator_socket_type; - - typedef tlm_base_target_socket_b< - BUSWIDTH, fw_interface_type, bw_interface_type> base_type; - - template - friend class tlm_base_initiator_socket; - - public: - tlm_base_target_socket() : - export_type(sc_core::sc_gen_unique_name("tlm_base_target_socket")), - m_port(sc_core::sc_gen_unique_name("tlm_base_target_socket_port")) - {} - - explicit tlm_base_target_socket(const char *name) : - export_type(name), m_port(sc_core::sc_gen_unique_name( - (std::string(name) + "_port").c_str())) - {} - - virtual const char *kind() const { return "tlm_base_target_socket"; } - - // - // Bind target socket to initiator socket - // - Binds the port of the initiator socket to the export of the target - // socket - // - Binds the port of the target socket to the export of the initiator - // socket - // - virtual void - bind(base_initiator_socket_type &s) - { - // initiator.port -> target.export - (s.get_base_port())(get_base_interface()); - // target.port -> initiator.export - get_base_port()(s.get_base_interface()); - } - - void operator () (base_initiator_socket_type &s) { bind(s); } - - // - // Bind target socket to target socket (hierarchical bind) - // - Binds both the export and the port - // - virtual void - bind(base_type &s) - { - // export - (get_base_export())(s.get_base_export()); - // port - (s.get_base_port())(get_base_port()); - } - - void operator () (base_type &s) { bind(s); } - - // - // Bind interface to socket - // - Binds the interface to the export - // - virtual void - bind(fw_interface_type &ifs) - { - export_type *exp = &get_base_export(); - if (this == exp) { - export_type::bind(ifs); - } else { - exp->bind( ifs ); - } - } - - void operator () (fw_interface_type &s) { bind(s); } - - // - // Forward to 'size()' of port class. - // - int size() const { return m_port.size(); } - - // - // Forward to 'operator->()' of port class. - // - bw_interface_type *operator->() { return m_port.operator->(); } - - // - // Forward to 'operator[]()' of port class. - // - bw_interface_type *operator[](int i) { return m_port.operator[](i); } - - // Implementation of tlm_base_socket_if functions. - virtual sc_core::sc_port_base &get_port_base() { return m_port; } - virtual sc_core::sc_port_base const & - get_port_base() const - { - return m_port; - } - virtual sc_core::sc_export_base &get_export_base() { return *this; } - virtual sc_core::sc_export_base const & - get_export_base() const - { - return *this; - } - virtual unsigned int get_bus_width() const { return BUSWIDTH; } - virtual tlm_socket_category - get_socket_category() const - { - return TLM_TARGET_SOCKET; - } - - // Implementation of tlm_base_target_socket_b functions - virtual sc_core::sc_port_b &get_base_port() { return m_port; } - virtual sc_core::sc_port_b const & - get_base_port() const - { - return m_port; - } - - virtual FW_IF &get_base_interface() { return *this; } - virtual FW_IF const &get_base_interface() const { return *this; } - - virtual sc_core::sc_export &get_base_export() { return *this; } - virtual sc_core::sc_export const & - get_base_export() const - { - return *this; - } - - protected: - port_type m_port; -}; - -template -class tlm_target_socket : - public tlm_base_target_socket< - BUSWIDTH, tlm_fw_transport_if, - tlm_bw_transport_if, N, POL> -{ - public: - tlm_target_socket() : - tlm_base_target_socket< - BUSWIDTH, tlm_fw_transport_if, - tlm_bw_transport_if, N, POL>() - {} - - explicit tlm_target_socket(const char *name) : - tlm_base_target_socket< - BUSWIDTH, tlm_fw_transport_if, - tlm_bw_transport_if, N, POL>(name) - {} - - virtual const char* kind() const { return "tlm_target_socket"; } - - virtual sc_core::sc_type_index - get_protocol_types() const - { - return typeid(TYPES); - } -}; - -} // namespace tlm - -#endif /* __SYSTEMC_EXT_TLM_CORE_2_SOCKETS_TARGET_SOCKET_H__ */ diff --git a/src/systemc/ext/tlm_core/2/sockets/target_socket.hh b/src/systemc/ext/tlm_core/2/sockets/target_socket.hh new file mode 100644 index 000000000..b412a7d5c --- /dev/null +++ b/src/systemc/ext/tlm_core/2/sockets/target_socket.hh @@ -0,0 +1,223 @@ +/***************************************************************************** + + Licensed to Accellera Systems Initiative Inc. (Accellera) under one or + more contributor license agreements. See the NOTICE file distributed + with this work for additional information regarding copyright ownership. + Accellera licenses this file to you 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. + + *****************************************************************************/ + +#ifndef __SYSTEMC_EXT_TLM_CORE_2_SOCKETS_TARGET_SOCKET_HH__ +#define __SYSTEMC_EXT_TLM_CORE_2_SOCKETS_TARGET_SOCKET_HH__ + +#include "tlm_core/2/interfaces/fw_bw_ifs.hh" +#include "tlm_core/2/sockets/base_socket_if.hh" + +namespace tlm +{ + +template , + typename BW_IF=tlm_bw_transport_if<>> +class tlm_base_target_socket_b +{ + public: + virtual ~tlm_base_target_socket_b() {} + + virtual sc_core::sc_port_b &get_base_port() = 0; + virtual sc_core::sc_export &get_base_export() = 0; + virtual FW_IF &get_base_interface() = 0; +}; + +template +class tlm_base_initiator_socket_b; + +template +class tlm_base_initiator_socket; + +template , + typename BW_IF=tlm_bw_transport_if<>, int N=1, + sc_core::sc_port_policy POL=sc_core::SC_ONE_OR_MORE_BOUND> +class tlm_base_target_socket : + public tlm_base_socket_if, + public tlm_base_target_socket_b, + public sc_core::sc_export +{ + public: + typedef FW_IF fw_interface_type; + typedef BW_IF bw_interface_type; + typedef sc_core::sc_port port_type; + + typedef sc_core::sc_export export_type; + typedef tlm_base_initiator_socket_b< + BUSWIDTH, fw_interface_type, bw_interface_type> + base_initiator_socket_type; + + typedef tlm_base_target_socket_b< + BUSWIDTH, fw_interface_type, bw_interface_type> base_type; + + template + friend class tlm_base_initiator_socket; + + public: + tlm_base_target_socket() : + export_type(sc_core::sc_gen_unique_name("tlm_base_target_socket")), + m_port(sc_core::sc_gen_unique_name("tlm_base_target_socket_port")) + {} + + explicit tlm_base_target_socket(const char *name) : + export_type(name), m_port(sc_core::sc_gen_unique_name( + (std::string(name) + "_port").c_str())) + {} + + virtual const char *kind() const { return "tlm_base_target_socket"; } + + // + // Bind target socket to initiator socket + // - Binds the port of the initiator socket to the export of the target + // socket + // - Binds the port of the target socket to the export of the initiator + // socket + // + virtual void + bind(base_initiator_socket_type &s) + { + // initiator.port -> target.export + (s.get_base_port())(get_base_interface()); + // target.port -> initiator.export + get_base_port()(s.get_base_interface()); + } + + void operator () (base_initiator_socket_type &s) { bind(s); } + + // + // Bind target socket to target socket (hierarchical bind) + // - Binds both the export and the port + // + virtual void + bind(base_type &s) + { + // export + (get_base_export())(s.get_base_export()); + // port + (s.get_base_port())(get_base_port()); + } + + void operator () (base_type &s) { bind(s); } + + // + // Bind interface to socket + // - Binds the interface to the export + // + virtual void + bind(fw_interface_type &ifs) + { + export_type *exp = &get_base_export(); + if (this == exp) { + export_type::bind(ifs); + } else { + exp->bind( ifs ); + } + } + + void operator () (fw_interface_type &s) { bind(s); } + + // + // Forward to 'size()' of port class. + // + int size() const { return m_port.size(); } + + // + // Forward to 'operator->()' of port class. + // + bw_interface_type *operator->() { return m_port.operator->(); } + + // + // Forward to 'operator[]()' of port class. + // + bw_interface_type *operator[](int i) { return m_port.operator[](i); } + + // Implementation of tlm_base_socket_if functions. + virtual sc_core::sc_port_base &get_port_base() { return m_port; } + virtual sc_core::sc_port_base const & + get_port_base() const + { + return m_port; + } + virtual sc_core::sc_export_base &get_export_base() { return *this; } + virtual sc_core::sc_export_base const & + get_export_base() const + { + return *this; + } + virtual unsigned int get_bus_width() const { return BUSWIDTH; } + virtual tlm_socket_category + get_socket_category() const + { + return TLM_TARGET_SOCKET; + } + + // Implementation of tlm_base_target_socket_b functions + virtual sc_core::sc_port_b &get_base_port() { return m_port; } + virtual sc_core::sc_port_b const & + get_base_port() const + { + return m_port; + } + + virtual FW_IF &get_base_interface() { return *this; } + virtual FW_IF const &get_base_interface() const { return *this; } + + virtual sc_core::sc_export &get_base_export() { return *this; } + virtual sc_core::sc_export const & + get_base_export() const + { + return *this; + } + + protected: + port_type m_port; +}; + +template +class tlm_target_socket : + public tlm_base_target_socket< + BUSWIDTH, tlm_fw_transport_if, + tlm_bw_transport_if, N, POL> +{ + public: + tlm_target_socket() : + tlm_base_target_socket< + BUSWIDTH, tlm_fw_transport_if, + tlm_bw_transport_if, N, POL>() + {} + + explicit tlm_target_socket(const char *name) : + tlm_base_target_socket< + BUSWIDTH, tlm_fw_transport_if, + tlm_bw_transport_if, N, POL>(name) + {} + + virtual const char* kind() const { return "tlm_target_socket"; } + + virtual sc_core::sc_type_index + get_protocol_types() const + { + return typeid(TYPES); + } +}; + +} // namespace tlm + +#endif /* __SYSTEMC_EXT_TLM_CORE_2_SOCKETS_TARGET_SOCKET_HH__ */ -- cgit v1.2.3