-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo15.jl
121 lines (96 loc) · 3.6 KB
/
demo15.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#Demo 15: Skew tests
#-------------------------------------------------------------------------------
using CMDimCircuits
CMDimCircuits.@using_CData()
#Get a demo display:
include(CMDimCircuits.demoplotcfgscript)
#Normally use something like:
#CMDimData.@includepkg EasyPlotInspect
#==Constants
===============================================================================#
vvst = cons(:a, labels = set(yaxis="Amplitude (V)", xaxis="Time (s)"))
dnsvst = cons(:a, labels = set(yaxis="Delay wrt Ref (ns)", xaxis="Inserted Delay (s)"))
delayattr = cons(:a,
line = set(style=:solid, width=3),
glyph = set(shape=:x, size=2),
)
#==Input data
===============================================================================#
tbit = 1e-9 #Bit period
osr = 20 #samples per bit
nsamples = 127
reglen = 7
#==Computations
===============================================================================#
#NOTE: Not a very computationnaly efficient/stable algorithm
seq = 1.0*prbs(reglen=reglen, seed=1, nsamples=nsamples)
t = DataF1(0:(tbit/osr):((nsamples)*tbit))
tmax = maximum(t)
#Generate parameter sweeps:
sweeplist = PSweep[
PSweep("del", tbit.*[-.05, 0, .1])
]
tauref = tbit/5
taupat = tbit/2.5
Πref = pulse(t, Pole(1/tauref,:rad), tpw=tbit)
#Step functions:
Ur = step(t, Pole(1/taupat,:rad), tdel=0)
Uf = -step(t, Pole(1/taupat,:rad), tdel=0*tbit)
#intvec(v) = [val>0?1:(val<0)?-1:0 for val in v]
#Rise/fall sequences
diffseq = diff(vcat(0,seq)) #Assumes starts @ 0.
seqr = 1.0*(diffseq.>0)
seqf = 1.0*(diffseq.<0)
#Rise/fall patterns:
patr = pattern(seqr, Ur, tbit=tbit)
patf = pattern(seqf, Uf, tbit=tbit)
#Complete pattern:
pat = fill(DataHR, sweeplist) do del
return patr + xshift(patf, del)
end
pat = (pat-0.5)*2 #Center data pattern
pat = clip(pat, xmax=tmax)
patref = (pattern(seq, Πref, tbit=tbit)-0.5)*2 #Center data pattern
pat = xshift(pat, 4.5*tbit)
skew = measskew(patref, pat)
#skew=()
for (k, v) in skew
println("\n", k, "/1p: ", v/1e-12)
end
del = parameter(pat, "del")
println("\n", "fall delay/1p: ", del/1e-12)
#==Helper functions
===============================================================================#
#TODO: supply eyeparam() as a FoldedAxis or Plot constructor???
eyeparam(tbit; teye=1.5*tbit, tstart=0) = cons(:a,
xfolded = set(tbit, xstart=tstart, xmax=teye),
xaxis = set(min=0, max=teye), #Force limits on exact data range.
)
#==Generate plot
===============================================================================#
p1 = push!(cons(:plot, xyaxes=set(xmax=tmax), vvst, title="Patterns"),
cons(:wfrm, patref+2, line=set(width=1, color=:black), label="ref+2"),
# cons(:wfrm, Π),
cons(:wfrm, pat, label="pat"),
)
p2 = push!(cons(:plot, dnsvst, title="Rise Delays"),
cons(:wfrm, skew[:mean_delrise]/1e-9, delayattr, label="mean"),
cons(:wfrm, skew[:min_delrise]/1e-9, delayattr, label="min"),
cons(:wfrm, skew[:max_delrise]/1e-9, delayattr, label="max"),
)
p3 = push!(cons(:plot, vvst, eyeparam(tbit, teye=1.5*tbit, tstart=4.5*tbit), title="Eye"),
cons(:wfrm, pat, label=""), #No label to see params
)
p4 = push!(cons(:plot, dnsvst, title="Fall Delays"),
cons(:wfrm, skew[:mean_delfall]/1e-9, delayattr, label="mean"),
cons(:wfrm, skew[:min_delfall]/1e-9, delayattr, label="min"),
cons(:wfrm, skew[:max_delfall]/1e-9, delayattr, label="max"),
)
pcoll = push!(cons(:plotcoll, title="Signal Skew Tests"), p1, p2, p3, p4)
pcoll.ncolumns = 2
#==Display results in pcoll
===============================================================================#
EasyPlot.displaygui(pcoll)
#==Return pcoll to user (call evalfile(...))
===============================================================================#
pcoll