add simple Sequencer

This commit is contained in:
Florent Kermarrec 2012-08-12 16:04:52 +02:00
parent d22101eaa1
commit 18452c8193
2 changed files with 58 additions and 7 deletions

View File

@ -228,6 +228,7 @@ class Recorder:
#Control #Control
self.rst = Signal() self.rst = Signal()
self.start = Signal() self.start = Signal()
self.offset = Signal(BV(self.depth_width))
self.size = Signal(BV(self.depth_width)) self.size = Signal(BV(self.depth_width))
self.done = Signal() self.done = Signal()
#Write Path #Write Path
@ -245,10 +246,14 @@ class Recorder:
#Others #Others
self._mem = Memory(self.width, self.depth, self._put_port, self._get_port) self._mem = Memory(self.width, self.depth, self._put_port, self._get_port)
def get_fragment(self): def get_fragment(self):
comb = [] comb = []
sync = [] sync = []
memories = [self._mem] memories = [self._mem]
size_minus_offset = Signal(BV(self.depth_width))
comb += [size_minus_offset.eq(self.size-self.offset)]
#Control #Control
sync += [ sync += [
If(self.rst, If(self.rst,
@ -259,7 +264,8 @@ class Recorder:
self.done.eq(0) self.done.eq(0)
).Elif(self.start, ).Elif(self.start,
self._put_cnt.eq(0), self._put_cnt.eq(0),
self._get_cnt.eq(0) self._get_cnt.eq(0),
self._get_ptr.eq(self._put_ptr-size_minus_offset)
), ),
If(self.put, If(self.put,
self._put_cnt.eq(self._put_cnt+1), self._put_cnt.eq(self._put_cnt+1),
@ -271,9 +277,9 @@ class Recorder:
) )
] ]
comb += [ comb += [
If(self._put_cnt == self.size-1, If(self._put_cnt == size_minus_offset-1,
self.done.eq(1) self.done.eq(1)
).Elif(self._get_cnt == self.size-1, ).Elif(self._get_cnt == size_minus_offset-1,
self.done.eq(1) self.done.eq(1)
).Else( ).Else(
self.done.eq(0) self.done.eq(0)
@ -281,6 +287,44 @@ class Recorder:
] ]
return Fragment(comb=comb, sync=sync, memories=memories) return Fragment(comb=comb, sync=sync, memories=memories)
class Sequencer:
def __init__(self,depth):
self.depth = depth
self.depth_width = bits_for(self.depth)
# Controller interface
self.ctl_rst = Signal()
self.ctl_offset = Signal(BV(self.depth_width))
self.ctl_arm = Signal()
self.ctl_done = Signal()
# Triggers interface
self.trig_hit = Signal()
# Recorder interface
self.rec_offset = Signal(BV(self.depth_width))
self.rec_start = Signal()
self.rec_done = Signal()
# Others
self.enable = Signal()
def get_fragment(self):
comb = []
sync = []
#Control
sync += [
If(self.ctl_rst,
self.enable.eq(0)
).Elif(self.ctl_arm,
self.enable.eq(1)
).Elif(self.rec_done,
self.enable.eq(0)
)
]
comb += [
self.rec_offset.eq(self.ctl_offset),
self.rec_start.eq(self.enable & self.trig_hit)
]
return Fragment(comb=comb, sync=sync)
class MigCon: class MigCon:
pass pass

13
top.py
View File

@ -38,9 +38,9 @@ import migScope
# #
#Test Sum #Test Sum
# #
sum = migScope.Sum(4,pipe=True) #sum = migScope.Sum(4,pipe=True)
v = verilog.convert(sum.get_fragment()) #v = verilog.convert(sum.get_fragment())
print(v) #print(v)
# #
#Test MigIo #Test MigIo
@ -55,3 +55,10 @@ print(v)
#recorder = migScope.Recorder(32,1024) #recorder = migScope.Recorder(32,1024)
#v = verilog.convert(recorder.get_fragment()) #v = verilog.convert(recorder.get_fragment())
#print(v) #print(v)
#
#Test Sequencer
#
sequencer = migScope.Sequencer(1024)
v = verilog.convert(sequencer.get_fragment())
print(v)