systemc: Make TLM port wrappers for tlm_base_(target|initiator)_socket.
authorGabe Black <gabeblack@google.com>
Fri, 13 Sep 2019 22:02:53 +0000 (15:02 -0700)
committerGabe Black <gabeblack@google.com>
Tue, 17 Sep 2019 19:07:59 +0000 (19:07 +0000)
These are useful if using TLM sockets without using the standard TLM
protocol. For instance, when used with ARM's fast models, this can wrap
sockets which carry the opaque GICv3Comms protocol.

Change-Id: I329a919068f958abbde2cb83683d3a3ae2e05a20
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/20860
Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Maintainer: Gabe Black <gabeblack@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
src/systemc/tlm_port_wrapper.hh

index 59f8d9fe00c8415bfd30c24aefe67b96c69040e9..1e46c5d8272bbb85b935047f3c40a770713bc6f5 100644 (file)
 namespace sc_gem5
 {
 
-template <unsigned int BUSWIDTH=32,
-          typename TYPES=tlm::tlm_base_protocol_types, int N=1,
-          sc_core::sc_port_policy POL=sc_core::SC_ONE_OR_MORE_BOUND>
-class TlmInitiatorWrapper;
+template <unsigned int BUSWIDTH, typename FW_IF, typename BW_IF, int N,
+          sc_core::sc_port_policy POL>
+class TlmInitiatorBaseWrapper;
 
-template <unsigned int BUSWIDTH=32,
-          typename TYPES=tlm::tlm_base_protocol_types, int N=1,
-          sc_core::sc_port_policy POL=sc_core::SC_ONE_OR_MORE_BOUND>
-class TlmTargetWrapper;
+template <unsigned int BUSWIDTH, typename FW_IF, typename BW_IF, int N,
+          sc_core::sc_port_policy POL>
+class TlmTargetBaseWrapper;
 
-template <unsigned int BUSWIDTH, typename TYPES, int N,
+template <unsigned int BUSWIDTH, typename FW_IF, typename BW_IF, int N,
           sc_core::sc_port_policy POL>
-class TlmInitiatorWrapper : public ::Port
+class TlmInitiatorBaseWrapper : public ::Port
 {
   public:
-    typedef tlm::tlm_base_initiator_socket<BUSWIDTH,
-            tlm::tlm_fw_transport_if<TYPES>,
-            tlm::tlm_bw_transport_if<TYPES>, N, POL>
+    typedef tlm::tlm_base_initiator_socket<BUSWIDTH, FW_IF, BW_IF, N, POL>
         InitiatorSocket;
     typedef typename InitiatorSocket::base_target_socket_type TargetSocket;
-    typedef TlmTargetWrapper<BUSWIDTH, TYPES, N, POL> TargetWrapper;
+    typedef TlmTargetBaseWrapper<BUSWIDTH, FW_IF, BW_IF, N, POL> TargetWrapper;
 
     InitiatorSocket &initiator() { return _initiator; }
 
-    TlmInitiatorWrapper(
+    TlmInitiatorBaseWrapper(
             InitiatorSocket &i, const std::string &_name, PortID _id) :
         Port(_name, _id), _initiator(i)
     {}
@@ -87,19 +83,18 @@ class TlmInitiatorWrapper : public ::Port
     InitiatorSocket &_initiator;
 };
 
-template <unsigned int BUSWIDTH, typename TYPES, int N,
+template <unsigned int BUSWIDTH, typename FW_IF, typename BW_IF, int N,
           sc_core::sc_port_policy POL>
-class TlmTargetWrapper : public ::Port
+class TlmTargetBaseWrapper : public ::Port
 {
   public:
-    typedef tlm::tlm_base_target_socket<BUSWIDTH,
-            tlm::tlm_fw_transport_if<TYPES>,
-            tlm::tlm_bw_transport_if<TYPES>, N, POL>
+    typedef tlm::tlm_base_target_socket<BUSWIDTH, FW_IF, BW_IF, N, POL>
         TargetSocket;
 
     TargetSocket &target() { return _target; }
 
-    TlmTargetWrapper(TargetSocket &t, const std::string &_name, PortID _id) :
+    TlmTargetBaseWrapper(TargetSocket &t, const std::string &_name,
+                         PortID _id) :
         Port(_name, _id), _target(t)
     {}
 
@@ -121,6 +116,20 @@ class TlmTargetWrapper : public ::Port
     TargetSocket &_target;
 };
 
+template <unsigned int BUSWIDTH=32,
+          typename TYPES=tlm::tlm_base_protocol_types, int N=1,
+          sc_core::sc_port_policy POL=sc_core::SC_ONE_OR_MORE_BOUND>
+using TlmInitiatorWrapper =
+    TlmInitiatorBaseWrapper<BUSWIDTH, tlm::tlm_fw_transport_if<TYPES>,
+                            tlm::tlm_bw_transport_if<TYPES>, N, POL>;
+
+template <unsigned int BUSWIDTH=32,
+          typename TYPES=tlm::tlm_base_protocol_types, int N=1,
+          sc_core::sc_port_policy POL=sc_core::SC_ONE_OR_MORE_BOUND>
+using TlmTargetWrapper =
+    TlmTargetBaseWrapper<BUSWIDTH, tlm::tlm_fw_transport_if<TYPES>,
+                         tlm::tlm_bw_transport_if<TYPES>, N, POL>;
+
 } // namespace sc_gem5
 
 #endif  //__SYSTEMC_TLM_PORT_WRAPPER_HH__