rle: increase dw automatically when needed
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Mon, 23 Feb 2015 08:41:18 +0000 (09:41 +0100)
committerFlorent Kermarrec <florent@enjoy-digital.fr>
Mon, 23 Feb 2015 08:41:18 +0000 (09:41 +0100)
litescope/core/storage.py
litescope/frontend/la.py

index 48ff9d16b9b960de584f9dc90569b80b02dd3060..30aab1615cb859f4f4b3f59bcb4cb8a503928af0 100644 (file)
@@ -28,8 +28,6 @@ class LiteScopeRunLengthEncoderUnit(Module):
        def __init__(self, dw, length):
                self.dw = dw
                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.source = source = Source(data_layout(dw))
index cbe7dbc413b502eca299ae03dfceaa9c0789bad6..fd8bd269e427504bf455006483b913d1e8643cf2 100644 (file)
@@ -13,6 +13,7 @@ class LiteScopeLA(Module, AutoCSR):
                self.data = Cat(*layout)
                self.dw = flen(self.data)
                if with_rle:
+                       self.dw = max(self.dw, log2_int(rle_length))
                        self.dw += 1
                self.depth = depth
                self.clk_domain = clk_domain