rle: expose length parameter to user, add assertion on dw to encode counter and automatically increase dw in rle mode

This commit is contained in:
Florent Kermarrec 2015-02-19 10:42:13 +01:00
parent 5fb6beb473
commit 5f19955825
2 changed files with 10 additions and 3 deletions

View File

@ -25,9 +25,11 @@ class LiteScopeSubSampler(LiteScopeSubSamplerUnit, AutoCSR):
self.comb += self.value.eq(self._value.storage) self.comb += self.value.eq(self._value.storage)
class LiteScopeRunLengthEncoderUnit(Module): class LiteScopeRunLengthEncoderUnit(Module):
def __init__(self, dw, length=1024): def __init__(self, dw, length):
self.dw = dw self.dw = dw
self.length = length self.length = length
if dw < (log2_int(length) + 1):
raise ValueError("Not enough bits to encode RLE length, increase dw or reduce RLE length")
self.sink = sink = Sink(data_layout(dw)) self.sink = sink = Sink(data_layout(dw))
self.source = source = Source(data_layout(dw)) self.source = source = Source(data_layout(dw))

View File

@ -6,13 +6,18 @@ from mibuild.tools import write_to_file
class LiteScopeLA(Module, AutoCSR): class LiteScopeLA(Module, AutoCSR):
def __init__(self, layout, depth, clk_domain="sys", def __init__(self, layout, depth, clk_domain="sys",
with_input_buffer=False, with_rle=False, with_subsampler=False): with_input_buffer=False,
with_rle=False, rle_length=256,
with_subsampler=False):
self.layout = layout self.layout = layout
self.data = Cat(*layout) self.data = Cat(*layout)
self.dw = flen(self.data) self.dw = flen(self.data)
if with_rle:
self.dw += 1
self.depth = depth self.depth = depth
self.clk_domain = clk_domain self.clk_domain = clk_domain
self.with_rle = with_rle self.with_rle = with_rle
self.rle_length = rle_length
self.with_input_buffer = with_input_buffer self.with_input_buffer = with_input_buffer
self.with_subsampler = with_subsampler self.with_subsampler = with_subsampler
@ -56,7 +61,7 @@ class LiteScopeLA(Module, AutoCSR):
# connect recorder # connect recorder
self.comb += Record.connect(self.trigger.source, self.recorder.trigger_sink) self.comb += Record.connect(self.trigger.source, self.recorder.trigger_sink)
if self.with_rle: if self.with_rle:
self.submodules.rle = LiteScopeRunLengthEncoder(self.dw) self.submodules.rle = LiteScopeRunLengthEncoder(self.dw, self.rle_length)
self.comb += [ self.comb += [
Record.connect(sink, self.rle.sink), Record.connect(sink, self.rle.sink),
Record.connect(self.rle.source, self.recorder.data_sink), Record.connect(self.rle.source, self.recorder.data_sink),