timer: add documentation

Now that CSRs have documentation support, add documentation to the basic
`Timer` module.

Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
Sean Cross 2019-09-18 15:06:20 +08:00
parent cca0478a5e
commit cb7d941aaa
1 changed files with 16 additions and 5 deletions

View File

@ -10,11 +10,22 @@ from litex.soc.interconnect.csr_eventmanager import *
class Timer(Module, AutoCSR): class Timer(Module, AutoCSR):
def __init__(self, width=32): def __init__(self, width=32):
self._load = CSRStorage(width) self._load = CSRStorage(width, description="""This is the initial value loaded into the
self._reload = CSRStorage(width) timer. You can make a one-shot timer by disabling the
self._en = CSRStorage() timer, writing to this register, and then re-enabling
self._update_value = CSR() the timer. For a recurring timer, set this to the same
self._value = CSRStatus(width) value as `reload`, or to 0.""")
self._reload = CSRStorage(width, description="""The internal timer value will be updated
with this value whenever it reaches 0. Use this to create
a periodic timer that fires whenever this transitions from
0 to >0. To create a one-shot timer, leave this value as 0.""")
self._en = CSRStorage(fields=[CSRField("en", description="Write a `1` here to start the timer running")])
self._update_value = CSRStorage(fields=[CSRField("update", description="""Writing to this register causes
the `value` register to be updated with with the current countdown
value.""")])
self._value = CSRStatus(width, description="""Last snapshotted value of the countdown
timer. This value is only updated when a `1` is written
to `update_value`.""")
self.submodules.ev = EventManager() self.submodules.ev = EventManager()
self.ev.zero = EventSourceProcess() self.ev.zero = EventSourceProcess()