Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
x393
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
x393
Commits
3d603296
Commit
3d603296
authored
Mar 28, 2015
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed last of the known so far errors in the DQ input delays vs DQS input delays LMA fitting
parent
07f11d45
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
84 additions
and
56 deletions
+84
-56
x393_lma.py
py393/x393_lma.py
+62
-35
x393_mcntrl_adjust.py
py393/x393_mcntrl_adjust.py
+22
-21
No files found.
py393/x393_lma.py
View file @
3d603296
...
@@ -116,7 +116,12 @@ class X393LMA(object):
...
@@ -116,7 +116,12 @@ class X393LMA(object):
'tFDQS'
:
[
True
,
True
,
True
,
True
],
'tFDQS'
:
[
True
,
True
,
True
,
True
],
'tFDQ'
:
[
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
],
'tFDQ'
:
[
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
],
'anaScale'
:
True
,
# False,# True, # False # Broke?
'anaScale'
:
True
,
# False,# True, # False # Broke?
'tCDQS'
:
False
# True #False #True # list of 30
# 'tCDQS': False # True #False #True # list of 30
'tCDQS'
:
[
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
# 8
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
True
,
# False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, #15
True
,
True
,
True
,
True
,
True
,
True
,
True
]
# False, False, False, False, False, False, False] #7
}
}
"""
"""
parameterMask={'tSDQS': True,
parameterMask={'tSDQS': True,
...
@@ -144,7 +149,10 @@ class X393LMA(object):
...
@@ -144,7 +149,10 @@ class X393LMA(object):
data_set
,
data_set
,
compare_prim_steps
,
compare_prim_steps
,
scale_w
=
0.2
,
# multiply weight by this if fractions are undefined
scale_w
=
0.2
,
# multiply weight by this if fractions are undefined
periods
=
None
):
periods
=
None
,
quiet
=
1
):
if
quiet
<
3
:
print
(
"createYandWvectors(): scale_w=
%
f"
%
(
scale_w
))
print
(
"createYandWvectors(): scale_w=
%
f"
%
(
scale_w
))
def
pythIsNone
(
obj
):
def
pythIsNone
(
obj
):
return
obj
is
None
return
obj
is
None
...
@@ -765,7 +773,7 @@ class X393LMA(object):
...
@@ -765,7 +773,7 @@ class X393LMA(object):
print
()
print
()
return
data_periods_map
return
data_periods_map
def
init_parameters
(
self
,
def
lma_fit
(
self
,
lane
,
# byte lane
lane
,
# byte lane
bin_size
,
bin_size
,
clk_period
,
clk_period
,
...
@@ -782,6 +790,10 @@ class X393LMA(object):
...
@@ -782,6 +790,10 @@ class X393LMA(object):
each of 2x2 elements (DQ delay values) or null
each of 2x2 elements (DQ delay values) or null
Create data set template - for each DQS delay and inPhase
Create data set template - for each DQS delay and inPhase
- branch - number of full periods to add
- branch - number of full periods to add
After initial parametersn are created - run LMA to find optimal ones,
then return up to 3 varints (early, nominal, late) providing the best
DQ input delay for each DQS one
@lane byte lane to process
@lane byte lane to process
@bin_size bin size for the histograms (should be 5/10/20/40)
@bin_size bin size for the histograms (should be 5/10/20/40)
@clk_period SDCLK period in ps
@clk_period SDCLK period in ps
...
@@ -792,7 +804,10 @@ class X393LMA(object):
...
@@ -792,7 +804,10 @@ class X393LMA(object):
save None for fraction in unknown (previous -0.5, next +0.5)
save None for fraction in unknown (previous -0.5, next +0.5)
@scale_w weight for "uncertain" values (where samples chane from all 0 to all 1 in one step)
@scale_w weight for "uncertain" values (where samples chane from all 0 to all 1 in one step)
@quiet reduce output
@quiet reduce output
@return 3-element dictionary of ('early','nominal','late'), each being None or a 160-element list,
each element being either None, or a list of 3 best DQ delay values for the DQS delay (some mey be None too)
"""
"""
if
quiet
<
3
:
print
(
"init_parameters(): scale_w=
%
f"
%
(
scale_w
))
print
(
"init_parameters(): scale_w=
%
f"
%
(
scale_w
))
self
.
clk_period
=
clk_period
self
.
clk_period
=
clk_period
...
@@ -816,7 +831,8 @@ class X393LMA(object):
...
@@ -816,7 +831,8 @@ class X393LMA(object):
data_set
,
data_set
,
compare_prim_steps
,
compare_prim_steps
,
scale_w
,
scale_w
,
data_periods_map
)
data_periods_map
,
quiet
)
# print("ywp=%s"%(str(ywp)))
# print("ywp=%s"%(str(ywp)))
if
quiet
<
2
:
if
quiet
<
2
:
print
(
"
\n
Y-vector:"
)
print
(
"
\n
Y-vector:"
)
...
@@ -839,6 +855,7 @@ class X393LMA(object):
...
@@ -839,6 +855,7 @@ class X393LMA(object):
for
b
,
d
in
enumerate
(
hist_estimated
[
'b_indiv'
]):
for
b
,
d
in
enumerate
(
hist_estimated
[
'b_indiv'
]):
tDQSHL
+=
(
d
[
1
][
0
]
-
d
[
0
][
0
]
+
d
[
3
][
0
]
-
d
[
2
][
0
])
*
step_ps
tDQSHL
+=
(
d
[
1
][
0
]
-
d
[
0
][
0
]
+
d
[
3
][
0
]
-
d
[
2
][
0
])
*
step_ps
tDQHL
[
b
]
=
(
d
[
0
][
0
]
-
d
[
1
][
0
]
+
d
[
3
][
0
]
-
d
[
2
][
0
])
*
step_ps
tDQHL
[
b
]
=
(
d
[
0
][
0
]
-
d
[
1
][
0
]
+
d
[
3
][
0
]
-
d
[
2
][
0
])
*
step_ps
if
quiet
<
3
:
print
(
"
%
d: S=
%
f, D=
%
f"
%
(
b
,
d
[
1
][
0
]
-
d
[
0
][
0
]
+
d
[
3
][
0
]
-
d
[
2
][
0
],
d
[
0
][
0
]
-
d
[
1
][
0
]
+
d
[
3
][
0
]
-
d
[
2
][
0
]))
print
(
"
%
d: S=
%
f, D=
%
f"
%
(
b
,
d
[
1
][
0
]
-
d
[
0
][
0
]
+
d
[
3
][
0
]
-
d
[
2
][
0
],
d
[
0
][
0
]
-
d
[
1
][
0
]
+
d
[
3
][
0
]
-
d
[
2
][
0
]))
tDQSHL
/=
8.0
tDQSHL
/=
8.0
# calculate primary tDQ delays (primary - for the edges selected by 'primary_set'
# calculate primary tDQ delays (primary - for the edges selected by 'primary_set'
...
@@ -860,8 +877,14 @@ class X393LMA(object):
...
@@ -860,8 +877,14 @@ class X393LMA(object):
"tCDQS"
:
(
0.0
,)
*
30
"tCDQS"
:
(
0.0
,)
*
30
# "anaScale":self.analog_scale
# "anaScale":self.analog_scale
}
}
"""
Returns # best (early,nominal,late) for each bit for each delay ([3][160][8])
Outer list each has 160-element list, some of which are None, others hove 8 elements (including None ones)
"""
if
quiet
<
2
:
print
(
"parameters=
%
s"
%
(
str
(
parameters
)))
print
(
"parameters=
%
s"
%
(
str
(
parameters
)))
self
.
normalizeParameters
(
parameters
)
#isMask=False)
self
.
normalizeParameters
(
parameters
)
#isMask=False)
if
quiet
<
4
:
print
(
"normalized parameters=
%
s"
%
(
str
(
parameters
)))
print
(
"normalized parameters=
%
s"
%
(
str
(
parameters
)))
"""
"""
both ways work:
both ways work:
...
@@ -872,15 +895,16 @@ class X393LMA(object):
...
@@ -872,15 +895,16 @@ class X393LMA(object):
# self.parameterMask=self.normalizeParameters({},isMask=True)
# self.parameterMask=self.normalizeParameters({},isMask=True)
self
.
parameterMask
=
self
.
normalizeParameters
(
self
.
parameterMask
,
isMask
=
True
)
self
.
parameterMask
=
self
.
normalizeParameters
(
self
.
parameterMask
,
isMask
=
True
)
if
quiet
<
4
:
print
(
"parameters mask=
%
s"
%
(
str
(
self
.
parameterMask
)))
print
(
"parameters mask=
%
s"
%
(
str
(
self
.
parameterMask
)))
create_jacobian
=
True
create_jacobian
=
True
fxj
=
self
.
createFxAndJacobian
(
parameters
,
fxj
=
self
.
createFxAndJacobian
(
parameters
,
ywp
,
# keep in self.variable?
ywp
,
# keep in self.variable?
primary_set
,
primary_set
,
jacobian
=
create_jacobian
,
create_jacobian
,
parMask
=
None
,
None
,
#parMask
quiet
=
1
)
quiet
)
if
create_jacobian
:
if
create_jacobian
:
fx
=
fxj
[
'fx'
]
fx
=
fxj
[
'fx'
]
...
@@ -893,19 +917,12 @@ class X393LMA(object):
...
@@ -893,19 +917,12 @@ class X393LMA(object):
print
(
"
\n
fx (filtered):"
)
print
(
"
\n
fx (filtered):"
)
self
.
showYOrVector
(
ywp
,
True
,
fx
)
self
.
showYOrVector
(
ywp
,
True
,
fx
)
if
quiet
<
4
:
SX
=
0.0
arms
=
self
.
getParAvgRMS
(
parameters
,
SX2
=
0.0
ywp
,
S0
=
0.0
primary_set
,
# prima
for
d
,
w
in
zip
(
fx
,
ywp
[
'w'
]):
quiet
+
1
)
if
w
>
0
:
print
(
"average(fx)=
%
fps, rms(fx)=
%
fps"
%
(
arms
[
'avg'
],
arms
[
'rms'
]))
S0
+=
w
SX
+=
w
*
d
SX2
+=
w
*
d
*
d
avg
=
SX
/
S0
rms
=
math
.
sqrt
(
SX2
/
S0
)
print
(
"average(fx)=
%
fps, rms(fx)=
%
fps"
%
(
avg
,
rms
))
if
quiet
<
3
:
if
quiet
<
3
:
jByJT
=
np
.
dot
(
fxj
[
'jacob'
],
np
.
transpose
(
fxj
[
'jacob'
]))
jByJT
=
np
.
dot
(
fxj
[
'jacob'
],
np
.
transpose
(
fxj
[
'jacob'
]))
print
(
"
\n
jByJT:"
)
print
(
"
\n
jByJT:"
)
...
@@ -923,7 +940,7 @@ class X393LMA(object):
...
@@ -923,7 +940,7 @@ class X393LMA(object):
self
.
lambdas
,
self
.
lambdas
,
self
.
finalDiffRMS
,
self
.
finalDiffRMS
,
quiet
)
quiet
)
if
quiet
<
4
:
if
(
quiet
<
4
)
or
((
quiet
<
5
)
and
finished
)
:
arms
=
self
.
getParAvgRMS
(
parameters
,
arms
=
self
.
getParAvgRMS
(
parameters
,
ywp
,
ywp
,
primary_set
,
# prima
primary_set
,
# prima
...
@@ -941,8 +958,8 @@ class X393LMA(object):
...
@@ -941,8 +958,8 @@ class X393LMA(object):
ywp
,
# keep in self.variable?
ywp
,
# keep in self.variable?
primary_set
,
primary_set
,
False
,
False
,
parMask
=
None
,
None
,
quiet
=
1
)
quiet
)
if
quiet
<
3
:
if
quiet
<
3
:
print
(
"
\n
fx-postLMA:"
)
print
(
"
\n
fx-postLMA:"
)
...
@@ -976,6 +993,14 @@ class X393LMA(object):
...
@@ -976,6 +993,14 @@ class X393LMA(object):
else
:
else
:
print
(
"
%
d"
%
(
DQvDQS
[
enl
][
dly
][
b
]),
end
=
" "
)
print
(
"
%
d"
%
(
DQvDQS
[
enl
][
dly
][
b
]),
end
=
" "
)
print
()
print
()
rslt
=
{}
rslt_names
=
(
"early"
,
"nominal"
,
"late"
)
for
i
,
d
in
enumerate
(
DQvDQS
):
rslt
[
rslt_names
[
i
]]
=
d
return
rslt
# return DQvDQS
# Returns 3-element dictionary of ('early','nominal','late'), each being None or a 160-element list,
# each element being either None, or a list of 3 best DQ delay values for the DQS delay (some mey be None too)
def
getBestDQforDQS
(
self
,
def
getBestDQforDQS
(
self
,
...
@@ -1189,7 +1214,7 @@ class X393LMA(object):
...
@@ -1189,7 +1214,7 @@ class X393LMA(object):
if
d
>=
0
:
if
d
>=
0
:
dqs_delay32_index
[
i
]
=
dqs_delay32_en
[
d
]
dqs_delay32_index
[
i
]
=
dqs_delay32_en
[
d
]
print
(
"*****dqs_delay32_index="
,
dqs_delay32_index
)
#
print("*****dqs_delay32_index=",dqs_delay32_index)
dq_finedelay_en
=
[
None
]
*
8
dq_finedelay_en
=
[
None
]
*
8
for
b
in
range
(
8
):
for
b
in
range
(
8
):
...
@@ -1208,6 +1233,7 @@ class X393LMA(object):
...
@@ -1208,6 +1233,7 @@ class X393LMA(object):
dtdqs_dtFDQS
=
(
-
fineM5
[
0
][
dlyMod5
],
-
fineM5
[
1
][
dlyMod5
],
-
fineM5
[
2
][
dlyMod5
],
-
fineM5
[
3
][
dlyMod5
])
dtdqs_dtFDQS
=
(
-
fineM5
[
0
][
dlyMod5
],
-
fineM5
[
1
][
dlyMod5
],
-
fineM5
[
2
][
dlyMod5
],
-
fineM5
[
3
][
dlyMod5
])
dtdqs_dtDQSHL_rf
=
(
-
0.25
,
+
0.25
)
# ign opposite from: ir = ir0 - s/4 + d/4; or = or0 - s/4 - d/4, ... - NOT, but maybe other is wrong
dtdqs_dtDQSHL_rf
=
(
-
0.25
,
+
0.25
)
# ign opposite from: ir = ir0 - s/4 + d/4; or = or0 - s/4 - d/4, ... - NOT, but maybe other is wrong
#correct for DQS edge type
#correct for DQS edge type
# dbg=[0.0]*32
for
b
in
range
(
8
):
# use all 4 variants
for
b
in
range
(
8
):
# use all 4 variants
for
t
in
range
(
4
):
for
t
in
range
(
4
):
indx
=
32
*
dly
+
t
*
8
+
b
indx
=
32
*
dly
+
t
*
8
+
b
...
@@ -1223,9 +1249,10 @@ class X393LMA(object):
...
@@ -1223,9 +1249,10 @@ class X393LMA(object):
jacob
[
pIndx
,
indx
]
=-
dtdqs_dtFDQS
[
i
]
jacob
[
pIndx
,
indx
]
=-
dtdqs_dtFDQS
[
i
]
if
dqs_delay32_en
:
if
dqs_delay32_en
:
for
i
,
pIndx
in
enumerate
(
dqs_delay32_
en
):
for
i
,
pIndx
in
enumerate
(
dqs_delay32_
index
):
if
pIndx
>=
0
:
if
pIndx
>=
0
:
jacob
[
pIndx
,
indx
]
=
(
0
,
1.0
)[
i
==
dlyDiv5
]
jacob
[
pIndx
,
indx
]
=
(
0
,
1.0
)[
i
==
dlyDiv5
]
# dbg[i]+=jacob[pIndx,indx]
if
parInd
[
'tDQSHL'
]
>=
0
:
if
parInd
[
'tDQSHL'
]
>=
0
:
jacob
[
parInd
[
'tDQSHL'
],
indx
]
=-
dtdqs_dtDQSHL_rf
[
t
&
1
]
jacob
[
parInd
[
'tDQSHL'
],
indx
]
=-
dtdqs_dtDQSHL_rf
[
t
&
1
]
...
@@ -1249,7 +1276,7 @@ class X393LMA(object):
...
@@ -1249,7 +1276,7 @@ class X393LMA(object):
if
parInd
[
'anaScale'
]
>=
0
:
if
parInd
[
'anaScale'
]
>=
0
:
if
anaScale
and
not
isNone
(
y_fractions
[
indx
]):
if
anaScale
and
not
isNone
(
y_fractions
[
indx
]):
jacob
[
parInd
[
'anaScale'
],
indx
]
=-
y_fractions
[
indx
]
jacob
[
parInd
[
'anaScale'
],
indx
]
=-
y_fractions
[
indx
]
# print("dbg: %d: "%(dly),dbg)
return
{
'fx'
:
fx
,
'jacob'
:
jacob
}
return
{
'fx'
:
fx
,
'jacob'
:
jacob
}
def
getParAvgRMS
(
self
,
def
getParAvgRMS
(
self
,
parameters
,
parameters
,
...
...
py393/x393_mcntrl_adjust.py
View file @
3d603296
...
@@ -2042,9 +2042,19 @@ class X393McntrlAdjust(object):
...
@@ -2042,9 +2042,19 @@ class X393McntrlAdjust(object):
quiet
=
1
):
quiet
=
1
):
"""
"""
@scale_w weight for "uncertain" values (where samples chane from all 0 to all 1 in one step)
Run DQ vs DQS fitting for one data lane (0 or 1) using earlier acquired hard-coded data
@lane byte lane to process
@bin_size bin size for the histograms (should be 5/10/20/40)
@primary_set which of the data edge series to use as leading (other will be trailing by 180)
@data_set_number select one of the hard-coded data sets (sets 0 and 1 use comparing with the data 1 fine step below
set #2 (default) used measurement with previous primary step measurement (will not suffer from
fine range wider than on primary step)
@scale_w weight for "uncertain" values (where samples change from all 0 to all 1 in one step)
For sufficient data 0.0 is OK (and seems to work better)- only "analog" samples are considered
@return 3-element dictionary of ('early','nominal','late'), each being None or a 160-element list,
each element being either None, or a list of 3 best DQ delay values for the DQS delay (some mey be None too)
"""
"""
if
quiet
<
3
:
print
(
"proc_test_data(): scale_w=
%
f"
%
(
scale_w
))
print
(
"proc_test_data(): scale_w=
%
f"
%
(
scale_w
))
compare_prim_steps
=
get_test_dq_dqs_data
.
get_compare_prim_steps
(
data_set_number
)
compare_prim_steps
=
get_test_dq_dqs_data
.
get_compare_prim_steps
(
data_set_number
)
meas_data
=
get_test_dq_dqs_data
.
get_data
(
data_set_number
)
meas_data
=
get_test_dq_dqs_data
.
get_data
(
data_set_number
)
...
@@ -2054,14 +2064,6 @@ class X393McntrlAdjust(object):
...
@@ -2054,14 +2064,6 @@ class X393McntrlAdjust(object):
bits
=
[
None
]
*
16
bits
=
[
None
]
*
16
for
b
,
pData
in
enumerate
(
data
):
for
b
,
pData
in
enumerate
(
data
):
if
pData
:
if
pData
:
"""
bits[b]=[[None,None],[None,None]]
for inPhase in (0,1):
if pData[inPhase]:
for e in (0,1):
if pData[inPhase][e]:
bits[b][inPhase][e]=pData[inPhase][e][0]
"""
bits
[
b
]
=
[
None
]
*
4
bits
[
b
]
=
[
None
]
*
4
for
inPhase
in
(
0
,
1
):
for
inPhase
in
(
0
,
1
):
if
pData
[
inPhase
]:
if
pData
[
inPhase
]:
...
@@ -2072,8 +2074,7 @@ class X393McntrlAdjust(object):
...
@@ -2072,8 +2074,7 @@ class X393McntrlAdjust(object):
if
quiet
<
1
:
if
quiet
<
1
:
x393_lma
.
test_data
(
meas_delays
,
compare_prim_steps
,
quiet
)
x393_lma
.
test_data
(
meas_delays
,
compare_prim_steps
,
quiet
)
lma
=
x393_lma
.
X393LMA
()
lma
=
x393_lma
.
X393LMA
()
lma
.
init_parameters
(
return
lma
.
lma_fit
(
lane
,
lane
,
bin_size
,
bin_size
,
2500.0
,
# clk_period,
2500.0
,
# clk_period,
78.0
,
# dly_step_ds,
78.0
,
# dly_step_ds,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment