-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTimer.py
executable file
·39 lines (28 loc) · 925 Bytes
/
Timer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
class Timer:
def __init__(self, count=100,step=1,cycles=0,stop=False):
self.count = count
self.current_cnt=0
self.step = step
self.cpu_cycles=cycles
self.stop=False #decrements count by step value
#Set the timer to count value, passed by from the simulator
def setTimer(self, count):
self.count=count
def get_CPUTime(self):
return self.current_cnt
def get_CPUCycles(self):
return self.cpu_cycles
#Starts decrementing the count value by step.
async def start_Timer(self):
cnt=self.count
if self.stop==True:
self.stop=False
while not self.stop :
if cnt == 0:
self.cpu_cycles=self.cpu_cycles+1
cnt=self.count
else:
cnt=cnt-self.step
self.current_cnt=cnt
def stop_Timer(self):
self.stop=True