Esempio n. 1
0
def encode_lanes(lanes):
    encoded_lanes = []
    for lane in lanes:
        table = "m"
        change_table = False

        encoded_lane = []
        for frame in lane:
            new_frame = []
            for octet in frame:
                if change_table:
                    table = "p" if table == "m" else "m"
                if isinstance(octet, Control):
                    if table == "p":
                        encoded_octet = line_coding_control_rd_p[octet.value]
                    else:
                        encoded_octet = line_coding_control_rd_m[octet.value]
                else:
                    if table == "p":
                        encoded_octet = line_coding_data_rd_p[octet]
                    else:
                        encoded_octet = line_coding_data_rd_m[octet]
                change_table = (disparity(encoded_octet, 10) != 0)
                new_frame.append(encoded_octet)

            encoded_lane.append(new_frame)

        encoded_lanes.append(encoded_lane)

    return encoded_lanes
Esempio n. 2
0
def encode_lanes(lanes):
    encoded_lanes = []
    for lane in lanes:
        table = "m"
        change_table = False

        encoded_lane = []
        for frame in lane:
            new_frame = []
            for octet in frame:
                if change_table:
                    table = "p" if table == "m" else "m"
                if isinstance(octet, Control):
                    if table == "p":
                        encoded_octet = line_coding_control_rd_p[octet.value]
                    else:
                        encoded_octet = line_coding_control_rd_m[octet.value]
                else:
                    if table == "p":
                        encoded_octet = line_coding_data_rd_p[octet]
                    else:
                        encoded_octet = line_coding_data_rd_m[octet]
                change_table = (disparity(encoded_octet, 10) != 0)
                new_frame.append(encoded_octet)

            encoded_lane.append(new_frame)

        encoded_lanes.append(encoded_lane)

    return encoded_lanes
Esempio n. 3
0
def encode_model(datas):
    encoded_datas = []
    table = "m"
    change_table = False
    for octet in datas:
        if change_table:
            table = "p" if table == "m" else "m"
        if isinstance(octet, Control):
            if table == "p":
                encoded_octet = code_8b10b_control_rd_p[octet.value]
            else:
                encoded_octet = code_8b10b_control_rd_m[octet.value]
        else:
            if table == "p":
                encoded_octet = code_8b10b_data_rd_p[octet]
            else:
                encoded_octet = code_8b10b_data_rd_m[octet]
        change_table = (code_8b10b.disparity(encoded_octet, 10) != 0)
        encoded_datas.append(encoded_octet)
    return encoded_datas
Esempio n. 4
0
 def test_running_disparity(self):
     rd = -1
     for w in self.output_sequence:
         rd += code_8b10b.disparity(w, 10)
         self.assertIn(rd, {-1, 1})
Esempio n. 5
0
 def test_running_disparity(self):
     rd = -1
     for w in self.output_sequence:
         rd += code_8b10b.disparity(w, 10)
         self.assertIn(rd, {-1, 1})