soc/cores/timer/doc: rewrite a little bit, avoid some redundancy, change ident.

This commit is contained in:
Florent Kermarrec 2019-09-18 10:14:47 +02:00
parent f1139c36b4
commit 28885064f7
1 changed files with 16 additions and 17 deletions

View File

@ -1,4 +1,6 @@
# This file is Copyright (c) 2013-2015 Sebastien Bourdeauducq <sb@m-labs.hk>
# This file is Copyright (c) 2019 Sean Cross <sean@xobs.io>
# This file is Copyright (c) 2019 Florent Kermarrec <florent@enjoy-digital.fr>
# License: BSD
@ -10,28 +12,25 @@ from litex.soc.interconnect.csr_eventmanager import *
class Timer(Module, AutoCSR):
def __init__(self, width=32):
self._load = CSRStorage(width, description="""This is the initial value loaded into the
timer. You can make a one-shot timer by disabling the
timer, writing to this register, and then re-enabling
the timer. For a recurring timer, set this to the same
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._load = CSRStorage(width, description=
"""Load value when timer is (re-)enabled.
This register is only used to create a One-Shot timer and specify the timer's duration
in clock cycles: Disable the timer, write load value and re-enable the timer""")
self._reload = CSRStorage(width, description=
"""Reload value when timer reaches 0.
This register is used to create a Periodic timer and specify the timer's period in clock
cycles. For a One-Shot timer, this register need to be set to 0.""")
self._en = CSRStorage(1, description=
"""Enable. Write 1 to enable/start the timer, 0 to disable the timer""")
self._update_value = CSRStorage(1, description=
"""Update. Write 1 to latch current countdown to value register.""")
self._value = CSRStatus(width, description="""Latched countdown value""")
self.submodules.ev = EventManager()
self.ev.zero = EventSourceProcess()
self.ev.finalize()
###
# # #
value = Signal(width)
self.sync += [