def generator(dut):
     yield dut.reset.eq(1)
     yield
     yield dut.reset.eq(0)
     for i in range(512):
         yield dut.sink.data.eq(swap_bytes(seed_to_data(i, True), 4))
         yield
         if i >= dut.latency:
             reference = model.scramble(seed_to_data(i-dut.latency, True), 32)
             reference = swap_bytes(reference, 4)
             if (yield dut.source.data) != reference:
                 dut.errors += 1
示例#2
0
 def generator(dut):
     yield dut.reset.eq(1)
     yield
     yield dut.reset.eq(0)
     for i in range(512):
         yield dut.sink.data.eq(swap_bytes(seed_to_data(i, True), 4))
         yield
         if i >= dut.latency:
             reference = model.scramble(seed_to_data(i-dut.latency, True), 32)
             reference = swap_bytes(reference, 4)
             if (yield dut.source.data) != reference:
                 dut.errors += 1
示例#3
0
    def test_roundtrip(self, nlanes=4, nconverters=4):
        ps = JESD204BPhysicalSettings(l=nlanes, m=nconverters, n=16, np=16)
        ts = JESD204BTransportSettings(f=2, s=1, k=16, cs=1)
        jesd_settings = JESD204BSettings(ps, ts, did=0x5a, bid=0x5)

        transport = TransportLayer(jesd_settings)
        link = LinkLayer(16, True)

        # tx >>
        # # #
        tx_samples = [[seed_to_data(j) % (2**16) for j in range(4096)]
                      for i in range(nconverters)]
        # transport
        tx_lanes = transport.encode(tx_samples)
        # link
        tx_data = link.encode(tx_lanes)
        # line_coding
        tx_encoded_data = encode_lanes(tx_data)

        # >> loopback >>
        # # #
        rx_encoded_data = tx_encoded_data

        # >> rx
        # # #
        # line_coding
        rx_data = decode_lanes(rx_encoded_data)
        # link
        rx_lanes = link.decode(rx_data)
        # transport
        rx_samples = transport.decode(rx_lanes)

        self.assertEqual(tx_samples, rx_samples)
示例#4
0
    def test_scrambling_loopback(self):
        class DUT(Module):
            def __init__(self):
                scrambler = Scrambler(32)
                descrambler = Descrambler(32)
                self.comb += descrambler.reset.eq(~scrambler.valid)
                self.submodules += scrambler, descrambler
                self.comb += descrambler.sink.eq(scrambler.source)
                self.sink, self.source = scrambler.sink, descrambler.source

        dut = DUT()
        dut.errors = 0

        datas = [seed_to_data(i, False) for i in range(512)]

        def generator(dut):
            for data in datas:
                yield dut.sink.data.eq(data)
                yield

        def checker(dut):
            yield
            yield
            yield
            for data in datas:
                if (yield dut.source.data) != data:
                    dut.errors += 1
                yield

        run_simulation(dut, [generator(dut), checker(dut)])
        self.assertEqual(dut.errors, 0)
示例#5
0
    def test_roundtrip(self, nlanes=4, nconverters=4):
        ps = JESD204BPhysicalSettings(l=nlanes, m=nconverters, n=16, np=16)
        ts = JESD204BTransportSettings(f=2, s=1, k=16, cs=1)
        jesd_settings = JESD204BSettings(ps, ts, did=0x5a, bid=0x5)

        transport = TransportLayer(jesd_settings)
        link = LinkLayer(16, True)

        # tx >>
        # # #
        tx_samples = [[seed_to_data(j)%(2**16) for j in range(4096)]
            for i in range(nconverters)]
        # transport
        tx_lanes = transport.encode(tx_samples)
        # link
        tx_data = link.encode(tx_lanes)
        # line_coding
        tx_encoded_data = encode_lanes(tx_data)

        # >> loopback >>
        # # #
        rx_encoded_data = tx_encoded_data

        # >> rx
        # # #
        # line_coding
        rx_data = decode_lanes(rx_encoded_data)
        # link
        rx_lanes = link.decode(rx_data)
        # transport
        rx_samples = transport.decode(rx_lanes)

        self.assertEqual(tx_samples, rx_samples)
示例#6
0
 def test_link_scrambling(self):
     scrambler = Scrambler()
     descrambler = Descrambler()
     errors = 0
     for i in range(128):
         input_data = seed_to_data(i)
         scrambled_data = scrambler.scramble(input_data, 32)
         output_data = descrambler.descramble(scrambled_data, 32)
         if input_data != output_data:
             errors += 1
     self.assertEqual(errors, 0)
示例#7
0
 def test_link_scrambling(self):
     scrambler = Scrambler()
     descrambler = Descrambler()
     errors = 0
     for i in range(128):
         input_data = seed_to_data(i)
         scrambled_data = scrambler.scramble(input_data, 32)
         output_data = descrambler.descramble(scrambled_data, 32)
         if input_data != output_data:
             errors += 1
     self.assertEqual(errors, 0)
示例#8
0
 def test_transport_mapping(self):
     nconverters = 4
     input_samples = [[j + i * 256 for j in range(8)]
                      for i in range(nconverters)]
     for nlanes in [1, 2, 4, 8]:
         output_samples = self.transport_mapping_test(
             nlanes, nconverters, input_samples)
         self.assertEqual(input_samples, output_samples)
     input_samples = [[seed_to_data(j + i) % (2**16) for j in range(1024)]
                      for i in range(nconverters)]
     for nlanes in [1, 2, 4, 8]:
         output_samples = self.transport_mapping_test(
             nlanes, nconverters, input_samples)
         self.assertEqual(input_samples, output_samples)
示例#9
0
 def test_transport_mapping(self):
     nconverters = 4
     input_samples = [[j+i*256 for j in range(8)]
         for i in range(nconverters)]
     for nlanes in [1, 2, 4, 8]:
         output_samples = self.transport_mapping_test(nlanes,
                                                      nconverters,
                                                      input_samples)
         self.assertEqual(input_samples, output_samples)
     input_samples = [[seed_to_data(j+i)%(2**16) for j in range(1024)]
         for i in range(nconverters)]
     for nlanes in [1, 2, 4, 8]:
         output_samples = self.transport_mapping_test(nlanes,
                                                      nconverters,
                                                      input_samples)
         self.assertEqual(input_samples, output_samples)