inteconnect/stream: Increase io_lcm size when io_lcm/i_dw or io_lcm/o_dw < 2.
Allow supporting all cases.
This commit is contained in:
parent
a166a8dba3
commit
675349055b
|
@ -519,6 +519,10 @@ class Gearbox(Module):
|
||||||
# # #
|
# # #
|
||||||
|
|
||||||
io_lcm = lcm(i_dw, o_dw)
|
io_lcm = lcm(i_dw, o_dw)
|
||||||
|
if (io_lcm//i_dw) < 2:
|
||||||
|
io_lcm = io_lcm * 2
|
||||||
|
if (io_lcm//o_dw) < 2:
|
||||||
|
io_lcm = io_lcm * 2
|
||||||
|
|
||||||
# Control path
|
# Control path
|
||||||
|
|
||||||
|
|
|
@ -42,20 +42,29 @@ def data_checker(dut, gearbox, datas):
|
||||||
|
|
||||||
|
|
||||||
class GearboxDUT(Module):
|
class GearboxDUT(Module):
|
||||||
def __init__(self):
|
def __init__(self, dw0=20, dw1=32):
|
||||||
self.submodules.gearbox0 = Gearbox(20, 32)
|
self.submodules.gearbox0 = Gearbox(dw0, dw1)
|
||||||
self.submodules.gearbox1 = Gearbox(32, 20)
|
self.submodules.gearbox1 = Gearbox(dw1, dw0)
|
||||||
self.comb += self.gearbox0.source.connect(self.gearbox1.sink)
|
self.comb += self.gearbox0.source.connect(self.gearbox1.sink)
|
||||||
|
|
||||||
|
|
||||||
class TestGearbox(unittest.TestCase):
|
class TestGearbox(unittest.TestCase):
|
||||||
def test_gearbox(self):
|
def gearbox_test(self, dw0, dw1):
|
||||||
prng = random.Random(42)
|
prng = random.Random(42)
|
||||||
dut = GearboxDUT()
|
dut = GearboxDUT(dw0, dw1)
|
||||||
datas = [prng.randrange(2**20) for i in range(128)]
|
datas = [prng.randrange(2**dw0) for i in range(128)]
|
||||||
generators = [
|
generators = [
|
||||||
data_generator(dut, dut.gearbox0, datas),
|
data_generator(dut, dut.gearbox0, datas),
|
||||||
data_checker(dut, dut.gearbox1, datas)
|
data_checker(dut, dut.gearbox1, datas)
|
||||||
]
|
]
|
||||||
run_simulation(dut, generators)
|
run_simulation(dut, generators)
|
||||||
self.assertEqual(dut.errors, 0)
|
self.assertEqual(dut.errors, 0)
|
||||||
|
|
||||||
|
def test_gearbox_20_32(self):
|
||||||
|
self.gearbox_test(20, 32)
|
||||||
|
|
||||||
|
def test_gearbox_10_2(self):
|
||||||
|
self.gearbox_test(10, 2)
|
||||||
|
|
||||||
|
def test_gearbox_10_4(self):
|
||||||
|
self.gearbox_test(10, 4)
|
||||||
|
|
Loading…
Reference in New Issue