soc/cores/freqmeter: Minor cosmetic cleanups.
This commit is contained in:
parent
ce5e3e3b93
commit
e6f1d677e7
|
@ -15,26 +15,26 @@ from litex.soc.interconnect.csr import *
|
||||||
class _Sampler(Module):
|
class _Sampler(Module):
|
||||||
def __init__(self, width):
|
def __init__(self, width):
|
||||||
self.latch = Signal()
|
self.latch = Signal()
|
||||||
self.i = Signal(width)
|
self.i = Signal(width)
|
||||||
self.o = Signal(32)
|
self.o = Signal(32)
|
||||||
|
|
||||||
# # #
|
# # #
|
||||||
|
|
||||||
inc = Signal(width)
|
inc = Signal(width)
|
||||||
counter = Signal(32)
|
count = Signal(32)
|
||||||
|
|
||||||
# Use wrapping property of unsigned arithmeric to reset the counter at each cycle. Doing
|
# Use wrapping property of unsigned arithmeric to reset the counter at each cycle. Doing
|
||||||
# it in fmeter clock domain would not be reliable.
|
# it in FreqMeter clock domain would not be reliable.
|
||||||
i_d = Signal(width)
|
i_d = Signal(width)
|
||||||
self.sync += i_d.eq(self.i)
|
self.sync += i_d.eq(self.i)
|
||||||
self.comb += inc.eq(self.i - i_d)
|
self.comb += inc.eq(self.i - i_d)
|
||||||
self.sync += \
|
self.sync += [
|
||||||
|
count.eq(count + inc),
|
||||||
If(self.latch,
|
If(self.latch,
|
||||||
counter.eq(0),
|
count.eq(0),
|
||||||
self.o.eq(counter),
|
self.o.eq(count)
|
||||||
).Else(
|
|
||||||
counter.eq(counter + inc)
|
|
||||||
)
|
)
|
||||||
|
]
|
||||||
|
|
||||||
# Freq Meter ---------------------------------------------------------------------------------------
|
# Freq Meter ---------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue