test/test_axi: add burst wrap test and fix code

This commit is contained in:
Florent Kermarrec 2018-08-29 18:47:40 +02:00
parent 47988d8cd3
commit f6797a16bb
2 changed files with 9 additions and 4 deletions

View File

@ -116,7 +116,7 @@ class LiteDRAMAXIBurst2Beat(Module):
NextValue(count, count + 1), NextValue(count, count + 1),
NextValue(offset, offset + size), NextValue(offset, offset + size),
If(ax_burst.burst == burst_types["wrap"], 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) NextValue(offset, 0)
) )
) )

View File

@ -135,7 +135,11 @@ class TestAXI(unittest.TestCase):
r = [] r = []
for i in range(self.len + 1): for i in range(self.len + 1):
if self.type == burst_types["incr"]: 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: else:
r += [Beat(self.addr)] r += [Beat(self.addr)]
return r return r
@ -181,8 +185,9 @@ class TestAXI(unittest.TestCase):
prng = random.Random(42) prng = random.Random(42)
bursts = [] bursts = []
for i in range(32): 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["fixed"], prng.randrange(2**32), prng.randrange(255), 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["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) # generate expexted dut output (beats for reference)
beats = [] beats = []