-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e5c0057
commit 984ee1a
Showing
12 changed files
with
110 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .value import TimeConverter, TimeValue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
''' | ||
Created on Nov 23, 2024 | ||
@author: Pat Deegan | ||
@copyright: Copyright (C) 2024 Pat Deegan, https://psychogenic.com | ||
''' | ||
from ttboard.cocotb.time.value import TimeValue | ||
from ttboard.cocotb.clock import Clock | ||
|
||
class SystemTime: | ||
_global_time = TimeValue(0, 'ns') | ||
|
||
@classmethod | ||
def reset(cls): | ||
cls._global_time = TimeValue(0, 'ns') | ||
|
||
@classmethod | ||
def current(cls) -> TimeValue: | ||
return cls._global_time | ||
|
||
@classmethod | ||
def set_units(cls, units:str): | ||
cls._global_time = TimeValue(cls._global_time.time, units) | ||
|
||
@classmethod | ||
def advance(cls, time_or_timevalue, units:str=None): | ||
if isinstance(time_or_timevalue, TimeValue): | ||
cls._global_time += time_or_timevalue | ||
elif isinstance(time_or_timevalue, int) and units is not None: | ||
cls._global_time += TimeValue(time_or_timevalue, units) | ||
else: | ||
raise ValueError | ||
|
||
for clk in Clock.all(): | ||
clk.time_is_now(cls._global_time) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
|
||
from ttboard.cocotb.time import SystemTime | ||
import math | ||
from ttboard.cocotb.time.system import SystemTime | ||
|
||
def get_sim_time(units:str): | ||
current = SystemTime.current() | ||
return current.time_in(units) | ||
return math.ceil(current.time_in(units)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters