2013-05-22 11:10:13 -04:00
|
|
|
from migen.fhdl.std import *
|
2012-08-04 10:31:24 -04:00
|
|
|
from migen.bank.description import *
|
|
|
|
|
2013-03-10 14:32:38 -04:00
|
|
|
class ASMIprobe(Module):
|
|
|
|
def __init__(self, hub, trace_depth=16):
|
|
|
|
slots = hub.get_slots()
|
|
|
|
slot_count = len(slots)
|
2012-08-04 10:31:24 -04:00
|
|
|
|
2013-03-30 12:28:15 -04:00
|
|
|
self._slot_count = CSRStatus(bits_for(slot_count))
|
|
|
|
self._trace_depth = CSRStatus(bits_for(trace_depth))
|
|
|
|
self._slot_status = [CSRStatus(2, name="slot_status" + str(i)) for i in range(slot_count)]
|
|
|
|
self._trace = [CSRStatus(bits_for(slot_count-1), name="trace" + str(i)) for i in range(trace_depth)]
|
2012-08-04 10:31:24 -04:00
|
|
|
|
2013-03-10 14:32:38 -04:00
|
|
|
###
|
|
|
|
|
|
|
|
self.comb += [
|
2013-03-30 12:28:15 -04:00
|
|
|
self._slot_count.status.eq(slot_count),
|
|
|
|
self._trace_depth.status.eq(trace_depth)
|
2012-08-04 10:31:24 -04:00
|
|
|
]
|
|
|
|
for slot, status in zip(slots, self._slot_status):
|
2013-03-30 12:28:15 -04:00
|
|
|
self.sync += status.status.eq(slot.state)
|
|
|
|
shift_tags = [self._trace[n].status.eq(self._trace[n+1].status)
|
2012-08-04 10:31:24 -04:00
|
|
|
for n in range(len(self._trace) - 1)]
|
2013-03-30 12:28:15 -04:00
|
|
|
shift_tags.append(self._trace[-1].status.eq(hub.tag_call))
|
2013-03-10 14:32:38 -04:00
|
|
|
self.sync += If(hub.call, *shift_tags)
|
|
|
|
|
2013-03-30 12:28:15 -04:00
|
|
|
def get_csrs(self):
|
2013-03-10 14:32:38 -04:00
|
|
|
return [self._slot_count, self._trace_depth] + self._slot_status + self._trace
|