2 from nmigen
.hdl
.ast
import Past
3 from nmigen
.asserts
import Assert
, Assume
5 from gram
.core
.refresher
import RefreshExecuter
, RefreshSequencer
, RefreshTimer
, RefreshPostponer
, Refresher
, ZQCSExecuter
6 from gram
.compat
import *
7 from gram
.test
.utils
import *
9 class RefreshExecuterTestCase(FHDLTestCase
):
10 def test_executer(self
):
11 def generic_test(abits
, babits
, trp
, trfc
):
12 dut
= RefreshExecuter(abits
=abits
, babits
=babits
, trp
=trp
, trfc
=trfc
)
16 yield; yield Delay(1e-9)
17 self
.assertEqual((yield dut
.a
), 2**10)
21 self
.assertEqual((yield dut
.a
), 0)
23 runSimulation(dut
, process
, "test_refreshexecuter.vcd")
25 generic_test(20, 20, 5, 5)
26 generic_test(20, 20, 100, 5)
28 class RefreshSequencerTestCase(FHDLTestCase
):
29 def test_formal(self
):
31 dut
= RefreshSequencer(abits
=14, babits
=3, trp
=trp
, trfc
=trfc
, postponing
=1)
32 self
.assertFormal(dut
, mode
="bmc", depth
=trp
+trfc
+1)
34 class RefreshTimerTestCase(FHDLTestCase
):
35 def test_formal(self
):
36 def generic_test(tREFI
):
37 dut
= RefreshTimer(tREFI
)
38 self
.assertFormal(dut
, mode
="bmc", depth
=tREFI
+1)
39 [generic_test(_
) for _
in [2, 5, 10]]
41 class RefreshPostponerTestCase(FHDLTestCase
):
43 dut
= RefreshPostponer(1)
46 self
.assertFalse((yield dut
.req_o
))
48 runSimulation(dut
, process
, "test_refreshpostponer.vcd")
51 def generic_test(delay
):
52 dut
= RefreshPostponer(delay
)
58 for i
in range(delay
):
59 self
.assertFalse((yield dut
.req_o
))
62 self
.assertTrue((yield dut
.req_o
))
64 runSimulation(dut
, process
, "test_refreshpostponer.vcd")
66 [generic_test(_
) for _
in [1, 5, 10]]
68 def test_req_not_stuck(self
):
69 def generic_test(delay
):
70 dut
= RefreshPostponer(delay
)
76 for i
in range(delay
):
80 yield; yield Delay(1e-9)
82 self
.assertFalse((yield dut
.req_o
))
84 runSimulation(dut
, process
, "test_refreshpostponer.vcd")
86 [generic_test(_
) for _
in [1, 5, 10]]
88 class RefresherTestCase(FHDLTestCase
):
93 settings
.with_refresh
= True
94 settings
.refresh_zqcs_freq
= 1e0
95 settings
.timing
= Obj()
96 settings
.timing
.tREFI
= 64
97 settings
.timing
.tRP
= 1
98 settings
.timing
.tRFC
= 2
99 settings
.timing
.tZQCS
= 64
100 settings
.geom
= Obj()
101 settings
.geom
.addressbits
= 16
102 settings
.geom
.bankbits
= 3
104 settings
.phy
.nranks
= 1
107 def generic_test(postponing
):
108 dut
= Refresher(self
.settings
, 100e6
, postponing
)
111 self
.assertFalse((yield dut
.cmd
.valid
))
113 runSimulation(dut
, process
, "test_refresher.vcd")
115 [generic_test(_
) for _
in [1, 2, 4, 8]]
117 class ZQCSExecuterTestCase(FHDLTestCase
):
123 def test_sequence(self
):
124 dut
= ZQCSExecuter(self
.abits
, self
.babits
, self
.trp
, self
.tzqcs
)
127 yield dut
.start
.eq(1)
129 yield dut
.start
.eq(0)
132 # Check for Precharge ALL command
133 for i
in range(self
.trp
):
134 self
.assertEqual((yield dut
.a
), 2**10)
135 self
.assertEqual((yield dut
.ba
), 0)
136 self
.assertFalse((yield dut
.cas
))
137 self
.assertTrue((yield dut
.ras
))
138 self
.assertTrue((yield dut
.we
))
139 self
.assertFalse((yield dut
.done
))
142 # Check for ZQCS command
143 for i
in range(self
.tzqcs
):
144 self
.assertFalse((yield dut
.a
[10]))
145 self
.assertFalse((yield dut
.cas
))
146 self
.assertFalse((yield dut
.ras
))
147 self
.assertTrue((yield dut
.we
))
148 self
.assertFalse((yield dut
.done
))
151 self
.assertTrue((yield dut
.done
))
153 runSimulation(dut
, process
, "test_core_refresher_zqcsexecuter.vcd")