1 # Copyright 2019 Google, Inc.
3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are
5 # met: redistributions of source code must retain the above copyright
6 # notice, this list of conditions and the following disclaimer;
7 # redistributions in binary form must reproduce the above copyright
8 # notice, this list of conditions and the following disclaimer in the
9 # documentation and/or other materials provided with the distribution;
10 # neither the name of the copyright holders nor the names of its
11 # contributors may be used to endorse or promote products derived from
12 # this software without specific prior written permission.
14 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
15 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
16 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
17 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
18 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
19 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
20 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 from m5
.params
import *
29 from m5
.proxy
import *
31 from m5
.objects
.SystemC
import SystemC_ScModule
32 from m5
.objects
.Tlm
import TlmInitiatorSocket
, TlmTargetSocket
34 def AMBA_TARGET_ROLE(width
):
35 return 'AMBA TARGET %d' % width
37 def AMBA_INITIATOR_ROLE(width
):
38 return 'AMBA INITIATOR %d' % width
40 def SC_MASTER_PORT_ROLE(port_type
):
41 return 'SC MASTER PORT for %s' % port_type
43 def SC_SLAVE_PORT_ROLE(port_type
):
44 return 'SC SLAVE PORT for %s' % port_type
46 class AmbaTargetSocket(Port
):
47 def __init__(self
, width
, desc
):
48 my_role
= AMBA_INITIATOR_ROLE(width
)
49 peer_role
= AMBA_TARGET_ROLE(width
)
50 Port
.compat(my_role
, peer_role
)
52 super(AmbaTargetSocket
, self
).__init
__(my_role
, desc
)
54 class VectorAmbaTargetSocket(VectorPort
):
55 def __init__(self
, width
, desc
):
56 my_role
= AMBA_INITIATOR_ROLE(width
)
57 peer_role
= AMBA_TARGET_ROLE(width
)
58 Port
.compat(my_role
, peer_role
)
60 super(VectorAmbaTargetSocket
, self
).__init
__(my_role
, desc
)
62 class AmbaInitiatorSocket(Port
):
63 def __init__(self
, width
, desc
):
64 my_role
= AMBA_TARGET_ROLE(width
)
65 peer_role
= AMBA_INITIATOR_ROLE(width
)
66 Port
.compat(my_role
, peer_role
)
68 super(AmbaInitiatorSocket
, self
).__init
__(
69 my_role
, desc
, is_source
=True)
71 class VectorAmbaInitiatorSocket(VectorPort
):
72 def __init__(self
, width
, desc
):
73 my_role
= AMBA_TARGET_ROLE(width
)
74 peer_role
= AMBA_INITIATOR_ROLE(width
)
75 Port
.compat(my_role
, peer_role
)
77 super(VectorAmbaInitiatorSocket
, self
).__init
__(
78 my_role
, desc
, is_source
=True)
80 class ScMasterPort(Port
):
81 def __init__(self
, desc
, port_type
):
82 my_role
= SC_MASTER_PORT_ROLE(port_type
)
83 peer_role
= SC_SLAVE_PORT_ROLE(port_type
)
84 Port
.compat(my_role
, peer_role
)
86 super(ScMasterPort
, self
).__init
__(my_role
, desc
)
88 class ScSlavePort(Port
):
89 def __init__(self
, desc
, port_type
):
90 my_role
= SC_SLAVE_PORT_ROLE(port_type
)
91 peer_role
= SC_MASTER_PORT_ROLE(port_type
)
92 Port
.compat(my_role
, peer_role
)
94 super(ScSlavePort
, self
).__init
__(my_role
, desc
)
96 class AmbaToTlmBridge64(SystemC_ScModule
):
97 type = 'AmbaToTlmBridge64'
98 cxx_class
= 'FastModel::AmbaToTlmBridge64'
99 cxx_header
= 'arch/arm/fastmodel/amba_to_tlm_bridge.hh'
101 amba
= AmbaTargetSocket(64, 'AMBA PV target socket')
102 tlm
= TlmInitiatorSocket(64, 'TLM initiator socket')
104 class AmbaFromTlmBridge64(SystemC_ScModule
):
105 type = 'AmbaFromTlmBridge64'
106 cxx_class
= 'FastModel::AmbaFromTlmBridge64'
107 cxx_header
= 'arch/arm/fastmodel/amba_from_tlm_bridge.hh'
109 tlm
= TlmTargetSocket(64, 'TLM target socket')
110 amba
= AmbaInitiatorSocket(64, 'AMBA PV initiator socket')