test/test_refresh: add Refresher test
This commit is contained in:
parent
7daf3551f6
commit
b543286d06
|
@ -6,7 +6,7 @@ import unittest
|
|||
from migen import *
|
||||
|
||||
from litedram.core.multiplexer import cmd_request_rw_layout
|
||||
from litedram.core.refresher import RefreshGenerator, RefreshTimer
|
||||
from litedram.core.refresher import RefreshGenerator, RefreshTimer, Refresher
|
||||
|
||||
|
||||
def c2bool(c):
|
||||
|
@ -33,8 +33,8 @@ class TestRefresh(unittest.TestCase):
|
|||
def test_refresh_generator(self):
|
||||
trp = 1
|
||||
trfc = 2
|
||||
class CMDS: pass
|
||||
cmds = CMDS()
|
||||
class Obj: pass
|
||||
cmds = Obj()
|
||||
starts = "_-______________"
|
||||
cmds.cas = "____-___________"
|
||||
cmds.ras = "___--___________"
|
||||
|
@ -65,3 +65,37 @@ class TestRefresh(unittest.TestCase):
|
|||
def test_refresh_timer(self):
|
||||
for i in range(1, 32):
|
||||
self.refresh_timer_test(i)
|
||||
|
||||
def test_refresher(self):
|
||||
class Obj: pass
|
||||
settings = Obj()
|
||||
settings.with_refresh = True
|
||||
settings.timing =Obj()
|
||||
settings.timing.tREFI = 64
|
||||
settings.timing.tRP = 1
|
||||
settings.timing.tRFC = 2
|
||||
settings.geom = Obj()
|
||||
settings.geom.addressbits = 16
|
||||
settings.geom.bankbits = 3
|
||||
settings.phy = Obj()
|
||||
settings.phy.nranks = 1
|
||||
|
||||
def generator(dut):
|
||||
dut.errors = 0
|
||||
yield dut.cmd.ready.eq(1)
|
||||
for i in range(16):
|
||||
while (yield dut.cmd.valid) == 0:
|
||||
yield
|
||||
cmd_valid_gap = 0
|
||||
while (yield dut.cmd.valid) == 1:
|
||||
cmd_valid_gap += 1
|
||||
yield
|
||||
while (yield dut.cmd.valid) == 0:
|
||||
cmd_valid_gap += 1
|
||||
yield
|
||||
if cmd_valid_gap != (settings.timing.tREFI + 1):
|
||||
dut.errors += 1
|
||||
|
||||
dut = Refresher(settings)
|
||||
run_simulation(dut, [generator(dut)])
|
||||
self.assertEqual(dut.errors, 0)
|
||||
|
|
Loading…
Reference in New Issue