sim: move Command
from core
to _pycoro
.
Simulator commands are deprecated and will be removed once RFC 36 is implemented and released. They are an artifact of the old API.
This commit is contained in:
parent
78a289e5aa
commit
f637530093
|
@ -1,13 +1,61 @@
|
||||||
import inspect
|
import inspect
|
||||||
|
|
||||||
|
from .._utils import deprecated
|
||||||
from ..hdl import *
|
from ..hdl import *
|
||||||
from ..hdl._ast import Statement, Assign, SignalSet, ValueCastable
|
from ..hdl._ast import Statement, Assign, SignalSet, ValueCastable
|
||||||
from .core import Tick, Settle, Delay, Passive, Active
|
|
||||||
from ._base import BaseProcess, BaseMemoryState
|
from ._base import BaseProcess, BaseMemoryState
|
||||||
from ._pyeval import eval_value, eval_assign
|
from ._pyeval import eval_value, eval_assign
|
||||||
|
|
||||||
|
|
||||||
__all__ = ["PyCoroProcess"]
|
__all__ = ["Command", "Settle", "Delay", "Tick", "Passive", "Active", "PyCoroProcess"]
|
||||||
|
|
||||||
|
|
||||||
|
class Command:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class Settle(Command):
|
||||||
|
@deprecated("The `Settle` command is deprecated per RFC 27. Use `add_testbench` to write "
|
||||||
|
"testbenches; in them, an equivalent of `yield Settle()` is performed "
|
||||||
|
"automatically.")
|
||||||
|
def __init__(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return "(settle)"
|
||||||
|
|
||||||
|
|
||||||
|
class Delay(Command):
|
||||||
|
def __init__(self, interval=None):
|
||||||
|
self.interval = None if interval is None else float(interval)
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
if self.interval is None:
|
||||||
|
return "(delay ε)"
|
||||||
|
else:
|
||||||
|
return f"(delay {self.interval * 1e6:.3}us)"
|
||||||
|
|
||||||
|
|
||||||
|
class Tick(Command):
|
||||||
|
def __init__(self, domain="sync"):
|
||||||
|
if not isinstance(domain, (str, ClockDomain)):
|
||||||
|
raise TypeError("Domain must be a string or a ClockDomain instance, not {!r}"
|
||||||
|
.format(domain))
|
||||||
|
assert domain != "comb"
|
||||||
|
self.domain = domain
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return f"(tick {self.domain})"
|
||||||
|
|
||||||
|
|
||||||
|
class Passive(Command):
|
||||||
|
def __repr__(self):
|
||||||
|
return "(passive)"
|
||||||
|
|
||||||
|
|
||||||
|
class Active(Command):
|
||||||
|
def __repr__(self):
|
||||||
|
return "(active)"
|
||||||
|
|
||||||
|
|
||||||
class PyCoroProcess(BaseProcess):
|
class PyCoroProcess(BaseProcess):
|
||||||
|
|
|
@ -7,59 +7,12 @@ from ..hdl._ir import *
|
||||||
from ..hdl._ast import Value, ValueLike
|
from ..hdl._ast import Value, ValueLike
|
||||||
from ..hdl._mem import MemoryData
|
from ..hdl._mem import MemoryData
|
||||||
from ._base import BaseEngine
|
from ._base import BaseEngine
|
||||||
|
from ._pycoro import Tick, Settle, Delay, Passive, Active
|
||||||
|
|
||||||
|
|
||||||
__all__ = ["Settle", "Delay", "Tick", "Passive", "Active", "Simulator"]
|
__all__ = ["Settle", "Delay", "Tick", "Passive", "Active", "Simulator"]
|
||||||
|
|
||||||
|
|
||||||
class Command:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class Settle(Command):
|
|
||||||
@deprecated("The `Settle` command is deprecated per RFC 27. Use `add_testbench` to write "
|
|
||||||
"testbenches; in them, an equivalent of `yield Settle()` is performed "
|
|
||||||
"automatically.")
|
|
||||||
def __init__(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def __repr__(self):
|
|
||||||
return "(settle)"
|
|
||||||
|
|
||||||
|
|
||||||
class Delay(Command):
|
|
||||||
def __init__(self, interval=None):
|
|
||||||
self.interval = None if interval is None else float(interval)
|
|
||||||
|
|
||||||
def __repr__(self):
|
|
||||||
if self.interval is None:
|
|
||||||
return "(delay ε)"
|
|
||||||
else:
|
|
||||||
return f"(delay {self.interval * 1e6:.3}us)"
|
|
||||||
|
|
||||||
|
|
||||||
class Tick(Command):
|
|
||||||
def __init__(self, domain="sync"):
|
|
||||||
if not isinstance(domain, (str, ClockDomain)):
|
|
||||||
raise TypeError("Domain must be a string or a ClockDomain instance, not {!r}"
|
|
||||||
.format(domain))
|
|
||||||
assert domain != "comb"
|
|
||||||
self.domain = domain
|
|
||||||
|
|
||||||
def __repr__(self):
|
|
||||||
return f"(tick {self.domain})"
|
|
||||||
|
|
||||||
|
|
||||||
class Passive(Command):
|
|
||||||
def __repr__(self):
|
|
||||||
return "(passive)"
|
|
||||||
|
|
||||||
|
|
||||||
class Active(Command):
|
|
||||||
def __repr__(self):
|
|
||||||
return "(active)"
|
|
||||||
|
|
||||||
|
|
||||||
class Simulator:
|
class Simulator:
|
||||||
def __init__(self, fragment, *, engine="pysim"):
|
def __init__(self, fragment, *, engine="pysim"):
|
||||||
if isinstance(engine, type) and issubclass(engine, BaseEngine):
|
if isinstance(engine, type) and issubclass(engine, BaseEngine):
|
||||||
|
|
Loading…
Reference in a new issue