port.hh revision 13782
113771Sgabeblack@google.com/* 213771Sgabeblack@google.com * Copyright (c) 2011-2012,2015,2017 ARM Limited 313771Sgabeblack@google.com * All rights reserved 413771Sgabeblack@google.com * 513771Sgabeblack@google.com * The license below extends only to copyright in the software and shall 613771Sgabeblack@google.com * not be construed as granting a license to any other intellectual 713771Sgabeblack@google.com * property including but not limited to intellectual property relating 813771Sgabeblack@google.com * to a hardware implementation of the functionality of the software 913771Sgabeblack@google.com * licensed hereunder. You may use the software subject to the license 1013771Sgabeblack@google.com * terms below provided that you ensure that this notice is replicated 1113771Sgabeblack@google.com * unmodified and in its entirety in all distributions of the software, 1213771Sgabeblack@google.com * modified or unmodified, in source code or in binary form. 1313771Sgabeblack@google.com * 1413771Sgabeblack@google.com * Copyright (c) 2002-2005 The Regents of The University of Michigan 1513771Sgabeblack@google.com * All rights reserved. 1613771Sgabeblack@google.com * 1713771Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without 1813771Sgabeblack@google.com * modification, are permitted provided that the following conditions are 1913771Sgabeblack@google.com * met: redistributions of source code must retain the above copyright 2013771Sgabeblack@google.com * notice, this list of conditions and the following disclaimer; 2113771Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright 2213771Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the 2313771Sgabeblack@google.com * documentation and/or other materials provided with the distribution; 2413771Sgabeblack@google.com * neither the name of the copyright holders nor the names of its 2513771Sgabeblack@google.com * contributors may be used to endorse or promote products derived from 2613771Sgabeblack@google.com * this software without specific prior written permission. 2713771Sgabeblack@google.com * 2813771Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 2913771Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 3013771Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 3113771Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 3213771Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 3313771Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 3413771Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 3513771Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 3613771Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 3713771Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 3813771Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3913771Sgabeblack@google.com * 4013771Sgabeblack@google.com * Authors: Ron Dreslinski 4113771Sgabeblack@google.com * Andreas Hansson 4213771Sgabeblack@google.com * William Wang 4313771Sgabeblack@google.com */ 4413771Sgabeblack@google.com 4513771Sgabeblack@google.com/** 4613771Sgabeblack@google.com * @file 4713771Sgabeblack@google.com * Port Object Declaration. 4813771Sgabeblack@google.com */ 4913771Sgabeblack@google.com 5013771Sgabeblack@google.com#ifndef __SIM_PORT_HH__ 5113771Sgabeblack@google.com#define __SIM_PORT_HH__ 5213771Sgabeblack@google.com 5313771Sgabeblack@google.com#include <string> 5413771Sgabeblack@google.com 5513771Sgabeblack@google.com#include "base/types.hh" 5613771Sgabeblack@google.com 5713771Sgabeblack@google.com/** 5813771Sgabeblack@google.com * Ports are used to interface objects to each other. 5913771Sgabeblack@google.com */ 6013771Sgabeblack@google.comclass Port 6113771Sgabeblack@google.com{ 6213771Sgabeblack@google.com 6313771Sgabeblack@google.com private: 6413771Sgabeblack@google.com 6513771Sgabeblack@google.com /** Descriptive name (for DPRINTF output) */ 6613782Sgabeblack@google.com const std::string portName; 6713771Sgabeblack@google.com 6813771Sgabeblack@google.com protected: 6913771Sgabeblack@google.com 7013771Sgabeblack@google.com /** 7113771Sgabeblack@google.com * A numeric identifier to distinguish ports in a vector, and set 7213771Sgabeblack@google.com * to InvalidPortID in case this port is not part of a vector. 7313771Sgabeblack@google.com */ 7413771Sgabeblack@google.com const PortID id; 7513782Sgabeblack@google.com /** 7613782Sgabeblack@google.com * Whether this port is currently connected to a peer port. 7713782Sgabeblack@google.com */ 7813782Sgabeblack@google.com bool _connected; 7913771Sgabeblack@google.com 8013771Sgabeblack@google.com /** 8113771Sgabeblack@google.com * Abstract base class for ports 8213771Sgabeblack@google.com * 8313771Sgabeblack@google.com * @param _name Port name including the owners name 8413771Sgabeblack@google.com * @param _id A port identifier for vector ports 8513771Sgabeblack@google.com */ 8613771Sgabeblack@google.com Port(const std::string& _name, PortID _id); 8713771Sgabeblack@google.com 8813771Sgabeblack@google.com /** 8913771Sgabeblack@google.com * Virtual destructor due to inheritance. 9013771Sgabeblack@google.com */ 9113771Sgabeblack@google.com virtual ~Port(); 9213771Sgabeblack@google.com 9313771Sgabeblack@google.com public: 9413771Sgabeblack@google.com 9513771Sgabeblack@google.com /** Return port name (for DPRINTF). */ 9613771Sgabeblack@google.com const std::string name() const { return portName; } 9713771Sgabeblack@google.com 9813771Sgabeblack@google.com /** Get the port id. */ 9913771Sgabeblack@google.com PortID getId() const { return id; } 10013771Sgabeblack@google.com 10113782Sgabeblack@google.com /** Attach to a peer port. */ 10213782Sgabeblack@google.com virtual void bind(Port &peer) = 0; 10313782Sgabeblack@google.com 10413782Sgabeblack@google.com /** Dettach from a peer port. */ 10513782Sgabeblack@google.com virtual void unbind() = 0; 10613782Sgabeblack@google.com 10713782Sgabeblack@google.com /** Is this port currently connected to a peer? */ 10813782Sgabeblack@google.com bool isConnected() const { return _connected; } 10913771Sgabeblack@google.com}; 11013771Sgabeblack@google.com 11113771Sgabeblack@google.com#endif //__SIM_PORT_HH__ 112