Skip to content

Commit b28989e

Browse files
author
LewisLiuLiuLiu
committed
implementing the Eye Analyzer Python script
1 parent 82c4185 commit b28989e

10 files changed

Lines changed: 2012 additions & 0 deletions

File tree

demo_eye_analyzer.py

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#!/usr/bin/env python3
2+
"""
3+
EyeAnalyzer Demo Script
4+
5+
This script demonstrates how to use the EyeAnalyzer module.
6+
It generates synthetic eye diagram data and performs analysis.
7+
"""
8+
9+
import numpy as np
10+
import sys
11+
import os
12+
13+
# Add current directory to path
14+
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
15+
16+
from eye_analyzer import EyeAnalyzer
17+
18+
def generate_test_data(ui=2.5e-11, num_ui=10000, noise_level=0.01):
19+
"""
20+
Generate synthetic eye diagram data.
21+
22+
Args:
23+
ui: Unit interval in seconds
24+
num_ui: Number of UI to generate
25+
noise_level: Noise standard deviation in volts
26+
27+
Returns:
28+
Tuple of (time_array, value_array)
29+
"""
30+
# Generate time array
31+
time_array = np.arange(num_ui) * ui
32+
33+
# Generate PRBS-like binary signal
34+
np.random.seed(42)
35+
value_array = np.random.choice([0.4, -0.4], size=num_ui)
36+
37+
# Add noise
38+
value_array += np.random.normal(0, noise_level, size=num_ui)
39+
40+
return time_array, value_array
41+
42+
def main():
43+
"""Main demo function."""
44+
print("="*60)
45+
print("EyeAnalyzer Demo")
46+
print("="*60)
47+
48+
# Parameters
49+
ui = 2.5e-11 # 10Gbps
50+
num_ui = 10000
51+
noise_level = 0.01
52+
53+
print(f"\nGenerating test data:")
54+
print(f" UI: {ui:.2e} s (10 Gbps)")
55+
print(f" Number of UI: {num_ui}")
56+
print(f" Noise level: {noise_level} V")
57+
58+
# Generate test data
59+
time_array, value_array = generate_test_data(ui, num_ui, noise_level)
60+
61+
print(f"\nData statistics:")
62+
print(f" Time range: {time_array[0]:.2e} to {time_array[-1]:.2e} s")
63+
print(f" Value range: {value_array.min():.3f} to {value_array.max():.3f} V")
64+
print(f" Value mean: {value_array.mean():.3f} V")
65+
print(f" Value std: {value_array.std():.3f} V")
66+
67+
# Create analyzer
68+
print(f"\nInitializing EyeAnalyzer...")
69+
analyzer = EyeAnalyzer(ui=ui, ui_bins=128, amp_bins=128)
70+
71+
# Perform analysis
72+
print(f"\nAnalyzing eye diagram...")
73+
metrics = analyzer.analyze(time_array, value_array)
74+
75+
# Save results
76+
output_dir = 'demo_results'
77+
print(f"\nSaving results to '{output_dir}/'...")
78+
analyzer.save_results(metrics, output_dir)
79+
80+
# Print summary
81+
print("\n" + "="*60)
82+
print("Analysis Complete!")
83+
print("="*60)
84+
print(f"\nEye Metrics:")
85+
print(f" Eye Height: {metrics['eye_height']*1000:.2f} mV")
86+
print(f" Eye Width: {metrics['eye_width']:.3f} UI")
87+
print(f"\nOutput Files:")
88+
print(f" 📄 {os.path.join(output_dir, 'eye_metrics.json')}")
89+
print(f" 🖼️ {os.path.join(output_dir, 'eye_diagram.png')}")
90+
print("="*60)
91+
92+
if __name__ == "__main__":
93+
main()

eye_analyzer/__init__.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"""
2+
EyeAnalyzer - SerDes Link Eye Diagram Analysis Tool
3+
4+
A Python tool for analyzing eye diagrams from SystemC-AMS simulation output.
5+
Supports eye diagram construction, eye height/width calculation, jitter decomposition,
6+
and visualization.
7+
8+
Version: 1.1.0
9+
Author: SerDes SystemC Project Team
10+
"""
11+
12+
from .core import EyeAnalyzer
13+
from .io import auto_load_waveform
14+
from .jitter import JitterDecomposer
15+
16+
__version__ = "1.1.0"
17+
__all__ = ["EyeAnalyzer", "auto_load_waveform", "JitterDecomposer"]

0 commit comments

Comments
 (0)