test/phy_common: simplify calls to run_simulation
This commit is contained in:
parent
13cdbc0ed9
commit
fcda73a175
|
@ -12,11 +12,11 @@ from typing import Mapping, Sequence
|
||||||
|
|
||||||
from migen import *
|
from migen import *
|
||||||
|
|
||||||
|
from litex.gen.sim.core import run_simulation as _run_simulation
|
||||||
|
|
||||||
from litedram.phy import dfi
|
from litedram.phy import dfi
|
||||||
from litedram.phy.utils import chunks
|
from litedram.phy.utils import chunks
|
||||||
|
|
||||||
from test.test_phy_utils import run_simulation as _run_simulation
|
|
||||||
|
|
||||||
BOLD = '\033[1m'
|
BOLD = '\033[1m'
|
||||||
HIGHLIGHT = '\033[91m'
|
HIGHLIGHT = '\033[91m'
|
||||||
CLEAR = '\033[0m'
|
CLEAR = '\033[0m'
|
||||||
|
|
|
@ -7,8 +7,9 @@
|
||||||
import re
|
import re
|
||||||
import copy
|
import copy
|
||||||
import unittest
|
import unittest
|
||||||
from collections import defaultdict
|
|
||||||
from typing import Mapping
|
from typing import Mapping
|
||||||
|
from functools import partial
|
||||||
|
from collections import defaultdict
|
||||||
|
|
||||||
from migen import *
|
from migen import *
|
||||||
|
|
||||||
|
@ -16,7 +17,8 @@ from litedram.phy.utils import bit
|
||||||
from litedram.phy.lpddr4.simphy import LPDDR4SimPHY, DoubleRateLPDDR4SimPHY
|
from litedram.phy.lpddr4.simphy import LPDDR4SimPHY, DoubleRateLPDDR4SimPHY
|
||||||
from litedram.phy.lpddr4 import simsoc
|
from litedram.phy.lpddr4 import simsoc
|
||||||
|
|
||||||
from test.phy_common import DFISequencer, PadChecker, run_simulation as _run_simulation
|
import test.phy_common
|
||||||
|
from test.phy_common import DFISequencer, PadChecker
|
||||||
|
|
||||||
|
|
||||||
# Migen simulator supports reset signals so we could add CRG to start all the signals
|
# Migen simulator supports reset signals so we could add CRG to start all the signals
|
||||||
|
@ -38,18 +40,14 @@ from test.phy_common import DFISequencer, PadChecker, run_simulation as _run_sim
|
||||||
# sys8x_90_ddr does not trigger at the simulation start (not an edge),
|
# sys8x_90_ddr does not trigger at the simulation start (not an edge),
|
||||||
# BUT a generator starts before first edge, so a `yield` is needed to wait until the first
|
# BUT a generator starts before first edge, so a `yield` is needed to wait until the first
|
||||||
# rising edge!
|
# rising edge!
|
||||||
CLOCKS = {
|
run_simulation = partial(test.phy_common.run_simulation, clocks={
|
||||||
"sys": (64, 31),
|
"sys": (64, 31),
|
||||||
"sys2x": (32, 15),
|
"sys2x": (32, 15),
|
||||||
"sys8x": ( 8, 3),
|
"sys8x": ( 8, 3),
|
||||||
"sys8x_ddr": ( 4, 1),
|
"sys8x_ddr": ( 4, 1),
|
||||||
"sys8x_90": ( 8, 1),
|
"sys8x_90": ( 8, 1),
|
||||||
"sys8x_90_ddr": ( 4, 3),
|
"sys8x_90_ddr": ( 4, 3),
|
||||||
}
|
})
|
||||||
|
|
||||||
def run_simulation(dut, generators, **kwargs):
|
|
||||||
_run_simulation(dut, generators, CLOCKS, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def dfi_data_to_dq(dq_i, dfi_phases, dfi_name, nphases=8):
|
def dfi_data_to_dq(dq_i, dfi_phases, dfi_name, nphases=8):
|
||||||
|
|
|
@ -6,27 +6,27 @@
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
import itertools
|
import itertools
|
||||||
|
from functools import partial
|
||||||
|
|
||||||
from migen import *
|
from migen import *
|
||||||
|
|
||||||
from litedram.phy.utils import Serializer, Deserializer, Latency, chunks, bit, ConstBitSlip
|
from litedram.phy.utils import Serializer, Deserializer, Latency, chunks, bit, ConstBitSlip
|
||||||
|
|
||||||
from test.phy_common import run_simulation
|
import test.phy_common
|
||||||
|
|
||||||
|
|
||||||
|
run_serializers_simulation = partial(test.phy_common.run_simulation, clocks={
|
||||||
|
"sys": (64, 31),
|
||||||
|
"sys_11_25": (64, 29), # aligned to sys8x_90 (phase shift of 11.25)
|
||||||
|
"sys2x": (32, 15),
|
||||||
|
"sys8x": ( 8, 3),
|
||||||
|
"sys8x_ddr": ( 4, 1),
|
||||||
|
"sys8x_90": ( 8, 1),
|
||||||
|
"sys8x_90_ddr": ( 4, 3),
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
class TestSimSerializers(unittest.TestCase):
|
class TestSimSerializers(unittest.TestCase):
|
||||||
def run_simulation(self, dut, generators, **kwargs):
|
|
||||||
clocks = {
|
|
||||||
"sys": (64, 31),
|
|
||||||
"sys_11_25": (64, 29), # aligned to sys8x_90 (phase shift of 11.25)
|
|
||||||
"sys2x": (32, 15),
|
|
||||||
"sys8x": ( 8, 3),
|
|
||||||
"sys8x_ddr": ( 4, 1),
|
|
||||||
"sys8x_90": ( 8, 1),
|
|
||||||
"sys8x_90_ddr": ( 4, 3),
|
|
||||||
}
|
|
||||||
run_simulation(dut, generators, clocks, **kwargs)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def data_generator(i, datas):
|
def data_generator(i, datas):
|
||||||
for data in datas:
|
for data in datas:
|
||||||
|
@ -56,7 +56,7 @@ class TestSimSerializers(unittest.TestCase):
|
||||||
clkgen: self.data_generator(dut.i, datas),
|
clkgen: self.data_generator(dut.i, datas),
|
||||||
clkcheck: self.data_checker(dut.o, received, n=len(datas) * data_width, latency=latency * data_width, yield1=True),
|
clkcheck: self.data_checker(dut.o, received, n=len(datas) * data_width, latency=latency * data_width, yield1=True),
|
||||||
}
|
}
|
||||||
self.run_simulation(dut, generators, **kwargs)
|
run_serializers_simulation(dut, generators, **kwargs)
|
||||||
|
|
||||||
received = list(chunks(received, data_width))
|
received = list(chunks(received, data_width))
|
||||||
datas = [[bit(i, d) for i in range(data_width)] for d in datas]
|
datas = [[bit(i, d) for i in range(data_width)] for d in datas]
|
||||||
|
@ -75,7 +75,7 @@ class TestSimSerializers(unittest.TestCase):
|
||||||
clkcheck: self.data_checker(dut.o, received, n=len(datas), latency=latency),
|
clkcheck: self.data_checker(dut.o, received, n=len(datas), latency=latency),
|
||||||
}
|
}
|
||||||
|
|
||||||
self.run_simulation(dut, generators, **kwargs)
|
run_serializers_simulation(dut, generators, **kwargs)
|
||||||
|
|
||||||
received = [[bit(i, d) for i in range(data_width)] for d in received]
|
received = [[bit(i, d) for i in range(data_width)] for d in received]
|
||||||
self.assertEqual(received, datas)
|
self.assertEqual(received, datas)
|
||||||
|
|
Loading…
Reference in New Issue