timer: revert prescaler (we will in fact use a software prescaler for uIP)
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Fri, 10 Apr 2015 16:57:06 +0000 (18:57 +0200)
committerFlorent Kermarrec <florent@enjoy-digital.fr>
Fri, 10 Apr 2015 16:57:06 +0000 (18:57 +0200)
misoclib/cpu/peripherals/timer/__init__.py

index 22e4d75c638b84ca36c6f6d4b8bde1075099b995..2ab77eadccc23dd2c1eb3ffa7c0259a7074f0c30 100644 (file)
@@ -1,14 +1,12 @@
 from migen.fhdl.std import *
 from migen.bank.description import *
 from migen.bank.eventmanager import *
-from migen.genlib.misc import Counter
 
 class Timer(Module, AutoCSR):
-       def __init__(self, width=32, prescaler_width=32):
+       def __init__(self, width=32):
                self._load = CSRStorage(width)
                self._reload = CSRStorage(width)
                self._en = CSRStorage()
-               self._prescaler = CSRStorage(prescaler_width, reset=1)
                self._update_value = CSR()
                self._value = CSRStatus(width)
 
@@ -17,28 +15,14 @@ class Timer(Module, AutoCSR):
                self.ev.finalize()
 
                ###
-               enable = self._en.storage
-               tick = Signal()
-
-               counter = Counter(prescaler_width)
-               self.submodules += counter
-               self.comb += [
-                       If(enable,
-                               tick.eq(counter.value >= (self._prescaler.storage-1)),
-                               counter.ce.eq(1),
-                               counter.reset.eq(tick),
-                       ).Else(
-                               counter.reset.eq(1)
-                       )
-               ]
 
                value = Signal(width)
                self.sync += [
-                       If(enable,
+                       If(self._en.storage,
                                If(value == 0,
                                        # set reload to 0 to disable reloading
                                        value.eq(self._reload.storage)
-                               ).Elif(tick,
+                               ).Else(
                                        value.eq(value - 1)
                                )
                        ).Else(