litescope/common: add Counter (will be removed from migen)

This commit is contained in:
Florent Kermarrec 2015-09-12 16:53:59 +02:00
parent 9393fee9f3
commit 984feb185f
1 changed files with 9 additions and 0 deletions

View File

@ -8,6 +8,15 @@ from migen.flow.plumbing import Buffer
from migen.fhdl.specials import Memory
@ResetInserter()
@CEInserter()
class Counter(Module):
def __init__(self, *args, increment=1, **kwargs):
self.value = Signal(*args, **kwargs)
self.width = flen(self.value)
self.sync += self.value.eq(self.value+increment)
def data_layout(dw):
return [("data", dw, DIR_M_TO_S)]