2016-05-26 05:10:03 -04:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
2016-05-03 13:24:33 -04:00
|
|
|
from litex.gen import *
|
|
|
|
|
|
|
|
from litex.soc.interconnect.stream import *
|
|
|
|
|
2016-06-15 11:51:46 -04:00
|
|
|
from litedram.common import LiteDRAMWritePort, LiteDRAMReadPort
|
2016-05-03 13:24:33 -04:00
|
|
|
from litedram.frontend.bist import LiteDRAMBISTGenerator
|
|
|
|
from litedram.frontend.bist import LiteDRAMBISTChecker
|
|
|
|
|
2016-05-23 07:30:38 -04:00
|
|
|
from test.common import DRAMMemory
|
|
|
|
|
2016-05-03 13:24:33 -04:00
|
|
|
class TB(Module):
|
|
|
|
def __init__(self):
|
2016-06-15 11:51:46 -04:00
|
|
|
self.write_port = LiteDRAMWritePort(aw=32, dw=32)
|
|
|
|
self.read_port = LiteDRAMReadPort(aw=32, dw=32)
|
2016-05-03 13:24:33 -04:00
|
|
|
self.submodules.generator = LiteDRAMBISTGenerator(self.write_port)
|
|
|
|
self.submodules.checker = LiteDRAMBISTChecker(self.read_port)
|
|
|
|
|
|
|
|
def main_generator(dut):
|
2016-05-26 06:04:41 -04:00
|
|
|
# init
|
|
|
|
yield dut.generator.reset.storage.eq(1)
|
|
|
|
yield dut.checker.reset.storage.eq(1)
|
|
|
|
yield
|
|
|
|
yield dut.generator.reset.storage.eq(0)
|
|
|
|
yield dut.checker.reset.storage.eq(0)
|
|
|
|
yield
|
2016-05-03 13:24:33 -04:00
|
|
|
# write
|
|
|
|
yield dut.generator.base.storage.eq(16)
|
2016-05-03 16:22:11 -04:00
|
|
|
yield dut.generator.length.storage.eq(64)
|
2016-05-23 08:17:22 -04:00
|
|
|
for i in range(8):
|
|
|
|
yield
|
2016-05-03 13:24:33 -04:00
|
|
|
yield dut.generator.shoot.re.eq(1)
|
|
|
|
yield
|
|
|
|
yield dut.generator.shoot.re.eq(0)
|
2016-05-23 08:17:22 -04:00
|
|
|
for i in range(8):
|
|
|
|
yield
|
2016-05-03 13:24:33 -04:00
|
|
|
while((yield dut.generator.done.status) == 0):
|
|
|
|
yield
|
|
|
|
# read
|
|
|
|
yield dut.checker.base.storage.eq(16)
|
2016-05-03 16:22:11 -04:00
|
|
|
yield dut.checker.length.storage.eq(64)
|
2016-05-23 08:17:22 -04:00
|
|
|
for i in range(8):
|
|
|
|
yield
|
2016-05-03 13:24:33 -04:00
|
|
|
yield dut.checker.shoot.re.eq(1)
|
|
|
|
yield
|
|
|
|
yield dut.checker.shoot.re.eq(0)
|
2016-05-23 08:17:22 -04:00
|
|
|
for i in range(8):
|
|
|
|
yield
|
2016-05-03 13:24:33 -04:00
|
|
|
while((yield dut.checker.done.status) == 0):
|
|
|
|
yield
|
2016-05-03 16:22:11 -04:00
|
|
|
# check
|
|
|
|
print("errors {:d}".format((yield dut.checker.error_count.status)))
|
|
|
|
yield
|
2016-05-03 13:24:33 -04:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
tb = TB()
|
2016-05-03 16:22:11 -04:00
|
|
|
mem = DRAMMemory(32, 128)
|
2016-05-03 13:24:33 -04:00
|
|
|
generators = {
|
|
|
|
"sys" : [main_generator(tb),
|
|
|
|
mem.write_generator(tb.write_port),
|
|
|
|
mem.read_generator(tb.read_port)]
|
|
|
|
}
|
|
|
|
clocks = {"sys": 10}
|
|
|
|
run_simulation(tb, generators, clocks, vcd_name="sim.vcd")
|