From 28885064f73edea5d5efb3d31a2464e3b17ee7f4 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Wed, 18 Sep 2019 10:14:47 +0200 Subject: [PATCH] soc/cores/timer/doc: rewrite a little bit, avoid some redundancy, change ident. --- litex/soc/cores/timer.py | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/litex/soc/cores/timer.py b/litex/soc/cores/timer.py index d82fae3d..7055254c 100644 --- a/litex/soc/cores/timer.py +++ b/litex/soc/cores/timer.py @@ -1,4 +1,6 @@ # This file is Copyright (c) 2013-2015 Sebastien Bourdeauducq +# This file is Copyright (c) 2019 Sean Cross +# This file is Copyright (c) 2019 Florent Kermarrec # 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 += [ -- 2.30.2