gem5  v20.1.0.0
sc_signal.cc
Go to the documentation of this file.
1 /*
2  * Copyright 2018 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 #include <sstream>
29 
34 
35 namespace sc_gem5
36 {
37 
39  sc_core::sc_prim_channel(name), _changeStamp(~0ULL),
40  _gem5WriterPort(nullptr)
41 {}
42 
44 
45 const sc_core::sc_event &
47 {
48  return valueChangedEvent();
49 }
50 
51 const sc_core::sc_event &
53 {
54  return _valueChangedEvent;
55 }
56 
57 bool
59 {
60  return _changeStamp == getChangeStamp();
61 }
62 
63 void
65 {
68 }
69 
70 void
72 {
75 }
76 
77 void
79 {
82 }
83 
84 namespace
85 {
86 
87 void
88 reportSignalError(ScSignalBase *sig, sc_core::sc_object *first,
89  sc_core::sc_object *second, bool delta_conflict=false)
90 {
91  std::ostringstream ss;
92  ss << "\n signal " << "`" << sig->name() << "' (" << sig->kind() << ")";
93  ss << "\n first driver `" << first->name() << "' (" <<
94  first->kind() << ")";
95  ss << "\n second driver `" << second->name() << "' (" <<
96  second->kind() << ")";
97  if (delta_conflict) {
98  ss << "\n conflicting write in delta cycle " <<
100  }
102  ss.str().c_str());
103 }
104 
105 } // anonymous namespace
106 
108  sig(_sig), firstPort(nullptr), proc(nullptr), writeStamp(~0ULL)
109 {}
110 
111 void
113  std::string iface_type_name, std::string out_name)
114 {
115  if (iface_type_name == out_name) {
116  if (firstPort)
117  reportSignalError(sig, firstPort, &port);
118  firstPort = &port;
119  }
120 }
121 
122 void
124 {
125  Process *p = scheduler.current();
126  if (!p)
127  return;
128  uint64_t stamp = getChangeStamp();
129  if (proc && proc != p)
130  reportSignalError(sig, proc, p);
131  proc = p;
132  writeStamp = stamp;
133 }
134 
136  sig(_sig), proc(nullptr), writeStamp(~0ULL)
137 {}
138 
139 void
141  std::string iface_type_name, std::string out_name)
142 {
143  return;
144 }
145 
146 void
148 {
149  Process *p = scheduler.current();
150  if (!p)
151  return;
152  uint64_t stamp = getChangeStamp();
153  if (writeStamp == stamp && proc && proc != p)
154  reportSignalError(sig, proc, p, writeStamp == stamp);
155  proc = p;
156  writeStamp = stamp;
157 }
158 
160  ScSignalBase(_name), _posStamp(~0ULL), _negStamp(~0ULL)
161 {}
162 
163 const sc_core::sc_event &
165 {
166  return _posedgeEvent;
167 }
168 
169 const sc_core::sc_event &
171 {
172  return _negedgeEvent;
173 }
174 
175 bool
177 {
178  return _posStamp == getChangeStamp();
179 }
180 
181 bool
183 {
184  return _negStamp == getChangeStamp();
185 }
186 
187 void
189 {
190  r->update();
191 }
192 
193 void
195 {
196  for (auto r: _resets)
197  _signalReset(r);
198 }
199 
200 } // namespace sc_gem5
sc_core::sc_port_base
Definition: sc_port.hh:74
sc_gem5::ScSignalBaseBinary::negedge
bool negedge() const
Definition: sc_signal.cc:182
sc_gem5::ScSignalBase::event
bool event() const
Definition: sc_signal.cc:58
sc_gem5::ScSignalBase::kind
virtual const char * kind() const
Definition: sc_signal.hh:57
sc_gem5::ScSignalBaseBinary::_posedgeEvent
InternalScEvent _posedgeEvent
Definition: sc_signal.hh:92
sc_gem5::ScSignalBaseBinary::ScSignalBaseBinary
ScSignalBaseBinary(const char *_name)
Definition: sc_signal.cc:159
sc_gem5::ScSignalBaseBinary::_signalReset
void _signalReset()
Definition: sc_signal.cc:194
sc_gem5::ScSignalBaseBinary::_signalPosedge
void _signalPosedge()
Definition: sc_signal.cc:71
sc_core
Definition: messages.cc:31
sc_gem5::ScSignalBaseBinary::_negedgeEvent
InternalScEvent _negedgeEvent
Definition: sc_signal.hh:93
sc_gem5::ScSignalBaseBinary::_resets
std::vector< sc_gem5::Reset * > _resets
Definition: sc_signal.hh:82
sc_signal.hh
sc_gem5::ScSignalBase::_changeStamp
uint64_t _changeStamp
Definition: sc_signal.hh:73
sc_core::SC_ZERO_TIME
const sc_time SC_ZERO_TIME
Definition: sc_time.cc:290
messages.hh
sc_core::SC_ID_MORE_THAN_ONE_SIGNAL_DRIVER_
const char SC_ID_MORE_THAN_ONE_SIGNAL_DRIVER_[]
Definition: messages.cc:52
sc_gem5::Reset
Definition: process.hh:206
sc_gem5::ScSignalBaseBinary::negedgeEvent
const sc_core::sc_event & negedgeEvent() const
Definition: sc_signal.cc:170
sc_gem5::getChangeStamp
uint64_t getChangeStamp()
Definition: sc_prim.cc:37
sc_gem5::ScSignalBase::_valueChangedEvent
InternalScEvent _valueChangedEvent
Definition: sc_signal.hh:72
ArmISA::ss
Bitfield< 21 > ss
Definition: miscregs_types.hh:56
SC_REPORT_ERROR
#define SC_REPORT_ERROR(msg_type, msg)
Definition: sc_report_handler.hh:127
sc_gem5::ScSignalBase::defaultEvent
const sc_core::sc_event & defaultEvent() const
Definition: sc_signal.cc:46
sc_core::sc_event
Definition: sc_event.hh:169
sc_main.hh
MipsISA::r
r
Definition: pra_constants.hh:95
sc_gem5::ScSignalBase::~ScSignalBase
virtual ~ScSignalBase()
Definition: sc_signal.cc:43
sc_gem5::ScSignalBase::_signalChange
void _signalChange()
Definition: sc_signal.cc:64
sc_gem5::Process
Definition: process.hh:62
sc_core::sc_object
Definition: sc_object.hh:50
name
const std::string & name()
Definition: trace.cc:50
sc_core::sc_event::notify
void notify()
Definition: sc_event.cc:337
sc_gem5::ScSignalBase
Definition: sc_signal.hh:54
sc_gem5::Scheduler::current
Process * current()
Definition: scheduler.hh:170
sc_core::sc_delta_count
sc_dt::uint64 sc_delta_count()
Definition: sc_main.cc:136
sc_core::sc_object::name
const char * name() const
Definition: sc_object.cc:44
sc_gem5::ScSignalBaseBinary::posedge
bool posedge() const
Definition: sc_signal.cc:176
sc_gem5::ScSignalBaseBinary::posedgeEvent
const sc_core::sc_event & posedgeEvent() const
Definition: sc_signal.cc:164
sc_gem5
Definition: sc_clock.cc:42
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
sc_core::sc_object::kind
virtual const char * kind() const
Definition: sc_object.hh:56
sc_gem5::scheduler
Scheduler scheduler
Definition: scheduler.cc:489
sc_gem5::ScSignalBaseBinary::_negStamp
uint64_t _negStamp
Definition: sc_signal.hh:96
sc_gem5::ScSignalBaseBinary::_posStamp
uint64_t _posStamp
Definition: sc_signal.hh:95
sc_gem5::WriteChecker
Definition: sc_signal.hh:124
sc_gem5::ScSignalBaseBinary::_signalNegedge
void _signalNegedge()
Definition: sc_signal.cc:78
scheduler.hh
ULL
#define ULL(N)
uint64_t constant
Definition: types.hh:50
sc_gem5::ScSignalBase::ScSignalBase
ScSignalBase(const char *_name)
Definition: sc_signal.cc:38
sc_gem5::ScSignalBase::valueChangedEvent
const sc_core::sc_event & valueChangedEvent() const
Definition: sc_signal.cc:52

Generated on Wed Sep 30 2020 14:02:14 for gem5 by doxygen 1.8.17