diff --git a/adi/jesd_internal.py b/adi/jesd_internal.py index d26b20abf..a471fe554 100644 --- a/adi/jesd_internal.py +++ b/adi/jesd_internal.py @@ -78,11 +78,11 @@ def get_all_statuses(self): class jesd_eye_scan(jesd): - _jesd_es_duration_ms = 100 + _jesd_es_duration_ms = 10 _jesd_prbs = 7 _max_possible_lanes_index = 24 - _half_rate = {"mode": "Half Fate", "scale": 0.004} + _half_rate = {"mode": "Half Rate", "scale": 1} _quarter_rate = {"mode": "Quarter Rate", "scale": 4} lanes = {} @@ -173,8 +173,19 @@ def get_eye_data(self, device=None, lanes=None): if lane not in available_lanes: raise Exception(f"Lane {lane} not found for device {device}.") + # Enable PRBS on TX side + devices_root = "/sys/bus/platform/devices/" + dev_list = self.fs.listdir(devices_root) + tx_dev = next((dev for dev in dev_list if "adxcvr-tx" in dev), None) + if not tx_dev: + raise Exception("No adxcvr-tx device found. Cannot enable PRBS.") + + self.fs.echo_to_fd("7", f"{devices_root}/{tx_dev}/prbs_select") + lane_eye_data = {} + print("Hold tight while we get the eye data...") + for lane in lanes: # Configure BIST print(f"Getting eye data for lane {lane}") @@ -205,14 +216,15 @@ def get_eye_data(self, device=None, lanes=None): else: spo = [float(x) for x in eye_line.split(",")] x.append(spo[0]) - y1.append(spo[1] * scale / 1000) - y2.append(spo[2] * scale / 1000) + y1.append(spo[1] * scale) + y2.append(spo[2] * scale) if len(x) == 0: raise Exception(f"No eye data found for lane {lane}.") graph_helpers = { "xlim": [-info[1] / 2, info[1] / 2 - 1], + "ylim": [-256, 256], "xlabel": "SPO", "ylabel": "EYE Voltage (mV)", "title": "JESD204 2D Eye Scan", diff --git a/adi/sshfs.py b/adi/sshfs.py index af47d3560..752d64388 100644 --- a/adi/sshfs.py +++ b/adi/sshfs.py @@ -51,3 +51,8 @@ def listdir(self, path): def gettext(self, path, *kargs, **kwargs): stdout, _ = self._run(f"cat {path}") return stdout + + def echo_to_fd(self, data, path): + if not self.isfile(path): + raise FileNotFoundError(f"No such file: {path}") + self._run(f"echo '{data}' > {path}") diff --git a/examples/ad9081_jesd_eye_diagram.py b/examples/ad9081_jesd_eye_diagram.py index 554167670..da36d2d5f 100644 --- a/examples/ad9081_jesd_eye_diagram.py +++ b/examples/ad9081_jesd_eye_diagram.py @@ -16,13 +16,13 @@ eye_data_per_lane = dev._jesd.get_eye_data() num_lanes = len(eye_data_per_lane.keys()) -for lane in eye_data_per_lane: +for i, lane in enumerate(eye_data_per_lane): x = eye_data_per_lane[lane]["x"] y1 = eye_data_per_lane[lane]["y1"] y2 = eye_data_per_lane[lane]["y2"] - plt.subplot(int(num_lanes / 2), 2, int(lane) + 1) + plt.subplot(int(num_lanes / 2), 2, int(i) + 1) plt.scatter(x, y1, marker="+", color="blue") plt.scatter(x, y2, marker="+", color="red") plt.xlim(eye_data_per_lane[lane]["graph_helpers"]["xlim"]) @@ -36,5 +36,6 @@ ) plt.axvline(0, color="black") # vertical plt.axhline(0, color="black") # horizontal + plt.grid(True) plt.show()