gem5  v21.1.0.2
intpin.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2019 Google, Inc.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met: redistributions of source code must retain the above copyright
7  * notice, this list of conditions and the following disclaimer;
8  * redistributions in binary form must reproduce the above copyright
9  * notice, this list of conditions and the following disclaimer in the
10  * documentation and/or other materials provided with the distribution;
11  * neither the name of the copyright holders nor the names of its
12  * contributors may be used to endorse or promote products derived from
13  * this software without specific prior written permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #ifndef __DEV_INTPIN_HH__
29 #define __DEV_INTPIN_HH__
30 
31 #include "sim/port.hh"
32 
33 namespace gem5
34 {
35 
36 class IntSourcePinBase;
37 
38 class IntSinkPinBase : public Port
39 {
40  protected:
42 
44 
45  int _number = 0;
46  bool _state = false;
47 
48  IntSinkPinBase(const std::string &_name, PortID _id, int num) :
49  Port(_name, _id), _number(num)
50  {}
51 
52  virtual void raiseOnDevice() = 0;
53  virtual void lowerOnDevice() = 0;
54 
55  void
56  raise()
57  {
58  _state = true;
59  raiseOnDevice();
60  }
61 
62  void
64  {
65  _state = false;
66  lowerOnDevice();
67  }
68 
69  public:
70  int number() { return _number; }
71  bool state() { return _state; }
72 
73  void bind(Port &peer) override;
74  void unbind() override;
75 };
76 
77 template <class Device>
78 class IntSinkPin : public IntSinkPinBase
79 {
80  private:
81  Device *device = nullptr;
82 
83  void raiseOnDevice() override { device->raiseInterruptPin(number()); }
84  void lowerOnDevice() override { device->lowerInterruptPin(number()); }
85 
86  public:
87  IntSinkPin(const std::string &_name, PortID _id, Device *dev, int num) :
88  IntSinkPinBase(_name, _id, num), device(dev) {}
89  IntSinkPin(const std::string &_name, PortID _id, Device *dev) :
90  IntSinkPin(_name, _id, dev, _id) {}
91 };
92 
93 class IntSourcePinBase : public Port
94 {
95  private:
96  IntSinkPinBase *sink = nullptr;
97  bool _state = false;
98 
99  public:
100  IntSourcePinBase(const std::string &_name, PortID _id, bool def_state) :
101  Port(_name, _id), _state(def_state)
102  {}
103 
104  void raise() { sink->raise(); }
105  void lower() { sink->lower(); }
106 
107  void bind(Port &peer) override;
108  void unbind() override;
109 };
110 
111 template <class Device>
113 {
114  public:
115  IntSourcePin(const std::string &_name, PortID _id, Device *owner,
116  bool def_state=false) :
117  IntSourcePinBase(_name, _id, def_state)
118  {}
119 };
120 
121 } // namespace gem5
122 
123 #endif //__DEV_INTPIN_HH__
gem5::PortID
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:252
gem5::IntSinkPinBase::lowerOnDevice
virtual void lowerOnDevice()=0
gem5::IntSinkPinBase::_number
int _number
Definition: intpin.hh:45
gem5::IntSinkPinBase::IntSinkPinBase
IntSinkPinBase(const std::string &_name, PortID _id, int num)
Definition: intpin.hh:48
gem5::IntSinkPin::device
Device * device
Definition: intpin.hh:81
gem5::IntSourcePinBase::sink
IntSinkPinBase * sink
Definition: intpin.hh:96
gem5::IntSinkPinBase::state
bool state()
Definition: intpin.hh:71
gem5::IntSinkPin::raiseOnDevice
void raiseOnDevice() override
Definition: intpin.hh:83
gem5::IntSinkPinBase::raise
void raise()
Definition: intpin.hh:56
gem5::IntSinkPinBase::raiseOnDevice
virtual void raiseOnDevice()=0
gem5::IntSourcePinBase::bind
void bind(Port &peer) override
Attach to a peer port.
Definition: intpin.cc:52
gem5::IntSourcePinBase::lower
void lower()
Definition: intpin.hh:105
gem5::IntSinkPinBase::source
IntSourcePinBase * source
Definition: intpin.hh:43
gem5::IntSinkPinBase::bind
void bind(Port &peer) override
Attach to a peer port.
Definition: intpin.cc:36
gem5::IntSourcePinBase::_state
bool _state
Definition: intpin.hh:97
gem5::IntSinkPinBase::IntSourcePinBase
friend IntSourcePinBase
Definition: intpin.hh:41
gem5::IntSourcePinBase
Definition: intpin.hh:93
gem5::IntSinkPinBase::_state
bool _state
Definition: intpin.hh:46
port.hh
gem5::Port
Ports are used to interface objects to each other.
Definition: port.hh:61
gem5::IntSinkPinBase::unbind
void unbind() override
Dettach from a peer port.
Definition: intpin.cc:45
gem5::IntSinkPin
Definition: intpin.hh:78
gem5::IntSourcePinBase::unbind
void unbind() override
Dettach from a peer port.
Definition: intpin.cc:66
gem5::IntSinkPinBase::lower
void lower()
Definition: intpin.hh:63
gem5::IntSinkPin::lowerOnDevice
void lowerOnDevice() override
Definition: intpin.hh:84
gem5::IntSourcePin
Definition: intpin.hh:112
gem5::IntSinkPin::IntSinkPin
IntSinkPin(const std::string &_name, PortID _id, Device *dev, int num)
Definition: intpin.hh:87
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
gem5::IntSourcePin::IntSourcePin
IntSourcePin(const std::string &_name, PortID _id, Device *owner, bool def_state=false)
Definition: intpin.hh:115
gem5::IntSinkPin::IntSinkPin
IntSinkPin(const std::string &_name, PortID _id, Device *dev)
Definition: intpin.hh:89
gem5::IntSinkPinBase::number
int number()
Definition: intpin.hh:70
gem5::IntSourcePinBase::IntSourcePinBase
IntSourcePinBase(const std::string &_name, PortID _id, bool def_state)
Definition: intpin.hh:100
gem5::IntSinkPinBase
Definition: intpin.hh:38

Generated on Tue Sep 21 2021 12:25:15 for gem5 by doxygen 1.8.17