Deleted Added
sdiff udiff text old ( 14189:a363edac6a12 ) new ( 14276:3fee93856d55 )
full compact
1/*
2 * Copyright 2018 Google, Inc.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met: redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer;
8 * redistributions in binary form must reproduce the above copyright

--- 23 unchanged lines hidden (view full) ---

32
33#include "base/logging.hh"
34#include "sim/port.hh"
35#include "systemc/ext/tlm_core/2/sockets/sockets.hh"
36
37namespace sc_gem5
38{
39
40template <unsigned int BUSWIDTH, typename FW_IF, typename BW_IF, int N,
41 sc_core::sc_port_policy POL>
42class TlmInitiatorBaseWrapper;
43
44template <unsigned int BUSWIDTH, typename FW_IF, typename BW_IF, int N,
45 sc_core::sc_port_policy POL>
46class TlmTargetBaseWrapper;
47
48template <unsigned int BUSWIDTH, typename FW_IF, typename BW_IF, int N,
49 sc_core::sc_port_policy POL>
50class TlmInitiatorBaseWrapper : public ::Port
51{
52 public:
53 typedef tlm::tlm_base_initiator_socket<BUSWIDTH, FW_IF, BW_IF, N, POL>
54 InitiatorSocket;
55 typedef typename InitiatorSocket::base_target_socket_type TargetSocket;
56 typedef TlmTargetBaseWrapper<BUSWIDTH, FW_IF, BW_IF, N, POL> TargetWrapper;
57
58 InitiatorSocket &initiator() { return _initiator; }
59
60 TlmInitiatorBaseWrapper(
61 InitiatorSocket &i, const std::string &_name, PortID _id) :
62 Port(_name, _id), _initiator(i)
63 {}
64
65 void
66 bind(::Port &peer) override
67 {
68 auto *target = dynamic_cast<TargetWrapper *>(&peer);

--- 9 unchanged lines hidden (view full) ---

78 {
79 panic("TLM sockets can't be unbound.");
80 }
81
82 private:
83 InitiatorSocket &_initiator;
84};
85
86template <unsigned int BUSWIDTH, typename FW_IF, typename BW_IF, int N,
87 sc_core::sc_port_policy POL>
88class TlmTargetBaseWrapper : public ::Port
89{
90 public:
91 typedef tlm::tlm_base_target_socket<BUSWIDTH, FW_IF, BW_IF, N, POL>
92 TargetSocket;
93
94 TargetSocket &target() { return _target; }
95
96 TlmTargetBaseWrapper(TargetSocket &t, const std::string &_name,
97 PortID _id) :
98 Port(_name, _id), _target(t)
99 {}
100
101 void
102 bind(::Port &peer) override
103 {
104 // Ignore attempts to bind a target socket. The initiator will
105 // handle it.

--- 5 unchanged lines hidden (view full) ---

111 {
112 panic("TLM sockets can't be unbound.");
113 }
114
115 private:
116 TargetSocket &_target;
117};
118
119template <unsigned int BUSWIDTH=32,
120 typename TYPES=tlm::tlm_base_protocol_types, int N=1,
121 sc_core::sc_port_policy POL=sc_core::SC_ONE_OR_MORE_BOUND>
122using TlmInitiatorWrapper =
123 TlmInitiatorBaseWrapper<BUSWIDTH, tlm::tlm_fw_transport_if<TYPES>,
124 tlm::tlm_bw_transport_if<TYPES>, N, POL>;
125
126template <unsigned int BUSWIDTH=32,
127 typename TYPES=tlm::tlm_base_protocol_types, int N=1,
128 sc_core::sc_port_policy POL=sc_core::SC_ONE_OR_MORE_BOUND>
129using TlmTargetWrapper =
130 TlmTargetBaseWrapper<BUSWIDTH, tlm::tlm_fw_transport_if<TYPES>,
131 tlm::tlm_bw_transport_if<TYPES>, N, POL>;
132
133} // namespace sc_gem5
134
135#endif //__SYSTEMC_TLM_PORT_WRAPPER_HH__