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 * Authors: Gabe Black 28 */ 29 30#ifndef __SYSTEMC_EXT_CHANNEL_SC_SIGNAL_HH__ 31#define __SYSTEMC_EXT_CHANNEL_SC_SIGNAL_HH__ 32 33#include <iostream> 34#include <string> 35#include <vector> 36
| 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 * Authors: Gabe Black 28 */ 29 30#ifndef __SYSTEMC_EXT_CHANNEL_SC_SIGNAL_HH__ 31#define __SYSTEMC_EXT_CHANNEL_SC_SIGNAL_HH__ 32 33#include <iostream> 34#include <string> 35#include <vector> 36
|
| 37#include "../core/sc_event.hh"
|
37#include "../core/sc_module.hh" // for sc_gen_unique_name 38#include "../core/sc_prim.hh"
| 38#include "../core/sc_module.hh" // for sc_gen_unique_name 39#include "../core/sc_prim.hh"
|
| 40#include "../dt/bit/sc_logic.hh"
|
39#include "sc_signal_inout_if.hh" 40#include "warn_unimpl.hh" // for warn_unimpl 41 42namespace sc_core 43{ 44 45class sc_port_base; 46class sc_trace_file; 47 48// Nonstandard 49// Despite having a warning "FOR INTERNAL USE ONLY!" in all caps above this 50// class definition in the Accellera implementation, it appears in their 51// examples and test programs, and so we need to have it here as well. 52struct sc_trace_params 53{ 54 sc_trace_file *tf; 55 std::string name; 56 57 sc_trace_params(sc_trace_file *tf, const std::string &name) : 58 tf(tf), name(name) 59 {} 60}; 61typedef std::vector<sc_trace_params *> sc_trace_params_vec; 62 63template <class T, sc_writer_policy WRITER_POLICY=SC_ONE_WRITER> 64class sc_signal : public sc_signal_inout_if<T>, 65 public sc_prim_channel 66{ 67 public: 68 sc_signal() : sc_signal_inout_if<T>(),
| 41#include "sc_signal_inout_if.hh" 42#include "warn_unimpl.hh" // for warn_unimpl 43 44namespace sc_core 45{ 46 47class sc_port_base; 48class sc_trace_file; 49 50// Nonstandard 51// Despite having a warning "FOR INTERNAL USE ONLY!" in all caps above this 52// class definition in the Accellera implementation, it appears in their 53// examples and test programs, and so we need to have it here as well. 54struct sc_trace_params 55{ 56 sc_trace_file *tf; 57 std::string name; 58 59 sc_trace_params(sc_trace_file *tf, const std::string &name) : 60 tf(tf), name(name) 61 {} 62}; 63typedef std::vector<sc_trace_params *> sc_trace_params_vec; 64 65template <class T, sc_writer_policy WRITER_POLICY=SC_ONE_WRITER> 66class sc_signal : public sc_signal_inout_if<T>, 67 public sc_prim_channel 68{ 69 public: 70 sc_signal() : sc_signal_inout_if<T>(),
|
69 sc_prim_channel(sc_gen_unique_name("signal"))
| 71 sc_prim_channel(sc_gen_unique_name("signal")), 72 m_cur_val(T()), m_new_val(T())
|
70 {}
| 73 {}
|
71 explicit sc_signal(const char *name) : sc_signal_inout_if<T>(), 72 sc_prim_channel(name)
| 74 explicit sc_signal(const char *name) : 75 sc_signal_inout_if<T>(), sc_prim_channel(name), 76 m_cur_val(T()), m_new_val(T())
|
73 {} 74 explicit sc_signal(const char *name, const T &initial_value) :
| 77 {} 78 explicit sc_signal(const char *name, const T &initial_value) :
|
75 sc_signal_inout_if(), sc_prim_channel(name) 76 { 77 // Need to consume initial_value. 78 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 79 }
| 79 sc_signal_inout_if<T>(), sc_prim_channel(name), 80 m_cur_val(initial_value), m_new_val(initial_value) 81 {}
|
80 virtual ~sc_signal() {} 81 82 virtual void 83 register_port(sc_port_base &, const char *) 84 { 85 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 86 } 87
| 82 virtual ~sc_signal() {} 83 84 virtual void 85 register_port(sc_port_base &, const char *) 86 { 87 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 88 } 89
|
88 virtual const T& 89 read() const 90 { 91 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 92 return *(const T *)nullptr; 93 } 94 operator const T&() const 95 { 96 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 97 return *(const T *)nullptr; 98 }
| 90 virtual const T &read() const { return m_cur_val; } 91 operator const T&() const { return read(); }
|
99 100 virtual sc_writer_policy 101 get_writer_policy() const 102 { 103 return WRITER_POLICY; 104 } 105 virtual void
| 92 93 virtual sc_writer_policy 94 get_writer_policy() const 95 { 96 return WRITER_POLICY; 97 } 98 virtual void
|
106 write(const T&)
| 99 write(const T &t)
|
107 {
| 100 {
|
108 sc_channel_warn_unimpl(__PRETTY_FUNCTION__);
| 101 m_new_val = t; 102 bool changed = !(m_cur_val == m_new_val); 103 //TODO check whether this write follows the write policy. 104 if (changed) 105 request_update();
|
109 } 110 sc_signal<T, WRITER_POLICY> &
| 106 } 107 sc_signal<T, WRITER_POLICY> &
|
111 operator = (const T&)
| 108 operator = (const T &t)
|
112 {
| 109 {
|
113 sc_channel_warn_unimpl(__PRETTY_FUNCTION__);
| 110 write(t);
|
114 return *this; 115 } 116 sc_signal<T, WRITER_POLICY> &
| 111 return *this; 112 } 113 sc_signal<T, WRITER_POLICY> &
|
117 operator = (const sc_signal &)
| 114 operator = (const sc_signal<T, WRITER_POLICY> &s)
|
118 {
| 115 {
|
119 sc_channel_warn_unimpl(__PRETTY_FUNCTION__);
| 116 write(s.read());
|
120 return *this; 121 } 122 123 virtual const sc_event & 124 default_event() const 125 {
| 117 return *this; 118 } 119 120 virtual const sc_event & 121 default_event() const 122 {
|
126 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 127 return *(sc_event *)nullptr;
| 123 return value_changed_event();
|
128 } 129 virtual const sc_event & 130 value_changed_event() const 131 {
| 124 } 125 virtual const sc_event & 126 value_changed_event() const 127 {
|
132 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 133 return *(sc_event *)nullptr;
| 128 return _valueChangedEvent;
|
134 } 135 virtual bool 136 event() const 137 { 138 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 139 return false; 140 } 141
| 129 } 130 virtual bool 131 event() const 132 { 133 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 134 return false; 135 } 136
|
| 137 virtual void print(std::ostream &os=std::cout) const { os << m_cur_val; }
|
142 virtual void
| 138 virtual void
|
143 print(std::ostream & =std::cout) const
| 139 dump(std::ostream &os=std::cout) const
|
144 {
| 140 {
|
145 sc_channel_warn_unimpl(__PRETTY_FUNCTION__);
| 141 os << " name = " << name() << ::std::endl; 142 os << " value = " << m_cur_val << ::std::endl; 143 os << "new value = " << m_new_val << ::std::endl;
|
146 }
| 144 }
|
147 virtual void 148 dump(std::ostream & =std::cout) const 149 { 150 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 151 }
| |
152 virtual const char *kind() const { return "sc_signal"; } 153 154 protected: 155 virtual void 156 update() 157 {
| 145 virtual const char *kind() const { return "sc_signal"; } 146 147 protected: 148 virtual void 149 update() 150 {
|
158 sc_channel_warn_unimpl(__PRETTY_FUNCTION__);
| 151 if (m_new_val == m_cur_val) 152 return; 153 154 m_cur_val = m_new_val; 155 _valueChangedEvent.notify(SC_ZERO_TIME);
|
159 } 160 161 // These members which store the current and future value of the signal 162 // are not specified in the standard but are referred to directly by one 163 // of the tests. 164 T m_cur_val; 165 T m_new_val; 166 167 private:
| 156 } 157 158 // These members which store the current and future value of the signal 159 // are not specified in the standard but are referred to directly by one 160 // of the tests. 161 T m_cur_val; 162 T m_new_val; 163 164 private:
|
| 165 sc_event _valueChangedEvent; 166
|
168 // Disabled 169 sc_signal(const sc_signal<T, WRITER_POLICY> &) : 170 sc_signal_inout_if<T>(), sc_prim_channel("") 171 {} 172}; 173 174template <class T, sc_writer_policy WRITER_POLICY> 175inline std::ostream & 176operator << (std::ostream &os, const sc_signal<T, WRITER_POLICY> &) 177{ 178 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 179 return os; 180} 181 182template <sc_writer_policy WRITER_POLICY> 183class sc_signal<bool, WRITER_POLICY> : 184 public sc_signal_inout_if<bool>, public sc_prim_channel 185{ 186 public:
| 167 // Disabled 168 sc_signal(const sc_signal<T, WRITER_POLICY> &) : 169 sc_signal_inout_if<T>(), sc_prim_channel("") 170 {} 171}; 172 173template <class T, sc_writer_policy WRITER_POLICY> 174inline std::ostream & 175operator << (std::ostream &os, const sc_signal<T, WRITER_POLICY> &) 176{ 177 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 178 return os; 179} 180 181template <sc_writer_policy WRITER_POLICY> 182class sc_signal<bool, WRITER_POLICY> : 183 public sc_signal_inout_if<bool>, public sc_prim_channel 184{ 185 public:
|
187 sc_signal() 188 { 189 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 190 } 191 explicit sc_signal(const char *) 192 { 193 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 194 }
| 186 sc_signal() : sc_signal_inout_if<bool>(), 187 sc_prim_channel(sc_gen_unique_name("signal")), 188 m_cur_val(bool()), m_new_val(bool()) 189 {} 190 explicit sc_signal(const char *name) : 191 sc_signal_inout_if<bool>(), sc_prim_channel(name), 192 m_cur_val(bool()), m_new_val(bool()) 193 {}
|
195 explicit sc_signal(const char *name, const bool &initial_value) :
| 194 explicit sc_signal(const char *name, const bool &initial_value) :
|
196 sc_signal_inout_if(), sc_prim_channel(name) 197 { 198 // Need to consume initial_value. 199 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 200 } 201 virtual ~sc_signal() 202 { 203 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 204 }
| 195 sc_signal_inout_if<bool>(), sc_prim_channel(name), 196 m_cur_val(initial_value), m_new_val(initial_value) 197 {} 198 virtual ~sc_signal() {}
|
205 206 virtual void 207 register_port(sc_port_base &, const char *) 208 { 209 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 210 } 211
| 199 200 virtual void 201 register_port(sc_port_base &, const char *) 202 { 203 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 204 } 205
|
212 virtual const bool & 213 read() const 214 { 215 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 216 return *(const bool *)nullptr; 217 } 218 operator const bool &() const 219 { 220 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 221 return *(const bool *)nullptr; 222 }
| 206 virtual const bool &read() const { return m_cur_val; } 207 operator const bool &() const { return read(); }
|
223 224 virtual sc_writer_policy 225 get_writer_policy() const 226 { 227 return WRITER_POLICY; 228 } 229 virtual void
| 208 209 virtual sc_writer_policy 210 get_writer_policy() const 211 { 212 return WRITER_POLICY; 213 } 214 virtual void
|
230 write(const bool &)
| 215 write(const bool &b)
|
231 {
| 216 {
|
232 sc_channel_warn_unimpl(__PRETTY_FUNCTION__);
| 217 m_new_val = b; 218 bool changed = !(m_cur_val == m_new_val); 219 //TODO check whether this write follows the write policy. 220 if (changed) 221 request_update();
|
233 } 234 sc_signal<bool, WRITER_POLICY> &
| 222 } 223 sc_signal<bool, WRITER_POLICY> &
|
235 operator = (const bool &)
| 224 operator = (const bool &b)
|
236 {
| 225 {
|
237 sc_channel_warn_unimpl(__PRETTY_FUNCTION__);
| 226 write(b);
|
238 return *this; 239 } 240 sc_signal<bool, WRITER_POLICY> &
| 227 return *this; 228 } 229 sc_signal<bool, WRITER_POLICY> &
|
241 operator = (const sc_signal &)
| 230 operator = (const sc_signal<bool, WRITER_POLICY> &s)
|
242 {
| 231 {
|
243 sc_channel_warn_unimpl(__PRETTY_FUNCTION__);
| 232 write(s.read());
|
244 return *this; 245 } 246 247 virtual const sc_event & 248 default_event() const 249 {
| 233 return *this; 234 } 235 236 virtual const sc_event & 237 default_event() const 238 {
|
250 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 251 return *(sc_event *)nullptr;
| 239 return value_changed_event();
|
252 } 253 254 virtual const sc_event & 255 value_changed_event() const 256 {
| 240 } 241 242 virtual const sc_event & 243 value_changed_event() const 244 {
|
257 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 258 return *(sc_event *)nullptr;
| 245 return _valueChangedEvent;
|
259 } 260 virtual const sc_event & 261 posedge_event() const 262 {
| 246 } 247 virtual const sc_event & 248 posedge_event() const 249 {
|
263 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 264 return *(sc_event *)nullptr;
| 250 return _posedgeEvent;
|
265 } 266 virtual const sc_event & 267 negedge_event() const 268 {
| 251 } 252 virtual const sc_event & 253 negedge_event() const 254 {
|
269 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 270 return *(sc_event *)nullptr;
| 255 return _negedgeEvent;
|
271 } 272 273 virtual bool 274 event() const 275 { 276 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 277 return false; 278 } 279 virtual bool 280 posedge() const 281 { 282 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 283 return false; 284 } 285 virtual bool 286 negedge() const 287 { 288 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 289 return false; 290 } 291
| 256 } 257 258 virtual bool 259 event() const 260 { 261 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 262 return false; 263 } 264 virtual bool 265 posedge() const 266 { 267 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 268 return false; 269 } 270 virtual bool 271 negedge() const 272 { 273 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 274 return false; 275 } 276
|
| 277 virtual void print(std::ostream &os=std::cout) const { os << m_cur_val; }
|
292 virtual void
| 278 virtual void
|
293 print(std::ostream & =std::cout) const
| 279 dump(std::ostream &os=std::cout) const
|
294 {
| 280 {
|
295 sc_channel_warn_unimpl(__PRETTY_FUNCTION__);
| 281 os << " name = " << name() << ::std::endl; 282 os << " value = " << m_cur_val << ::std::endl; 283 os << "new value = " << m_new_val << ::std::endl;
|
296 }
| 284 }
|
297 virtual void 298 dump(std::ostream & =std::cout) const 299 { 300 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 301 }
| |
302 virtual const char *kind() const { return "sc_signal"; } 303 304 protected: 305 virtual void 306 update() 307 {
| 285 virtual const char *kind() const { return "sc_signal"; } 286 287 protected: 288 virtual void 289 update() 290 {
|
308 sc_channel_warn_unimpl(__PRETTY_FUNCTION__);
| 291 if (m_new_val == m_cur_val) 292 return; 293 294 m_cur_val = m_new_val; 295 _valueChangedEvent.notify(SC_ZERO_TIME); 296 if (m_cur_val) 297 _posedgeEvent.notify(SC_ZERO_TIME); 298 else 299 _negedgeEvent.notify(SC_ZERO_TIME);
|
309 } 310
| 300 } 301
|
| 302 bool m_cur_val; 303 bool m_new_val; 304
|
311 private:
| 305 private:
|
| 306 sc_event _valueChangedEvent; 307 sc_event _posedgeEvent; 308 sc_event _negedgeEvent; 309
|
312 // Disabled 313 sc_signal(const sc_signal<bool, WRITER_POLICY> &) : 314 sc_signal_inout_if<bool>(), sc_prim_channel("") 315 {} 316}; 317 318template <sc_writer_policy WRITER_POLICY> 319class sc_signal<sc_dt::sc_logic, WRITER_POLICY> : 320 public sc_signal_inout_if<sc_dt::sc_logic>, public sc_prim_channel 321{ 322 public:
| 310 // Disabled 311 sc_signal(const sc_signal<bool, WRITER_POLICY> &) : 312 sc_signal_inout_if<bool>(), sc_prim_channel("") 313 {} 314}; 315 316template <sc_writer_policy WRITER_POLICY> 317class sc_signal<sc_dt::sc_logic, WRITER_POLICY> : 318 public sc_signal_inout_if<sc_dt::sc_logic>, public sc_prim_channel 319{ 320 public:
|
323 sc_signal() 324 { 325 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 326 } 327 explicit sc_signal(const char *) 328 { 329 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 330 }
| 321 sc_signal() : sc_signal_inout_if<sc_dt::sc_logic>(), 322 sc_prim_channel(sc_gen_unique_name("signal")), 323 m_cur_val(sc_dt::sc_logic()), m_new_val(sc_dt::sc_logic()) 324 {} 325 explicit sc_signal(const char *name) : 326 sc_signal_inout_if<sc_dt::sc_logic>(), sc_prim_channel(name), 327 m_cur_val(sc_dt::sc_logic()), m_new_val(sc_dt::sc_logic()) 328 {}
|
331 explicit sc_signal(const char *name, 332 const sc_dt::sc_logic &initial_value) :
| 329 explicit sc_signal(const char *name, 330 const sc_dt::sc_logic &initial_value) :
|
333 sc_signal_inout_if(), sc_prim_channel(name) 334 { 335 // Need to consume initial_value. 336 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 337 } 338 virtual ~sc_signal() 339 { 340 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 341 }
| 331 sc_signal_inout_if<sc_dt::sc_logic>(), sc_prim_channel(name), 332 m_cur_val(initial_value), m_new_val(initial_value) 333 {} 334 virtual ~sc_signal() {}
|
342 343 virtual void 344 register_port(sc_port_base &, const char *) 345 { 346 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 347 } 348
| 335 336 virtual void 337 register_port(sc_port_base &, const char *) 338 { 339 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 340 } 341
|
349 virtual const sc_dt::sc_logic & 350 read() const 351 { 352 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 353 return *(const sc_dt::sc_logic *)nullptr; 354 } 355 operator const sc_dt::sc_logic &() const 356 { 357 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 358 return *(const sc_dt::sc_logic *)nullptr; 359 }
| 342 virtual const sc_dt::sc_logic &read() const { return m_cur_val; } 343 operator const sc_dt::sc_logic &() const { return read(); }
|
360 361 virtual sc_writer_policy 362 get_writer_policy() const 363 { 364 return WRITER_POLICY; 365 } 366 virtual void
| 344 345 virtual sc_writer_policy 346 get_writer_policy() const 347 { 348 return WRITER_POLICY; 349 } 350 virtual void
|
367 write(const sc_dt::sc_logic &)
| 351 write(const sc_dt::sc_logic &l)
|
368 {
| 352 {
|
369 sc_channel_warn_unimpl(__PRETTY_FUNCTION__);
| 353 m_new_val = l; 354 bool changed = !(m_cur_val == m_new_val); 355 //TODO check whether this write follows the write policy. 356 if (changed) 357 request_update();
|
370 } 371 sc_signal<sc_dt::sc_logic, WRITER_POLICY> &
| 358 } 359 sc_signal<sc_dt::sc_logic, WRITER_POLICY> &
|
372 operator = (const sc_dt::sc_logic &)
| 360 operator = (const sc_dt::sc_logic &l)
|
373 {
| 361 {
|
374 sc_channel_warn_unimpl(__PRETTY_FUNCTION__);
| 362 write(l);
|
375 return *this; 376 } 377 sc_signal<sc_dt::sc_logic, WRITER_POLICY> &
| 363 return *this; 364 } 365 sc_signal<sc_dt::sc_logic, WRITER_POLICY> &
|
378 operator = (const sc_signal &)
| 366 operator = (const sc_signal<sc_dt::sc_logic, WRITER_POLICY> &s)
|
379 {
| 367 {
|
380 sc_channel_warn_unimpl(__PRETTY_FUNCTION__);
| 368 write(s.read());
|
381 return *this; 382 } 383 384 virtual const sc_event & 385 default_event() const 386 {
| 369 return *this; 370 } 371 372 virtual const sc_event & 373 default_event() const 374 {
|
387 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 388 return *(sc_event *)nullptr;
| 375 return value_changed_event();
|
389 } 390 391 virtual const sc_event & 392 value_changed_event() const 393 {
| 376 } 377 378 virtual const sc_event & 379 value_changed_event() const 380 {
|
394 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 395 return *(sc_event *)nullptr;
| 381 return _valueChangedEvent;
|
396 } 397 virtual const sc_event & 398 posedge_event() const 399 {
| 382 } 383 virtual const sc_event & 384 posedge_event() const 385 {
|
400 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 401 return *(sc_event *)nullptr;
| 386 return _posedgeEvent;
|
402 } 403 virtual const sc_event & 404 negedge_event() const 405 {
| 387 } 388 virtual const sc_event & 389 negedge_event() const 390 {
|
406 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 407 return *(sc_event *)nullptr;
| 391 return _negedgeEvent;
|
408 } 409 410 virtual bool 411 event() const 412 { 413 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 414 return false; 415 } 416 virtual bool 417 posedge() const 418 { 419 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 420 return false; 421 } 422 virtual bool 423 negedge() const 424 { 425 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 426 return false; 427 } 428
| 392 } 393 394 virtual bool 395 event() const 396 { 397 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 398 return false; 399 } 400 virtual bool 401 posedge() const 402 { 403 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 404 return false; 405 } 406 virtual bool 407 negedge() const 408 { 409 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 410 return false; 411 } 412
|
| 413 virtual void print(std::ostream &os=std::cout) const { os << m_cur_val; }
|
429 virtual void
| 414 virtual void
|
430 print(std::ostream & =std::cout) const
| 415 dump(std::ostream &os=std::cout) const
|
431 {
| 416 {
|
432 sc_channel_warn_unimpl(__PRETTY_FUNCTION__);
| 417 os << " name = " << name() << ::std::endl; 418 os << " value = " << m_cur_val << ::std::endl; 419 os << "new value = " << m_new_val << ::std::endl;
|
433 }
| 420 }
|
434 virtual void 435 dump(std::ostream & =std::cout) const 436 { 437 sc_channel_warn_unimpl(__PRETTY_FUNCTION__); 438 }
| |
439 virtual const char *kind() const { return "sc_signal"; } 440 441 protected: 442 virtual void 443 update() 444 {
| 421 virtual const char *kind() const { return "sc_signal"; } 422 423 protected: 424 virtual void 425 update() 426 {
|
445 sc_channel_warn_unimpl(__PRETTY_FUNCTION__);
| 427 if (m_new_val == m_cur_val) 428 return; 429 430 m_cur_val = m_new_val; 431 _valueChangedEvent.notify(SC_ZERO_TIME); 432 if (m_cur_val == sc_dt::SC_LOGIC_1) 433 _posedgeEvent.notify(SC_ZERO_TIME); 434 else if (m_cur_val == sc_dt::SC_LOGIC_0) 435 _negedgeEvent.notify(SC_ZERO_TIME);
|
446 } 447
| 436 } 437
|
| 438 sc_dt::sc_logic m_cur_val; 439 sc_dt::sc_logic m_new_val; 440
|
448 private:
| 441 private:
|
| 442 sc_event _valueChangedEvent; 443 sc_event _posedgeEvent; 444 sc_event _negedgeEvent; 445
|
449 // Disabled 450 sc_signal(const sc_signal<sc_dt::sc_logic, WRITER_POLICY> &) : 451 sc_signal_inout_if<sc_dt::sc_logic>(), sc_prim_channel("") 452 {} 453}; 454 455} // namespace sc_core 456 457#endif //__SYSTEMC_EXT_CHANNEL_SC_SIGNAL_HH__
| 446 // Disabled 447 sc_signal(const sc_signal<sc_dt::sc_logic, WRITER_POLICY> &) : 448 sc_signal_inout_if<sc_dt::sc_logic>(), sc_prim_channel("") 449 {} 450}; 451 452} // namespace sc_core 453 454#endif //__SYSTEMC_EXT_CHANNEL_SC_SIGNAL_HH__
|