diff --git a/litedram/frontend/axi.py b/litedram/frontend/axi.py index 3b4ba92..50a8234 100644 --- a/litedram/frontend/axi.py +++ b/litedram/frontend/axi.py @@ -116,7 +116,7 @@ class LiteDRAMAXIBurst2Beat(Module): NextValue(count, count + 1), NextValue(offset, offset + size), If(ax_burst.burst == burst_types["wrap"], - If(offset == (ax_burst.len + 1 - 1)*size, + If(offset == (ax_burst.len - 1)*size, NextValue(offset, 0) ) ) diff --git a/test/test_axi.py b/test/test_axi.py index cf3c91f..f8253f8 100755 --- a/test/test_axi.py +++ b/test/test_axi.py @@ -135,7 +135,11 @@ class TestAXI(unittest.TestCase): r = [] for i in range(self.len + 1): if self.type == burst_types["incr"]: - r += [Beat(self.addr + i*2**(self.size))] + offset = i*2**(self.size) + r += [Beat(self.addr + offset)] + elif self.type == burst_types["wrap"]: + offset = (i*2**(self.size))%((2**self.size)*(self.len)) + r += [Beat(self.addr + offset)] else: r += [Beat(self.addr)] return r @@ -181,8 +185,9 @@ class TestAXI(unittest.TestCase): prng = random.Random(42) bursts = [] for i in range(32): - bursts.append(Burst(burst_types["fixed"], prng.randrange(2**32), prng.randrange(256), log2_int(32//8))) - bursts.append(Burst(burst_types["incr"], prng.randrange(2**32), prng.randrange(256), log2_int(32//8))) + bursts.append(Burst(burst_types["fixed"], prng.randrange(2**32), prng.randrange(255), log2_int(32//8))) + bursts.append(Burst(burst_types["incr"], prng.randrange(2**32), prng.randrange(255), log2_int(32//8))) + bursts.append(Burst(burst_types["wrap"], 4, 4-1, log2_int(2))) # generate expexted dut output (beats for reference) beats = []