bist: add count to bist parameters

This commit is contained in:
Florent Kermarrec 2014-12-15 19:48:22 +01:00
parent 13d75d3933
commit fadd21fae2
3 changed files with 12 additions and 8 deletions

View File

@ -6,9 +6,9 @@ from lib.sata.transport import SATATransport
from lib.sata.command import SATACommand from lib.sata.command import SATACommand
class SATACON(Module): class SATACON(Module):
def __init__(self, phy, sector_size=512, max_count=16): def __init__(self, phy, sector_size=512, max_count=8):
self.submodules.link = SATALink(phy) self.submodules.link = SATALink(phy)
self.submodules.transport = SATATransport(self.link) self.submodules.transport = SATATransport(self.link)
self.submodules.command = SATACommand(self.transport) self.submodules.command = SATACommand(self.transport, sector_size=sector_size, max_count=max_count)
self.sink, self.source = self.command.sink, self.command.source self.sink, self.source = self.command.sink, self.command.source

View File

@ -5,12 +5,13 @@ from lib.sata.common import *
from lib.sata.link.scrambler import Scrambler from lib.sata.link.scrambler import Scrambler
class SATABIST(Module): class SATABIST(Module):
def __init__(self, sector_size=512, max_count=1): def __init__(self, sector_size=512):
self.sink = sink = Sink(command_rx_description(32)) self.sink = sink = Sink(command_rx_description(32))
self.source = source = Source(command_tx_description(32)) self.source = source = Source(command_tx_description(32))
self.start = Signal() self.start = Signal()
self.sector = Signal(48) self.sector = Signal(48)
self.count = Signal(4)
self.done = Signal() self.done = Signal()
self.ctrl_errors = Signal(32) self.ctrl_errors = Signal(32)
self.data_errors = Signal(32) self.data_errors = Signal(32)
@ -42,10 +43,10 @@ class SATABIST(Module):
fsm.act("SEND_WRITE_CMD_AND_DATA", fsm.act("SEND_WRITE_CMD_AND_DATA",
source.stb.eq(1), source.stb.eq(1),
source.sop.eq((counter.value == 0)), source.sop.eq((counter.value == 0)),
source.eop.eq((counter.value == (sector_size*max_count)//4-1)), source.eop.eq((counter.value == (sector_size//4*self.count)-1)),
source.write.eq(1), source.write.eq(1),
source.sector.eq(self.sector), source.sector.eq(self.sector),
source.count.eq(max_count), source.count.eq(self.count),
source.data.eq(scrambler.value), source.data.eq(scrambler.value),
counter.ce.eq(source.ack), counter.ce.eq(source.ack),
If(source.stb & source.eop & source.ack, If(source.stb & source.eop & source.ack,
@ -67,7 +68,7 @@ class SATABIST(Module):
source.eop.eq(1), source.eop.eq(1),
source.read.eq(1), source.read.eq(1),
source.sector.eq(self.sector), source.sector.eq(self.sector),
source.count.eq(max_count), source.count.eq(self.count),
If(source.ack, If(source.ack,
NextState("WAIT_READ_ACK") NextState("WAIT_READ_ACK")
) )

View File

@ -18,7 +18,7 @@ class TB(Module):
transport_debug=False, transport_loopback=False, transport_debug=False, transport_loopback=False,
hdd_debug=True) hdd_debug=True)
self.submodules.controller = SATACON(self.hdd.phy) self.submodules.controller = SATACON(self.hdd.phy)
self.submodules.bist = SATABIST(max_count=2) self.submodules.bist = SATABIST()
self.comb += [ self.comb += [
self.bist.source.connect(self.controller.sink), self.bist.source.connect(self.controller.sink),
self.controller.source.connect(self.bist.sink) self.controller.source.connect(self.bist.sink)
@ -27,6 +27,8 @@ class TB(Module):
def gen_simulation(self, selfp): def gen_simulation(self, selfp):
hdd = self.hdd hdd = self.hdd
hdd.malloc(0, 64) hdd.malloc(0, 64)
selfp.bist.sector = 0
selfp.bist.count = 4
while True: while True:
selfp.bist.start = 1 selfp.bist.start = 1
yield yield
@ -36,6 +38,7 @@ class TB(Module):
yield yield
print("ctrl_errors: {} / data_errors {}".format(selfp.bist.ctrl_errors, selfp.bist.data_errors)) print("ctrl_errors: {} / data_errors {}".format(selfp.bist.ctrl_errors, selfp.bist.data_errors))
selfp.bist.sector += 1 selfp.bist.sector += 1
selfp.bist.count = max((selfp.bist.count + 1)%8, 1)
if __name__ == "__main__": if __name__ == "__main__":
run_simulation(TB(), ncycles=4096, vcd_name="my.vcd", keep_files=True) run_simulation(TB(), ncycles=8192*2, vcd_name="my.vcd", keep_files=True)