2014-12-11 18:56:29 -05:00
|
|
|
import random
|
|
|
|
|
|
|
|
from migen.fhdl.std import *
|
|
|
|
from migen.genlib.record import *
|
|
|
|
from migen.sim.generic import run_simulation
|
|
|
|
|
|
|
|
from lib.sata.std import *
|
2014-12-12 08:35:48 -05:00
|
|
|
from lib.sata.link import SATALink
|
|
|
|
from lib.sata.transport import SATATransport
|
2014-12-11 18:56:29 -05:00
|
|
|
|
|
|
|
from lib.sata.test.bfm import *
|
|
|
|
from lib.sata.test.common import *
|
|
|
|
|
|
|
|
class TB(Module):
|
|
|
|
def __init__(self):
|
|
|
|
self.submodules.bfm = BFM(phy_debug=False,
|
2014-12-12 05:22:21 -05:00
|
|
|
link_random_level=0, transport_debug=True, transport_loopback=True)
|
2014-12-12 08:35:48 -05:00
|
|
|
self.submodules.link = SATALink(self.bfm.phy)
|
|
|
|
self.submodules.transport = SATATransport(self.link)
|
2014-12-11 18:56:29 -05:00
|
|
|
|
2014-12-12 05:22:21 -05:00
|
|
|
def gen_simulation(self, selfp):
|
|
|
|
for i in range(100):
|
|
|
|
yield
|
2014-12-12 08:31:00 -05:00
|
|
|
selfp.transport.sink.stb = 1
|
|
|
|
selfp.transport.sink.sop = 1
|
|
|
|
selfp.transport.sink.eop = 1
|
|
|
|
selfp.transport.sink.type = fis_types["REG_H2D"]
|
|
|
|
selfp.transport.sink.lba = 0x0123456789
|
2014-12-12 05:22:21 -05:00
|
|
|
yield
|
2014-12-12 08:31:00 -05:00
|
|
|
while selfp.transport.sink.ack == 0:
|
2014-12-12 05:22:21 -05:00
|
|
|
yield
|
2014-12-12 08:31:00 -05:00
|
|
|
|
2014-12-12 05:22:21 -05:00
|
|
|
for i in range(32):
|
2014-12-12 08:31:00 -05:00
|
|
|
selfp.transport.sink.stb = 1
|
|
|
|
selfp.transport.sink.sop = (i==0)
|
|
|
|
selfp.transport.sink.eop = (i==31)
|
|
|
|
selfp.transport.sink.type = fis_types["DATA"]
|
|
|
|
selfp.transport.sink.data = i
|
|
|
|
if selfp.transport.sink.ack == 1:
|
2014-12-12 05:22:21 -05:00
|
|
|
yield
|
|
|
|
else:
|
2014-12-12 08:31:00 -05:00
|
|
|
while selfp.transport.sink.ack == 0:
|
2014-12-12 05:22:21 -05:00
|
|
|
yield
|
2014-12-12 08:31:00 -05:00
|
|
|
selfp.transport.sink.stb = 0
|
2014-12-11 18:56:29 -05:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2014-12-12 05:22:21 -05:00
|
|
|
run_simulation(TB(), ncycles=512, vcd_name="my.vcd", keep_files=True)
|