test/test_axi: add bursts to axi2native
This commit is contained in:
parent
e27fbc2430
commit
93e8510f55
|
@ -112,30 +112,35 @@ class TestAXI(unittest.TestCase):
|
||||||
run_simulation(dut, generators, vcd_name="burst2beat.vcd")
|
run_simulation(dut, generators, vcd_name="burst2beat.vcd")
|
||||||
self.assertEqual(self.errors, 0)
|
self.assertEqual(self.errors, 0)
|
||||||
|
|
||||||
def test_axi2native(self):
|
def test_axi2native(self, with_random=True):
|
||||||
def writes_cmd_generator(axi_port, writes):
|
def writes_cmd_generator(axi_port, writes):
|
||||||
for write in writes:
|
for write in writes:
|
||||||
# send command
|
# send command
|
||||||
yield axi_port.aw.valid.eq(1)
|
yield axi_port.aw.valid.eq(1)
|
||||||
yield axi_port.aw.addr.eq(write.addr<<2)
|
yield axi_port.aw.addr.eq(write.addr<<2)
|
||||||
|
yield axi_port.aw.burst.eq(write.type)
|
||||||
|
yield axi_port.aw.len.eq(write.len)
|
||||||
|
yield axi_port.aw.size.eq(write.size)
|
||||||
yield axi_port.aw.id.eq(write.id)
|
yield axi_port.aw.id.eq(write.id)
|
||||||
|
yield
|
||||||
while (yield axi_port.aw.ready) == 0:
|
while (yield axi_port.aw.ready) == 0:
|
||||||
yield
|
yield
|
||||||
yield
|
|
||||||
yield axi_port.aw.valid.eq(0)
|
yield axi_port.aw.valid.eq(0)
|
||||||
yield
|
|
||||||
|
|
||||||
def writes_data_generator(axi_port, writes):
|
def writes_data_generator(axi_port, writes):
|
||||||
for write in writes:
|
for write in writes:
|
||||||
|
for i, data in enumerate(write.data):
|
||||||
# send data
|
# send data
|
||||||
yield axi_port.w.valid.eq(1)
|
yield axi_port.w.valid.eq(1)
|
||||||
|
if (i == (len(write.data) - 1)):
|
||||||
yield axi_port.w.last.eq(1)
|
yield axi_port.w.last.eq(1)
|
||||||
yield axi_port.w.data.eq(write.data)
|
else:
|
||||||
|
yield axi_port.w.last.eq(0)
|
||||||
|
yield axi_port.w.data.eq(data)
|
||||||
|
yield
|
||||||
while (yield axi_port.w.ready) == 0:
|
while (yield axi_port.w.ready) == 0:
|
||||||
yield
|
yield
|
||||||
yield
|
|
||||||
yield axi_port.w.valid.eq(0)
|
yield axi_port.w.valid.eq(0)
|
||||||
yield
|
|
||||||
|
|
||||||
def writes_response_generator(axi_port, writes):
|
def writes_response_generator(axi_port, writes):
|
||||||
self.writes_id_errors = 0
|
self.writes_id_errors = 0
|
||||||
|
@ -153,28 +158,36 @@ class TestAXI(unittest.TestCase):
|
||||||
# send command
|
# send command
|
||||||
yield axi_port.ar.valid.eq(1)
|
yield axi_port.ar.valid.eq(1)
|
||||||
yield axi_port.ar.addr.eq(read.addr<<2)
|
yield axi_port.ar.addr.eq(read.addr<<2)
|
||||||
|
yield axi_port.ar.burst.eq(read.type)
|
||||||
|
yield axi_port.ar.len.eq(read.len)
|
||||||
|
yield axi_port.ar.size.eq(read.size)
|
||||||
yield axi_port.ar.id.eq(read.id)
|
yield axi_port.ar.id.eq(read.id)
|
||||||
yield
|
yield
|
||||||
while (yield axi_port.ar.ready) == 0:
|
while (yield axi_port.ar.ready) == 0:
|
||||||
yield
|
yield
|
||||||
yield axi_port.ar.valid.eq(0)
|
yield axi_port.ar.valid.eq(0)
|
||||||
yield
|
|
||||||
|
|
||||||
def reads_response_data_generator(axi_port, reads):
|
def reads_response_data_generator(axi_port, reads):
|
||||||
self.reads_data_errors = 0
|
self.reads_data_errors = 0
|
||||||
self.reads_id_errors = 0
|
self.reads_id_errors = 0
|
||||||
self.reads_last_errors = 0
|
self.reads_last_errors = 0
|
||||||
yield axi_port.r.ready.eq(1) # always accepting read response
|
yield axi_port.r.ready.eq(1) # always accepting read response
|
||||||
|
yield
|
||||||
for read in reads:
|
for read in reads:
|
||||||
|
for i, data in enumerate(read.data):
|
||||||
# wait data / response
|
# wait data / response
|
||||||
while (yield axi_port.r.valid) == 0:
|
while (yield axi_port.r.valid) == 0:
|
||||||
yield
|
yield
|
||||||
if (yield axi_port.r.data) != read.data:
|
if (yield axi_port.r.data) != data:
|
||||||
self.reads_data_errors += 1
|
self.reads_data_errors += 1
|
||||||
if (yield axi_port.r.id) != read.id:
|
if (yield axi_port.r.id) != read.id:
|
||||||
self.reads_id_errors += 1
|
self.reads_id_errors += 1
|
||||||
|
if i == (len(read.data) - 1):
|
||||||
if (yield axi_port.r.last) != 1:
|
if (yield axi_port.r.last) != 1:
|
||||||
self.reads_last_errors += 1
|
self.reads_last_errors += 1
|
||||||
|
else:
|
||||||
|
if (yield axi_port.r.last) != 0:
|
||||||
|
self.reads_last_errors += 1
|
||||||
yield
|
yield
|
||||||
|
|
||||||
# dut
|
# dut
|
||||||
|
@ -186,19 +199,21 @@ class TestAXI(unittest.TestCase):
|
||||||
# generate writes/reads
|
# generate writes/reads
|
||||||
prng = random.Random(42)
|
prng = random.Random(42)
|
||||||
writes = []
|
writes = []
|
||||||
for i in range(64):
|
for i in range(16):
|
||||||
|
if with_random:
|
||||||
# incrementing addr, random data &id
|
# incrementing addr, random data &id
|
||||||
writes.append(Write(i, prng.randrange(2**32), prng.randrange(2**8)))
|
writes.append(Write(i, [prng.randrange(2**32) for _ in range(i+1)], prng.randrange(2**8), type=0b00, len=i))
|
||||||
|
else:
|
||||||
# incrementing addr, data & id (debug)
|
# incrementing addr, data & id (debug)
|
||||||
#writes.append(Write(i, i, i))
|
writes.append(Write(i, [i for _ in range(i+1)], i, type=0b00, len=i))
|
||||||
reads = []
|
reads = []
|
||||||
for i in range(64): # dummy reads while content not yet written
|
for i in range(16):
|
||||||
reads.append(Read(64, 0x00000000, 0x00))
|
if with_random:
|
||||||
for i in range(64):
|
|
||||||
# incrementing addr, written data, random id
|
# incrementing addr, written data, random id
|
||||||
reads.append(Read(i, writes[i].data, prng.randrange(2**8)))
|
reads.append(Read(i, writes[i].data, prng.randrange(2**8), type=0b00, len=len(writes[i].data)-1))
|
||||||
|
else:
|
||||||
# incrementing addr, written data, incrementing id (debug)
|
# incrementing addr, written data, incrementing id (debug)
|
||||||
#reads.append(Read(i, writes[i].data, i))
|
reads.append(Read(i, writes[i].data, i, type=0b00, len=len(writes[i].data)-1))
|
||||||
|
|
||||||
# simulation
|
# simulation
|
||||||
generators = [
|
generators = [
|
||||||
|
|
Loading…
Reference in New Issue