Skip to content

Commit

Permalink
Fix scaling
Browse files Browse the repository at this point in the history
Signed-off-by: Travis F. Collins <[email protected]>
  • Loading branch information
tfcollins committed Jan 29, 2024
1 parent d268e40 commit 8e7a6f6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
20 changes: 16 additions & 4 deletions adi/jesd_internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down Expand Up @@ -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}")
Expand Down Expand Up @@ -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",
Expand Down
5 changes: 5 additions & 0 deletions adi/sshfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
5 changes: 3 additions & 2 deletions examples/ad9081_jesd_eye_diagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand All @@ -36,5 +36,6 @@
)
plt.axvline(0, color="black") # vertical
plt.axhline(0, color="black") # horizontal
plt.grid(True)

plt.show()

0 comments on commit 8e7a6f6

Please sign in to comment.