simulavr
1.1.0
|
Class to store and manage the central simulation time. More...
#include <systemclock.h>
Public Member Functions | |
SystemClockOffset | GetCurrentTime () const |
Returns the current simulation time. More... | |
void | SetCurrentTime (SystemClockOffset of) |
Set the simulation time to a dedicated value. More... | |
void | IncrTime (SystemClockOffset of) |
Increments the current simulation time with a offset. More... | |
void | Add (SimulationMember *dev) |
Add a simulation member (normally a device) More... | |
void | AddAsyncMember (SimulationMember *dev) |
Add a async simulation member, this will be called every simulation step. More... | |
int | Step (bool &untilCoreStepFinished) |
Process one simulation step. More... | |
long | Endless () |
Run simulation endless till SIGINT or SIGTERM signal, return the number of CPU cycles. More... | |
long | Run (SystemClockOffset maxRunTime) |
Run simulation till given time is arrived or signal is cached. More... | |
long | RunTimeRange (SystemClockOffset timeRange) |
Like Run method, but stops on breakpoint or after given time offset. More... | |
void | Reschedule (SimulationMember *sm, SystemClockOffset newTime) |
Moves the given simulation member to a new place in time table. More... | |
void | SetTraceModeForAllMembers (int trace_on) |
Switches trace mode for all current found simulation members. More... | |
void | Stop () |
Stop Run/Endless or Step asynchronously. More... | |
void | ResetClock (void) |
Resets the simulation time and clears table for simulation members and async simulation members. More... | |
Static Public Member Functions | |
static SystemClock & | Instance () |
Returns the central SystemClock instance for the application. More... | |
Protected Attributes | |
SystemClockOffset | currentTime |
time in [ns] since start of simulation More... | |
MinHeap< SystemClockOffset, SimulationMember * > | syncMembers |
earliest first More... | |
std::vector< SimulationMember * > | asyncMembers |
List of asynchron working simulation members, will be called every step! More... | |
Private Member Functions | |
SystemClock () | |
Do not this constructor from application code! More... | |
SystemClock (const SystemClock &) | |
Do not this constructor from application code! More... | |
Class to store and manage the central simulation time.
This acts as a time table, a simulation member gets a place on this ordered table, where it should be called next time, the placement depends on the results of Step method call Step on this simulation member.
Definition at line 82 of file systemclock.h.
|
private |
Do not this constructor from application code!
Definition at line 111 of file systemclock.cpp.
References avr_error.
|
private |
Do not this constructor from application code!
void SystemClock::Add | ( | SimulationMember * | dev | ) |
Add a simulation member (normally a device)
Definition at line 129 of file systemclock.cpp.
Referenced by HWUSI::doCount(), HWUSI::PinStateHasChanged(), and HWTimerTinyX5::SetPrescalerClock().
void SystemClock::AddAsyncMember | ( | SimulationMember * | dev | ) |
Add a async simulation member, this will be called every simulation step.
Definition at line 133 of file systemclock.cpp.
long SystemClock::Endless | ( | ) |
Run simulation endless till SIGINT or SIGTERM signal, return the number of CPU cycles.
Definition at line 215 of file systemclock.cpp.
References breakMessage, and OnBreak().
|
inline |
Returns the current simulation time.
Definition at line 95 of file systemclock.h.
Referenced by HWIrqSystem::ClearIrqFlag(), HWWado::CpuCycle(), DumpVCD::cycle(), HWIrqSystem::IrqHandlerFinished(), HWIrqSystem::IrqHandlerStarted(), WarnUnknown::markReadUnknown(), RunTimeRange(), HWTimerTinyX5::set_from_reg(), HWEeprom::SetEecr(), HWIrqSystem::SetIrqFlag(), FlashProgramming::SPM_action(), DumpVCD::stop(), and HWWado::Wdr().
|
inline |
Increments the current simulation time with a offset.
Attention! Use this method with care, if you don't want crazy results
Definition at line 101 of file systemclock.h.
|
static |
Returns the central SystemClock instance for the application.
There will be only one instance on a application!
Definition at line 271 of file systemclock.cpp.
Referenced by avr_set_time_tf(), HWIrqSystem::ClearIrqFlag(), HWWado::CpuCycle(), HWEeprom::CpuCycle(), FlashProgramming::CpuCycle(), HWTimerTinyX5::CpuCycle(), DumpVCD::cycle(), HWUSI::doCount(), HWIrqSystem::IrqHandlerFinished(), HWIrqSystem::IrqHandlerStarted(), WarnUnknown::markReadUnknown(), HWUSI::PinStateHasChanged(), Run(), RunTimeRange(), HWTimerTinyX5::set_from_reg(), HWEeprom::SetEecr(), HWIrqSystem::SetIrqFlag(), HWTimerTinyX5::SetPrescalerClock(), FlashProgramming::SPM_action(), AvrDevice::Step(), DumpVCD::stop(), and HWWado::Wdr().
void SystemClock::Reschedule | ( | SimulationMember * | sm, |
SystemClockOffset | newTime | ||
) |
Moves the given simulation member to a new place in time table.
The next time, simulation member will be called, is calculated as a given offset to current simulation time + 1.
Definition at line 186 of file systemclock.cpp.
void SystemClock::ResetClock | ( | void | ) |
Resets the simulation time and clears table for simulation members and async simulation members.
Definition at line 208 of file systemclock.cpp.
References breakMessage.
long SystemClock::Run | ( | SystemClockOffset | maxRunTime | ) |
Run simulation till given time is arrived or signal is cached.
Definition at line 232 of file systemclock.cpp.
References breakMessage, Instance(), and OnBreak().
long SystemClock::RunTimeRange | ( | SystemClockOffset | timeRange | ) |
Like Run method, but stops on breakpoint or after given time offset.
Definition at line 251 of file systemclock.cpp.
References breakMessage, GetCurrentTime(), Instance(), and OnBreak().
|
inline |
Set the simulation time to a dedicated value.
Attention! Use this method with care, if you don't want crazy results
Definition at line 98 of file systemclock.h.
Referenced by avr_set_time_tf().
void SystemClock::SetTraceModeForAllMembers | ( | int | trace_on | ) |
Switches trace mode for all current found simulation members.
Definition at line 119 of file systemclock.cpp.
References AvrDevice::trace_on.
int SystemClock::Step | ( | bool & | untilCoreStepFinished | ) |
Process one simulation step.
Definition at line 139 of file systemclock.cpp.
References breakMessage, and SimulationMember::Step().
void SystemClock::Stop | ( | ) |
Stop Run/Endless or Step asynchronously.
Definition at line 204 of file systemclock.cpp.
References breakMessage.
Referenced by AvrDevice::Step().
|
protected |
List of asynchron working simulation members, will be called every step!
Definition at line 91 of file systemclock.h.
|
protected |
time in [ns] since start of simulation
Definition at line 89 of file systemclock.h.
|
protected |
earliest first
Definition at line 90 of file systemclock.h.