2014-12-15 10:44:12 -05:00
|
|
|
import random, copy
|
|
|
|
|
|
|
|
from migen.fhdl.std import *
|
|
|
|
from migen.genlib.record import *
|
|
|
|
from migen.sim.generic import run_simulation
|
|
|
|
|
|
|
|
from lib.sata.common import *
|
2014-12-15 13:13:32 -05:00
|
|
|
from lib.sata import SATACON
|
2014-12-15 10:44:12 -05:00
|
|
|
from lib.sata.bist import SATABIST
|
|
|
|
|
|
|
|
from lib.sata.test.hdd import *
|
|
|
|
from lib.sata.test.common import *
|
|
|
|
|
|
|
|
class TB(Module):
|
|
|
|
def __init__(self):
|
|
|
|
self.submodules.hdd = HDD(
|
2014-12-15 13:04:45 -05:00
|
|
|
link_debug=False, link_random_level=0,
|
2014-12-15 10:44:12 -05:00
|
|
|
transport_debug=False, transport_loopback=False,
|
|
|
|
hdd_debug=True)
|
2014-12-15 13:13:32 -05:00
|
|
|
self.submodules.controller = SATACON(self.hdd.phy)
|
2014-12-15 13:48:22 -05:00
|
|
|
self.submodules.bist = SATABIST()
|
2014-12-15 10:44:12 -05:00
|
|
|
self.comb += [
|
2014-12-15 13:13:32 -05:00
|
|
|
self.bist.source.connect(self.controller.sink),
|
|
|
|
self.controller.source.connect(self.bist.sink)
|
2014-12-15 10:44:12 -05:00
|
|
|
]
|
|
|
|
|
|
|
|
def gen_simulation(self, selfp):
|
|
|
|
hdd = self.hdd
|
|
|
|
hdd.malloc(0, 64)
|
2014-12-15 13:48:22 -05:00
|
|
|
selfp.bist.sector = 0
|
|
|
|
selfp.bist.count = 4
|
2014-12-15 10:44:12 -05:00
|
|
|
while True:
|
|
|
|
selfp.bist.start = 1
|
|
|
|
yield
|
|
|
|
selfp.bist.start = 0
|
|
|
|
yield
|
|
|
|
while selfp.bist.done == 0:
|
|
|
|
yield
|
2014-12-15 13:04:45 -05:00
|
|
|
print("ctrl_errors: {} / data_errors {}".format(selfp.bist.ctrl_errors, selfp.bist.data_errors))
|
2014-12-15 10:44:12 -05:00
|
|
|
selfp.bist.sector += 1
|
2014-12-15 13:48:22 -05:00
|
|
|
selfp.bist.count = max((selfp.bist.count + 1)%8, 1)
|
2014-12-15 10:44:12 -05:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2014-12-15 13:48:22 -05:00
|
|
|
run_simulation(TB(), ncycles=8192*2, vcd_name="my.vcd", keep_files=True)
|