port.hh revision 13771
17019SBrad.Beckmann@amd.com/*
27019SBrad.Beckmann@amd.com * Copyright (c) 2011-2012,2015,2017 ARM Limited
37019SBrad.Beckmann@amd.com * All rights reserved
47019SBrad.Beckmann@amd.com *
57019SBrad.Beckmann@amd.com * The license below extends only to copyright in the software and shall
67019SBrad.Beckmann@amd.com * not be construed as granting a license to any other intellectual
77019SBrad.Beckmann@amd.com * property including but not limited to intellectual property relating
87019SBrad.Beckmann@amd.com * to a hardware implementation of the functionality of the software
97019SBrad.Beckmann@amd.com * licensed hereunder.  You may use the software subject to the license
107019SBrad.Beckmann@amd.com * terms below provided that you ensure that this notice is replicated
117019SBrad.Beckmann@amd.com * unmodified and in its entirety in all distributions of the software,
127019SBrad.Beckmann@amd.com * modified or unmodified, in source code or in binary form.
137019SBrad.Beckmann@amd.com *
147019SBrad.Beckmann@amd.com * Copyright (c) 2002-2005 The Regents of The University of Michigan
157019SBrad.Beckmann@amd.com * All rights reserved.
167019SBrad.Beckmann@amd.com *
177019SBrad.Beckmann@amd.com * Redistribution and use in source and binary forms, with or without
187019SBrad.Beckmann@amd.com * modification, are permitted provided that the following conditions are
197019SBrad.Beckmann@amd.com * met: redistributions of source code must retain the above copyright
207019SBrad.Beckmann@amd.com * notice, this list of conditions and the following disclaimer;
217019SBrad.Beckmann@amd.com * redistributions in binary form must reproduce the above copyright
227019SBrad.Beckmann@amd.com * notice, this list of conditions and the following disclaimer in the
237019SBrad.Beckmann@amd.com * documentation and/or other materials provided with the distribution;
247019SBrad.Beckmann@amd.com * neither the name of the copyright holders nor the names of its
257019SBrad.Beckmann@amd.com * contributors may be used to endorse or promote products derived from
267019SBrad.Beckmann@amd.com * this software without specific prior written permission.
277019SBrad.Beckmann@amd.com *
287019SBrad.Beckmann@amd.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
297019SBrad.Beckmann@amd.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
306876Ssteve.reinhardt@amd.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
319206Snilay@cs.wisc.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
3210525Snilay@cs.wisc.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
336876Ssteve.reinhardt@amd.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
349206Snilay@cs.wisc.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
356876Ssteve.reinhardt@amd.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3611108Sdavid.hashe@amd.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
376876Ssteve.reinhardt@amd.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
386876Ssteve.reinhardt@amd.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
399504Snilay@cs.wisc.edu *
406876Ssteve.reinhardt@amd.com * Authors: Ron Dreslinski
4110524Snilay@cs.wisc.edu *          Andreas Hansson
4210524Snilay@cs.wisc.edu *          William Wang
4310012Snilay@cs.wisc.edu */
4411172Snilay@cs.wisc.edu
4511172Snilay@cs.wisc.edu/**
4611172Snilay@cs.wisc.edu * @file
4711172Snilay@cs.wisc.edu * Port Object Declaration.
4811172Snilay@cs.wisc.edu */
4911049Snilay@cs.wisc.edu
5011049Snilay@cs.wisc.edu#ifndef __SIM_PORT_HH__
5111049Snilay@cs.wisc.edu#define __SIM_PORT_HH__
5211049Snilay@cs.wisc.edu
5311172Snilay@cs.wisc.edu#include <string>
54
55#include "base/types.hh"
56
57/**
58 * Ports are used to interface objects to each other.
59 */
60class Port
61{
62
63  private:
64
65    /** Descriptive name (for DPRINTF output) */
66    std::string portName;
67
68  protected:
69
70    /**
71     * A numeric identifier to distinguish ports in a vector, and set
72     * to InvalidPortID in case this port is not part of a vector.
73     */
74    const PortID id;
75
76    /**
77     * Abstract base class for ports
78     *
79     * @param _name Port name including the owners name
80     * @param _id A port identifier for vector ports
81     */
82    Port(const std::string& _name, PortID _id);
83
84    /**
85     * Virtual destructor due to inheritance.
86     */
87    virtual ~Port();
88
89  public:
90
91    /** Return port name (for DPRINTF). */
92    const std::string name() const { return portName; }
93
94    /** Get the port id. */
95    PortID getId() const { return id; }
96
97};
98
99#endif //__SIM_PORT_HH__
100