Tlm.py revision 13873
113873Sgabeblack@google.com# Copyright 2019 Google, Inc. 213873Sgabeblack@google.com# 313873Sgabeblack@google.com# Redistribution and use in source and binary forms, with or without 413873Sgabeblack@google.com# modification, are permitted provided that the following conditions are 513873Sgabeblack@google.com# met: redistributions of source code must retain the above copyright 613873Sgabeblack@google.com# notice, this list of conditions and the following disclaimer; 713873Sgabeblack@google.com# redistributions in binary form must reproduce the above copyright 813873Sgabeblack@google.com# notice, this list of conditions and the following disclaimer in the 913873Sgabeblack@google.com# documentation and/or other materials provided with the distribution; 1013873Sgabeblack@google.com# neither the name of the copyright holders nor the names of its 1113873Sgabeblack@google.com# contributors may be used to endorse or promote products derived from 1213873Sgabeblack@google.com# this software without specific prior written permission. 1313873Sgabeblack@google.com# 1413873Sgabeblack@google.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1513873Sgabeblack@google.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1613873Sgabeblack@google.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1713873Sgabeblack@google.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 1813873Sgabeblack@google.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 1913873Sgabeblack@google.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2013873Sgabeblack@google.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2113873Sgabeblack@google.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2213873Sgabeblack@google.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2313873Sgabeblack@google.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2413873Sgabeblack@google.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2513873Sgabeblack@google.com# 2613873Sgabeblack@google.com# Authors: Gabe Black 2713873Sgabeblack@google.com 2813873Sgabeblack@google.comfrom m5.params import Port, VectorPort 2913873Sgabeblack@google.com 3013873Sgabeblack@google.comdef TLM_TARGET_ROLE(width): 3113873Sgabeblack@google.com return 'TLM TARGET %d' % width 3213873Sgabeblack@google.com 3313873Sgabeblack@google.comdef TLM_INITIATOR_ROLE(width): 3413873Sgabeblack@google.com return 'TLM INITIATOR %d' % width 3513873Sgabeblack@google.com 3613873Sgabeblack@google.comclass TlmTargetSocket(Port): 3713873Sgabeblack@google.com def __init__(self, width, desc): 3813873Sgabeblack@google.com my_role = TLM_TARGET_ROLE(width) 3913873Sgabeblack@google.com peer_role = TLM_INITIATOR_ROLE(width) 4013873Sgabeblack@google.com Port.compat(my_role, peer_role) 4113873Sgabeblack@google.com 4213873Sgabeblack@google.com super(TlmTargetSocket, self).__init__(my_role, desc) 4313873Sgabeblack@google.com 4413873Sgabeblack@google.comclass VectorTlmTargetSocket(VectorPort): 4513873Sgabeblack@google.com def __init__(self, width, desc): 4613873Sgabeblack@google.com my_role = TLM_TARGET_ROLE(width) 4713873Sgabeblack@google.com peer_role = TLM_INITIATOR_ROLE(width) 4813873Sgabeblack@google.com Port.compat(my_role, peer_role) 4913873Sgabeblack@google.com 5013873Sgabeblack@google.com super(VectorTlmTargetSocket, self).__init__(my_role, desc) 5113873Sgabeblack@google.com 5213873Sgabeblack@google.comclass TlmInitiatorSocket(Port): 5313873Sgabeblack@google.com def __init__(self, width, desc): 5413873Sgabeblack@google.com my_role = TLM_INITIATOR_ROLE(width) 5513873Sgabeblack@google.com peer_role = TLM_TARGET_ROLE(width) 5613873Sgabeblack@google.com Port.compat(my_role, peer_role) 5713873Sgabeblack@google.com 5813873Sgabeblack@google.com super(TlmInitiatorSocket, self).__init__(my_role, desc, is_source=True) 5913873Sgabeblack@google.com 6013873Sgabeblack@google.comclass VectorTlmInitiatorSocket(VectorPort): 6113873Sgabeblack@google.com def __init__(self, width, desc): 6213873Sgabeblack@google.com my_role = TLM_INITIATOR_ROLE(width) 6313873Sgabeblack@google.com peer_role = TLM_TARGET_ROLE(width) 6413873Sgabeblack@google.com Port.compat(my_role, peer_role) 6513873Sgabeblack@google.com 6613873Sgabeblack@google.com super(VectorTlmInitiatorSocket, self).__init__( 6713873Sgabeblack@google.com my_role, desc, is_source=True) 68