113821Sgabeblack@google.com# Copyright 2019 Google, Inc.
213821Sgabeblack@google.com#
313821Sgabeblack@google.com# Redistribution and use in source and binary forms, with or without
413821Sgabeblack@google.com# modification, are permitted provided that the following conditions are
513821Sgabeblack@google.com# met: redistributions of source code must retain the above copyright
613821Sgabeblack@google.com# notice, this list of conditions and the following disclaimer;
713821Sgabeblack@google.com# redistributions in binary form must reproduce the above copyright
813821Sgabeblack@google.com# notice, this list of conditions and the following disclaimer in the
913821Sgabeblack@google.com# documentation and/or other materials provided with the distribution;
1013821Sgabeblack@google.com# neither the name of the copyright holders nor the names of its
1113821Sgabeblack@google.com# contributors may be used to endorse or promote products derived from
1213821Sgabeblack@google.com# this software without specific prior written permission.
1313821Sgabeblack@google.com#
1413821Sgabeblack@google.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1513821Sgabeblack@google.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1613821Sgabeblack@google.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1713821Sgabeblack@google.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1813821Sgabeblack@google.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1913821Sgabeblack@google.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2013821Sgabeblack@google.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2113821Sgabeblack@google.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2213821Sgabeblack@google.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2313821Sgabeblack@google.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2413821Sgabeblack@google.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2513821Sgabeblack@google.com#
2613821Sgabeblack@google.com# Authors: Gabe Black
2713821Sgabeblack@google.com
2813821Sgabeblack@google.comfrom m5.objects.SystemC import SystemC_ScModule
2913821Sgabeblack@google.comfrom m5.params import *
3013821Sgabeblack@google.comfrom m5.proxy import *
3113821Sgabeblack@google.com
3213874Sgabeblack@google.comfrom m5.objects.Tlm import TlmTargetSocket, TlmInitiatorSocket
3313874Sgabeblack@google.com
3413823Sgabeblack@google.comclass Gem5ToTlmBridgeBase(SystemC_ScModule):
3513823Sgabeblack@google.com    type = 'Gem5ToTlmBridgeBase'
3613823Sgabeblack@google.com    abstract = True
3713823Sgabeblack@google.com    cxx_class = 'sc_gem5::Gem5ToTlmBridgeBase'
3813821Sgabeblack@google.com    cxx_header = 'systemc/tlm_bridge/gem5_to_tlm.hh'
3913821Sgabeblack@google.com
4013821Sgabeblack@google.com    system = Param.System(Parent.any, "system")
4113821Sgabeblack@google.com
4213821Sgabeblack@google.com    gem5 = SlavePort('gem5 slave port')
4313821Sgabeblack@google.com    addr_ranges = VectorParam.AddrRange([],
4413821Sgabeblack@google.com            'Addresses served by this port\'s TLM side')
4513821Sgabeblack@google.com
4613823Sgabeblack@google.comclass TlmToGem5BridgeBase(SystemC_ScModule):
4713823Sgabeblack@google.com    type = 'TlmToGem5BridgeBase'
4813823Sgabeblack@google.com    abstract = True
4913823Sgabeblack@google.com    cxx_class = 'sc_gem5::TlmToGem5BridgeBase'
5013821Sgabeblack@google.com    cxx_header = 'systemc/tlm_bridge/tlm_to_gem5.hh'
5113821Sgabeblack@google.com
5213821Sgabeblack@google.com    system = Param.System(Parent.any, "system")
5313821Sgabeblack@google.com
5413821Sgabeblack@google.com    gem5 = MasterPort('gem5 master port')
5513823Sgabeblack@google.com
5613823Sgabeblack@google.com
5713823Sgabeblack@google.comclass Gem5ToTlmBridge32(Gem5ToTlmBridgeBase):
5813823Sgabeblack@google.com    type = 'Gem5ToTlmBridge32'
5913823Sgabeblack@google.com    cxx_template_params = [ 'unsigned int BITWIDTH' ]
6013823Sgabeblack@google.com    cxx_class = 'sc_gem5::Gem5ToTlmBridge<32>'
6113823Sgabeblack@google.com    cxx_header = 'systemc/tlm_bridge/gem5_to_tlm.hh'
6213823Sgabeblack@google.com
6313874Sgabeblack@google.com    tlm = TlmInitiatorSocket(32, 'TLM initiator socket')
6413874Sgabeblack@google.com
6513823Sgabeblack@google.comclass Gem5ToTlmBridge64(Gem5ToTlmBridgeBase):
6613823Sgabeblack@google.com    type = 'Gem5ToTlmBridge64'
6713823Sgabeblack@google.com    cxx_template_params = [ 'unsigned int BITWIDTH' ]
6813823Sgabeblack@google.com    cxx_class = 'sc_gem5::Gem5ToTlmBridge<64>'
6913823Sgabeblack@google.com    cxx_header = 'systemc/tlm_bridge/gem5_to_tlm.hh'
7013823Sgabeblack@google.com
7113874Sgabeblack@google.com    tlm = TlmInitiatorSocket(64, 'TLM initiator socket')
7213874Sgabeblack@google.com
7313823Sgabeblack@google.com
7413823Sgabeblack@google.comclass TlmToGem5Bridge32(TlmToGem5BridgeBase):
7513823Sgabeblack@google.com    type = 'TlmToGem5Bridge32'
7613823Sgabeblack@google.com    cxx_template_params = [ 'unsigned int BITWIDTH' ]
7713823Sgabeblack@google.com    cxx_class = 'sc_gem5::TlmToGem5Bridge<32>'
7813823Sgabeblack@google.com    cxx_header = 'systemc/tlm_bridge/tlm_to_gem5.hh'
7913823Sgabeblack@google.com
8013874Sgabeblack@google.com    tlm = TlmTargetSocket(32, 'TLM target socket')
8113874Sgabeblack@google.com
8213823Sgabeblack@google.comclass TlmToGem5Bridge64(TlmToGem5BridgeBase):
8313823Sgabeblack@google.com    type = 'TlmToGem5Bridge64'
8413823Sgabeblack@google.com    cxx_template_params = [ 'unsigned int BITWIDTH' ]
8513823Sgabeblack@google.com    cxx_class = 'sc_gem5::TlmToGem5Bridge<64>'
8613823Sgabeblack@google.com    cxx_header = 'systemc/tlm_bridge/tlm_to_gem5.hh'
8713874Sgabeblack@google.com
8813874Sgabeblack@google.com    tlm = TlmTargetSocket(64, 'TLM target socket')
89