summaryrefslogtreecommitdiff
path: root/ext/systemc/src/tlm_core/tlm_2/tlm_sockets/tlm_target_socket.h
diff options
context:
space:
mode:
authorMatthias Jung <jungma@eit.uni-kl.de>2017-03-01 18:39:56 +0100
committerMatthias Jung <jungma@eit.uni-kl.de>2017-05-18 08:36:56 +0000
commitaa651c7f8321bf96fc88f9a17285225000a753ec (patch)
treeb13240008c970b47bd74a5007e68136155d272fc /ext/systemc/src/tlm_core/tlm_2/tlm_sockets/tlm_target_socket.h
parent595e692de09e1b7cbc5f57ac01da299afc066fdd (diff)
downloadgem5-aa651c7f8321bf96fc88f9a17285225000a753ec.tar.xz
ext: Include SystemC 2.3.1 into gem5
In the past it happened several times that some changes in gem5 broke the SystemC coupling. Recently Accelera has changed the licence for SystemC from their own licence to Apache2.0, which is compatible with gem5. However, SystemC usually relies on the Boost library, but I was able to exchange the boost calls by c++11 alternatives. The recent SystemC version is placed into /ext and is integrated into gem5's build system. The goal is to integrate some SystemC tests for the CI in some following patches. Change-Id: I4b66ec806b5e3cffc1d7c85d3735ff4fa5b31fd0 Reviewed-on: https://gem5-review.googlesource.com/2240 Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
Diffstat (limited to 'ext/systemc/src/tlm_core/tlm_2/tlm_sockets/tlm_target_socket.h')
-rw-r--r--ext/systemc/src/tlm_core/tlm_2/tlm_sockets/tlm_target_socket.h275
1 files changed, 275 insertions, 0 deletions
diff --git a/ext/systemc/src/tlm_core/tlm_2/tlm_sockets/tlm_target_socket.h b/ext/systemc/src/tlm_core/tlm_2/tlm_sockets/tlm_target_socket.h
new file mode 100644
index 000000000..4ed29f62a
--- /dev/null
+++ b/ext/systemc/src/tlm_core/tlm_2/tlm_sockets/tlm_target_socket.h
@@ -0,0 +1,275 @@
+/*****************************************************************************
+
+ 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 __TLM_TARGET_SOCKET_H__
+#define __TLM_TARGET_SOCKET_H__
+
+//#include <systemc>
+#include "tlm_core/tlm_2/tlm_2_interfaces/tlm_fw_bw_ifs.h"
+
+
+namespace tlm {
+
+template <unsigned int BUSWIDTH = 32,
+ typename FW_IF = tlm_fw_transport_if<>,
+ 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<BW_IF> & get_base_port() = 0;
+ virtual sc_core::sc_export<FW_IF> & get_base_export() = 0;
+ virtual FW_IF & get_base_interface() = 0;
+};
+
+template <unsigned int BUSWIDTH,
+ typename FW_IF,
+ typename BW_IF> class tlm_base_initiator_socket_b;
+
+template <unsigned int BUSWIDTH,
+ typename FW_IF,
+ typename BW_IF,
+ int N
+#if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
+ ,sc_core::sc_port_policy POL
+#endif
+ > class tlm_base_initiator_socket;
+
+template <unsigned int BUSWIDTH = 32,
+ typename FW_IF = tlm_fw_transport_if<>,
+ typename BW_IF = tlm_bw_transport_if<>,
+ int N = 1
+#if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
+ ,sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND
+#endif
+ >
+class tlm_base_target_socket : public tlm_base_target_socket_b<BUSWIDTH, FW_IF, BW_IF>,
+ public sc_core::sc_export<FW_IF>
+{
+public:
+ typedef FW_IF fw_interface_type;
+ typedef BW_IF bw_interface_type;
+ typedef sc_core::sc_port<bw_interface_type, N
+#if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
+ , POL
+#endif
+ > port_type;
+
+ typedef sc_core::sc_export<fw_interface_type> 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 <unsigned int, typename, typename, int
+#if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
+ ,sc_core::sc_port_policy
+#endif
+
+ >
+ 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";
+ }
+
+ unsigned int get_bus_width() const
+ {
+ return BUSWIDTH;
+ }
+
+ //
+ // 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 ); // non-virtual function call
+ } 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 pure virtual functions of base class
+
+ virtual sc_core::sc_port_b<BW_IF> & get_base_port()
+ { return m_port; }
+ virtual sc_core::sc_port_b<BW_IF> const & get_base_port() const
+ { return m_port; }
+
+ virtual FW_IF & get_base_interface()
+ { return *this; }
+ virtual FW_IF const & get_base_interface() const
+#if !( defined(IEEE_1666_SYSTEMC) && IEEE_1666_SYSTEMC >= 201101L )
+ { return *const_cast<export_type*>(static_cast<export_type const*>(this)); }
+#else
+ { return *this; }
+#endif
+
+ virtual sc_core::sc_export<FW_IF> & get_base_export()
+ { return *this; }
+ virtual sc_core::sc_export<FW_IF> const & get_base_export() const
+ { return *this; }
+
+protected:
+ port_type m_port;
+};
+
+
+//
+// Convenience blocking and non-blocking socket classes
+//
+
+template <unsigned int BUSWIDTH = 32,
+ typename TYPES = tlm_base_protocol_types,
+ int N = 1
+#if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
+ ,sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND
+#endif
+ >
+class tlm_target_socket :
+ public tlm_base_target_socket <BUSWIDTH,
+ tlm_fw_transport_if<TYPES>,
+ tlm_bw_transport_if<TYPES>,
+ N
+#if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
+ ,POL
+#endif
+ >
+{
+public:
+ tlm_target_socket() :
+ tlm_base_target_socket<BUSWIDTH,
+ tlm_fw_transport_if<TYPES>,
+ tlm_bw_transport_if<TYPES>,
+ N
+#if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
+ ,POL
+#endif
+ >()
+ {
+ }
+
+ explicit tlm_target_socket(const char* name) :
+ tlm_base_target_socket<BUSWIDTH,
+ tlm_fw_transport_if<TYPES>,
+ tlm_bw_transport_if<TYPES>,
+ N
+#if !(defined SYSTEMC_VERSION & SYSTEMC_VERSION <= 20050714)
+ ,POL
+#endif
+ >(name)
+ {
+ }
+
+ virtual const char* kind() const
+ {
+ return "tlm_target_socket";
+ }
+};
+
+} // namespace tlm
+
+#endif