event.cc (12957:e54f9890363d) | event.cc (12962:004cc9133bd6) |
---|---|
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 --- 29 unchanged lines hidden (view full) --- 38#include "systemc/core/scheduler.hh" 39 40namespace sc_gem5 41{ 42 43Event::Event(sc_core::sc_event *_sc_event) : Event(_sc_event, "") {} 44 45Event::Event(sc_core::sc_event *_sc_event, const char *_basename) : | 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 --- 29 unchanged lines hidden (view full) --- 38#include "systemc/core/scheduler.hh" 39 40namespace sc_gem5 41{ 42 43Event::Event(sc_core::sc_event *_sc_event) : Event(_sc_event, "") {} 44 45Event::Event(sc_core::sc_event *_sc_event, const char *_basename) : |
46 _sc_event(_sc_event), _basename(_basename), delayedNotify(this) | 46 _sc_event(_sc_event), _basename(_basename), delayedNotifyEvent(this) |
47{ 48 Module *p = currentModule(); 49 50 if (p) 51 parent = p->obj()->sc_obj(); 52 else if (scheduler.current()) 53 parent = scheduler.current(); 54 --- 61 unchanged lines hidden (view full) --- 116Event::notify() 117{ 118 auto local_sensitivities = sensitivities; 119 for (auto s: local_sensitivities) 120 s->notify(this); 121} 122 123void | 47{ 48 Module *p = currentModule(); 49 50 if (p) 51 parent = p->obj()->sc_obj(); 52 else if (scheduler.current()) 53 parent = scheduler.current(); 54 --- 61 unchanged lines hidden (view full) --- 116Event::notify() 117{ 118 auto local_sensitivities = sensitivities; 119 for (auto s: local_sensitivities) 120 s->notify(this); 121} 122 123void |
124Event::delayedNotify() 125{ 126 scheduler.eventHappened(); 127 notify(); 128} 129 130void |
|
124Event::notify(const sc_core::sc_time &t) 125{ 126 //XXX We're assuming the systemc time resolution is in ps. | 131Event::notify(const sc_core::sc_time &t) 132{ 133 //XXX We're assuming the systemc time resolution is in ps. |
127 Tick new_tick = t.value() * SimClock::Int::ps + 128 scheduler.eventQueue().getCurTick(); 129 if (delayedNotify.scheduled()) { 130 Tick old_tick = delayedNotify.when(); | 134 Tick new_tick = t.value() * SimClock::Int::ps + scheduler.getCurTick(); 135 if (delayedNotifyEvent.scheduled()) { 136 Tick old_tick = delayedNotifyEvent.when(); |
131 132 if (new_tick >= old_tick) 133 return; 134 | 137 138 if (new_tick >= old_tick) 139 return; 140 |
135 scheduler.eventQueue().deschedule(&delayedNotify); | 141 scheduler.deschedule(&delayedNotifyEvent); |
136 } 137 | 142 } 143 |
138 scheduler.eventQueue().schedule(&delayedNotify, new_tick); | 144 scheduler.schedule(&delayedNotifyEvent, new_tick); |
139} 140 141void 142Event::cancel() 143{ | 145} 146 147void 148Event::cancel() 149{ |
144 if (delayedNotify.scheduled()) 145 scheduler.eventQueue().deschedule(&delayedNotify); | 150 if (delayedNotifyEvent.scheduled()) 151 scheduler.deschedule(&delayedNotifyEvent); |
146} 147 148bool 149Event::triggered() const 150{ 151 return false; 152} 153 --- 15 unchanged lines hidden --- | 152} 153 154bool 155Event::triggered() const 156{ 157 return false; 158} 159 --- 15 unchanged lines hidden --- |