Commit 5fc79880 authored by Andrey Filippov's avatar Andrey Filippov

desting, debugging, cleaning up

parent 4aaf6074
......@@ -444,7 +444,8 @@ class X393McntrlAdjust(object):
phaseData=delays[phase]
phaseErrs=errors[phase]
if quiet <1:
print("phaseData=",phaseData)
print(phase,"--phaseData=",phaseData," ... highDelay=",highDelay," lowDelay=",lowDelay," list_branches=",list_branches)
# print("phaseErrs=",phaseErrs)
else:
try:
......@@ -457,10 +458,13 @@ class X393McntrlAdjust(object):
return None
if quiet <1:
print("phaseData=",phaseData)
print(phase,"phaseData=",phaseData," ... highDelay=",highDelay," lowDelay=",lowDelay," list_branches=",list_branches)
if phaseData is None:
return None
# print ("target=",target," phaseData=",phaseData )
"""
periods=phaseData.keys()
periods.sort() # can compare tuples (1-st is "more important")
......@@ -476,7 +480,24 @@ class X393McntrlAdjust(object):
for indx,branch in enumerate(periods): # if all elements are None
if all(v is None for v in phaseData[branch]):
periods.pop(indx)
"""
periods=set(phaseData.keys())
if maxErrPS:
for period in periods.copy():
if phaseErrs[period] > maxErrPS:
periods.remove(period)
if allGood:
for period in periods.copy():
if None in phaseData[period]:
periods.remove(period)
for period in periods.copy(): # if all elements are None
if all(v is None for v in phaseData[period]):
periods.remove(period)
periods=list(periods)
periods.sort() # can compare tuples (1-st is "more important")
# useBranch
# filter results
......@@ -500,7 +521,7 @@ class X393McntrlAdjust(object):
eff_errs=[phaseErrs[b]+(delay_cost*sum(d for d in phaseData[b] if not d is None)/sum(1 for d in phaseData[b] if not d is None)) for b in periods]
periods=[periods[eff_errs.index(min(eff_errs))]]
#Filter by low/high delays without minError mode
if len(periods)>1:
if len(periods)>1:
dl0_per=[phaseData[p][0] for p in periods] # only delay for line 0, but with same branch requirement this should be the same for all lines
if highDelay or lowDelay or not list_branches or return_error: # in list_branches mode - filter by low/high only if requested, for delays use low if not highDelay
periods=[periods[dl0_per.index((min,max)[highDelay](dl0_per))]]
......@@ -567,7 +588,7 @@ class X393McntrlAdjust(object):
try:
phase= self.adjustment_state['optimal_phase']
except:
raise Exception("Phase value is not provided and global;optimal phase is not defined")
raise Exception("Phase value is not provided and global optimal phase is not defined")
num_addr=vrlg.ADDRESS_NUMBER
num_banks=3
dly_steps=self.x393_mcntrl_timing.get_dly_steps()
......@@ -672,7 +693,7 @@ class X393McntrlAdjust(object):
if (k == CMDA_KEY) and ((not 'addr_odelay' in self.adjustment_state) or
(isinstance (filter_cmda,str) and (len(filter_cmda)>1) and (filter_cmda.upper()[0]=='S'))):
if quiet < 3:
print ("\n===== processing '%s' using self.adjustment_state['cmda_bspe']"%(k))
print ("\n------ processing '%s' using self.adjustment_state['cmda_bspe'], filter= %s"%(k,str(filters[k])))
try:
cmda_bspe=self.adjustment_state['cmda_bspe']
except:
......@@ -692,7 +713,7 @@ class X393McntrlAdjust(object):
delays[k]=cmda_bspe[phase]['ldly']
else:
if quiet < 3:
print ("\n===== processing '%s'"%(k))
print ("\n------ processing '%s', filter= %s"%(k,str(filters[k])))
if forgive_missing:
try:
delays[k]=self.get_delays_for_phase(phase = phase,
......@@ -732,6 +753,7 @@ class X393McntrlAdjust(object):
@param filter_dqo filter for DQS output delays,
@param quiet Reduce output
"""
"""
required_keys=('addr_odelay',
'dqi_phase_multi',
'dqi_phase_err',
......@@ -741,35 +763,90 @@ class X393McntrlAdjust(object):
'dqsi_phase_err',
'dqso_phase_multi',
'dqso_phase_err')
if not all (k in self.adjustment_state for k in required_keys):
print ("Running in simulation mode, using hardcoded data")
self.load_hardcoded_data()
self.proc_addr_odelay(True, 200.0, 4)
self.proc_dqsi_phase ('All', 50, 0, 0.0, 200, 3)
self.proc_dqso_phase ('All', 50, 0, 0.0, 200, 3)
"""
#temporarily:
self.load_mcntrl('dbg/x393_mcntrl.pickle')
# if not all (k in self.adjustment_state for k in required_keys):
# print ("Running in simulation mode, using hardcoded data")
# self.load_hardcoded_data()
# self.proc_addr_odelay(True, 200.0, 4)
# self.proc_dqsi_phase ('All', 50, 0, 0.0, 200, 3)
# self.proc_dqso_phase ('All', 50, 0, 0.0, 200, 3)
#datasheet step per average delay per finedelay step
all_groups_valid_only=False
if (isinstance(filter_variants,str)) : # currently - any string means "keep only phases that have all groups valid)
all_groups_valid_only=True
filter_variants=None
tSDQS=1000.0*self.x393_mcntrl_timing.get_dly_steps()['DLY_STEP']/NUM_FINE_STEPS
filters=dict(zip(SIG_LIST,[filter_cmda,filter_dqsi,filter_dqi,filter_dqso,filter_dqo]))
# filters={CMDA_KEY:filter_cmda,DQSI_KEY:filter_dqsi,DQI_KEY:filter_dqi,DQSO_KEY:filter_dqso,DQO_KEY:filter_dqo}
periods_phase={}
periods_all={}
for k in SIG_LIST:
if quiet < 3:
print ("\n===== processing '%s'"%(k))
if quiet < 2:
print ("\n===== processing '%s', filter= %s"%(k,str(filters[k])))
periods_phase[k]=self.get_delays_for_phase(phase = None,
list_branches=True,
target=k,
b_filter=filters[k],
#cost=NUM_FINE_STEPS,
quiet = quiet+2)
# quiet = quiet+2)
quiet = quiet+0)
numPhases=len(periods_phase[CMDA_KEY])
#Remove DQI and DQO branches that are referenced to non-existing (filtered out) DQSI/DQI
for phase in range (numPhases):# ,cmda,dqso,dqo, in zip(range(numPhases),cmda_vars,dqso_vars,dqo_vars):
if (DQI_KEY in periods_phase) and (DQSI_KEY in periods_phase):
fl=[]
if periods_phase[DQI_KEY][phase] is not None:
for variant in periods_phase[DQI_KEY][phase]:
if (not periods_phase[DQSI_KEY][phase] is None) and (variant[0] in periods_phase[DQSI_KEY][phase]):
fl.append(variant)
if fl:
periods_phase[DQI_KEY][phase]=fl
else:
periods_phase[DQI_KEY][phase]=None
if (DQO_KEY in periods_phase) and (DQSO_KEY in periods_phase):
if periods_phase[DQO_KEY][phase] is not None:
fl=[]
for variant in periods_phase[DQO_KEY][phase]:
if (not periods_phase[DQSO_KEY][phase] is None) and (variant[0] in periods_phase[DQSO_KEY][phase]):
fl.append(variant)
if fl:
periods_phase[DQO_KEY][phase]=fl
else:
periods_phase[DQO_KEY][phase]=None
if quiet < 2:
print ("all_groups_valid_only=",all_groups_valid_only)
if all_groups_valid_only:
for phase in range (numPhases):
for k in periods_phase:
if periods_phase[k][phase] is None:
for k in periods_phase:
periods_phase[k][phase]=None
break
if quiet < 2:
print("===== Filtered periods: =====")
for phase in range (numPhases):
print ("phase=%d"%(phase),end=" ")
for k in periods_phase:
print ("'%s':%s"%(k,str(periods_phase[k][phase])),end=" ")
print()
if not filter_variants is None:
strict= not ('all' in filter_variants)
if quiet < 3:
print ("filter_variants=",filter_variants)
for phase in range (numPhases):# ,cmda,dqso,dqo, in zip(range(numPhases),cmda_vars,dqso_vars,dqo_vars):
#build variants for each group that are used in at least one permitted combination of cmda, dqso, dqo, dqsi, dqi
# 'try' makes sure that all groups are not None (in that case just skip that phase value)
key_vars={}
for k in SIG_LIST:
key_vars[k]=set()
......@@ -777,32 +854,39 @@ class X393McntrlAdjust(object):
for cmda in periods_phase[CMDA_KEY][phase]:
for dqo in periods_phase[DQO_KEY][phase]:
for dqi in periods_phase[DQI_KEY][phase]:
print("phase=%d, (cmda,dqo,dqi)=%s"%(phase,str((cmda,dqo,dqi))))
if quiet < 3:
print("phase=%d, (cmda,dqo,dqi)=%s"%(phase,str((cmda,dqo,dqi))))
if (((cmda,dqo,dqi) in filter_variants) and
(dqo[0] in periods_phase[DQSO_KEY][phase]) and
(dqi[0] in periods_phase[DQSI_KEY][phase])):
for i,k in enumerate(SIG_LIST):
key_vars[k].add((cmda,dqi[0],dqi,dqo[0],dqo)[i]) #careful with the order
print("phase=%d, key_vars=%s"%(phase,str(key_vars))) # OK
if quiet < 2:
print("phase=%d, key_vars=%s"%(phase,str(key_vars))) # OK
for k in SIG_LIST:
for variant in periods_phase[k][phase]:
if not variant in key_vars[k]:
print ("variant % s is not in %s for %s"%(variant,str(key_vars[k]), str(k)))
if quiet < 3:
print ("phase=%d: variant %s is not in %s for %s, key_vars=%s . OK in when filtered by 'filter_variants'"%(phase,
variant,
str(key_vars[k]),
str(k),
str(key_vars)))
periods_phase[k][phase].pop(variant) # remove variants that do not fit in one of the combinations in filter_variants
print("periods_phase[%s][phase]=%s, strict=%s"%(str(k),str(periods_phase[k][phase]),str(strict)))
if strict and (not periods_phase[k][phase]):
print("empty")
raise Exception('Just get to except')
if quiet <2:
print("periods_phase[%s][phase]=%s, strict=%s"%(str(k),str(periods_phase[k][phase]),str(strict)))
assert (periods_phase[k][phase] or (not strict))
except:
for k in SIG_LIST:
print("except %s"%str(k))
if quiet <2:
print("except %s"%str(k))
periods_phase[k][phase]=None
for phase in range (numPhases):
print ("phase= %d"%(phase), end=" ")
for k in SIG_LIST:
print ("%s"%(periods_phase[k][phase]), end=" ")
print()
if quiet <2:
for phase in range (numPhases):
print ("phase= %d"%(phase), end=" ")
for k in SIG_LIST:
print ("%s"%(periods_phase[k][phase]), end=" ")
print()
for k in SIG_LIST:
periods_all[k]=set()
for lp in periods_phase[k]:
......@@ -858,7 +942,8 @@ class X393McntrlAdjust(object):
print ("%d"%(phase),end=" ")
for k in SIG_LIST:
for period in periods_all[k]:
if not periods_phase[k][phase] is None:
if (not periods_phase[k][phase] is None) and (period in periods_phase[k][phase]):
# print("<<",k,"::",periods_phase[k][phase],":",period,">>>")
data_group=self.get_delays_for_phase(phase = phase,
list_branches=False,
target=k,
......@@ -875,7 +960,7 @@ class X393McntrlAdjust(object):
for k in [CMDA_KEY,DQSI_KEY,DQSO_KEY]:
for period in periods_all[k]:
if not periods_phase[k][phase] is None:
if (not periods_phase[k][phase] is None) and (period in periods_phase[k][phase]):
err_ps=self.get_delays_for_phase(phase = phase,
list_branches='Err',
target=k,
......@@ -3693,17 +3778,113 @@ class X393McntrlAdjust(object):
self.x393_pio_sequences.set_write_lev(16,False) # write leveling - 'good' mode (if it was not set so)
return cmd_odelay
def _map_varinats(self,
list_variants):
def _map_variants(self,
list_variants,
var_template):
"""
@param list_variants list of sets of variants - for each variant find the longest steak (rolls over the end of the list)
Each item of a set should be a tuple of integers(cmda)/pairs of integers(dqi and dqo)
dqi/dqo tuple consists of reference dqsi/dqso branch (signed int) and a relative shift to it (negative - earlier,
positive - later)
@param var_template - a tuple of the same number of elements as each variant in a set, of boolean: True (cmda,dqso, dqo) - add 1 when crossing
from last to 0, False (dqi,dqsi) - subtract
@return dictionary with keys - variants, and values - tuples of starts and lengths of the longest streak
"""
l=len(list_variants)
streaks={}
prev_vars=list_variants[l-1]
map_all=self._map_variants_all(list_variants=list_variants,
var_template=var_template)
result={}
for k,v in map_all.items():
lengths=[sl[1] for sl in v]
result[k]= v[lengths.index(max(lengths))]
# print ("map_all=",map_all)
# print ("result=",result)
return result
def _map_variants_all(self,
list_variants,
var_template):
"""
@param list_variants list of sets of variants - for each variant find the longest steak (rolls over the end of the list)
Each item of a set should be a tuple of integers(cmda)/pairs of integers(dqi and dqo)
dqi/dqo tuple consists of reference dqsi/dqso branch (signed int) and a relative shift to it (negative - earlier,
positive - later)
@param var_template - a tuple of the same number of elements as each variant in a set, of boolean: True (cmda,dqso, dqo) - add 1 when crossing
from last to 0, False (dqi,dqsi) - subtract
@return dictionary with keys - variants, and values - list of tuples (usually just one element) of starts and lengths of the longest streak
"""
numPhases=len(list_variants)
falling_signs=tuple([(-1,1)[i] for i in var_template])
# for each variant (key) a list of (start,len,(this_start,this_end))
# start - start of this steak, possibly rolling through 0, len - length of this streak (rolling over
# this start - start of this streak not crossing 0, this_end - last+1 - not crossing len
streaks={}
prev_vars=set()
all_variants=set()
# First - process phase=0, all the rest will have starts
def check_extrapolated_var_to_phase(phase,variant):
extrapolated_variant=variant
periods = phase // numPhases
if periods != 0:
extrapolated_variant = []
for falling,item_var in zip(falling_signs,variant):
if isinstance(item_var,tuple):
extrapolated_variant.append((item_var[0]+falling*periods,item_var[1]))
else:
extrapolated_variant.append(item_var+falling*periods)
extrapolated_variant=tuple(extrapolated_variant)
try:
# print("check_extrapolated_var_to_phase(%d,%s ==> %s)"%(phase,str(variant),str(extrapolated_variant in list_variants[phase % numPhases])))
return extrapolated_variant in list_variants[phase % numPhases]
except:
# print("check_extrapolated_var_to_phase(%d,%s) - was None"%(phase,str(variant)))
return False # was None
# periods= phase // numPhases
# p_phase=phase % numPhases
for phase, variants in enumerate(list_variants):
if variants:
all_variants |= variants
new_vars = variants - prev_vars
for new_var in new_vars:
# First - process phase=0, all the rest will have starts
if phase==0:
s_phase = phase
while check_extrapolated_var_to_phase(s_phase-1,new_var):
s_phase -= 1
else:
s_phase=phase
# now s_phase >=0 for phase>0 or <= 0 for phase=0
# find the end of the streak
e_phase=phase+1
while check_extrapolated_var_to_phase(e_phase,new_var):
e_phase += 1
# print(".... phase=%d, s_phase=%d, e_phase=%d"%(phase, s_phase, e_phase))
if not new_var in streaks:
streaks[new_var]=[]
streaks[new_var].append((s_phase % numPhases, e_phase-s_phase))
"""
for streak_len in range(1,numPhases):
if (list_variants[(s_phase+streak_len) % numPhases] is None) or (not new_var in list_variants[(s_phase+streak_len) % numPhases]):
if (not new_var in streaks) or (streaks[new_var][1]<streak_len):
streaks[new_var]=(s_phase,streak_len)
break
"""
else:
variants=set()
prev_vars=variants
return streaks
"""
prev_vars=list_variants[numPhases-1]
all_variants=set()
for s_phase, variants in enumerate(list_variants):
if variants:
......@@ -3713,8 +3894,8 @@ class X393McntrlAdjust(object):
else:
new_vars = variants
for new_var in new_vars:
for streak_len in range(1,l):
if (list_variants[(s_phase+streak_len) % l] is None) or (not new_var in list_variants[(s_phase+streak_len) % l]):
for streak_len in range(1,numPhases):
if (list_variants[(s_phase+streak_len) % numPhases] is None) or (not new_var in list_variants[(s_phase+streak_len) % numPhases]):
if (not new_var in streaks) or (streaks[new_var][1]<streak_len):
streaks[new_var]=(s_phase,streak_len)
break
......@@ -3723,9 +3904,9 @@ class X393McntrlAdjust(object):
# check if a variant is available everywher (should not be the case in this application)
for v in all_variants:
if not v in streaks:
streaks[v]=(0,l) # all length, starting from 0
streaks[v]=(0,numPhases) # all length, starting from 0
return streaks
"""
def set_read_branch(self,
......@@ -3743,7 +3924,7 @@ class X393McntrlAdjust(object):
if the remaining number of errors is odd
"""
#temporarily:
# self.load_mcntrl('dbg/proc_addr_odelay_0x55.pickle')
# self.load_mcntrl('dbg/x393_mcntrl.pickle')
if wbuf_dly is None:
wbuf_dly=vrlg.DFLT_WBUF_DELAY
......@@ -3804,15 +3985,41 @@ class X393McntrlAdjust(object):
for phase, v in enumerate(read_phase_variants):
print("%d: %s"%(phase,str(v)))
variants_map=self._map_varinats(read_phase_variants)
variants_map=self._map_variants(list_variants=read_phase_variants,
var_template=(True,False))
centers={}
skipped_centers=set() # just for debugging
used_centers=set() # just for debugging
data_shifts={}
for k,v in variants_map.items():
centers[k]=(v[0]+v[1]//2) % numPhases
data_shifts[k]=k[1][1]-k[1][0]-k[0]
center_phase=(v[0]+v[1]//2) % numPhases
if k in read_phase_variants[center_phase]:
centers[k]=center_phase
used_centers.add(center_phase)
else:
skipped_centers.add(center_phase)
if quiet < 2:
print ("center phase = %d for variant %s is not in read_phase_variants[%d]=%s"%(center_phase,
str(k),
center_phase,
str(read_phase_variants[center_phase])))
print ("It should be listed for some other variant")
if quiet < 3:
print ("variants_map=",variants_map)
print ("centers=",centers)
print ("used_centers=",used_centers)
print ("skipped_centers=",skipped_centers)
print ('data_shifts=',data_shifts)
if skipped_centers - used_centers:
print ("Some skipped centers %s are not listed for other variants %s, variants_map=%s)"%(str(skipped_centers),
str(used_centers),
str(variants_map)))
raise Exception("BUG: Some skipped centers %s are not listed for other variants")
# print ("**** REMOVE THIS RETURN ****")
# return
# some different varinats are actually the same when they roll over phases TODO: merge them
......@@ -3874,6 +4081,7 @@ class X393McntrlAdjust(object):
cost=None,
refresh=True,
forgive_missing=False,
# quiet=quiet+1)
quiet=quiet+1)
if used_delays is None:
raise Exception("set_read_branch(): failed to set phase = %d"%(phase))
......@@ -3885,12 +4093,13 @@ class X393McntrlAdjust(object):
read_problems=None
for _ in range(20): # limit numer of repetiotions - just in case
self.x393_mcntrl_timing.axi_set_wbuf_delay(wdly)
read_problems=self.x393_pio_sequences. set_and_read_inc(num8=8, # max 512 16-bit words
ca=ca+16,
ra=ra,
ba=ba,
sel=rsel,
quiet=quiet+1)
read_results = self.x393_pio_sequences. set_and_read_inc(num8=8, # max 512 16-bit words
ca=ca+16,
ra=ra,
ba=ba,
sel=rsel,
quiet=quiet+1)
read_problems=read_results[:2]
if (read_problems[0]>=4) or ((rsel==0) and (read_problems[0]>=2)):
if last_wstep < 0:
if quiet < 1:
......@@ -3931,12 +4140,32 @@ class X393McntrlAdjust(object):
if sum(read_problems_min) > 0:
for dw,sel in ((-1,0),(-1,1),(0,0),(0,1),(1,0),(1,1)):
self.x393_mcntrl_timing.axi_set_wbuf_delay(wdly+dw)
read_problems=self.x393_pio_sequences. set_and_read_inc(num8=8, # max 512 16-bit words
ca=ca+16,
ra=ra,
ba=ba,
sel=sel ^ rsel,
quiet=quiet+1)
read_results = self.x393_pio_sequences. set_and_read_inc(num8=8, # max 512 16-bit words
ca=ca+16,
ra=ra,
ba=ba,
sel=sel ^ rsel,
# quiet=quiet+1)
quiet=quiet+1)
read_problems=read_results[:2]
shft=(read_results[2] & 0x1ff)-16-read_results[3]
if quiet < 2:
print("=== Variant=%s, phase=%d sel=%d wbuf=%d : shift=%d, Read_problems=%s"%(str(variant),
phase,
sel ^ rsel,
wdly+dw,
str(read_problems)))
if quiet < 3:
measured_shift= 4*(wdly+dw) - shft - 2* (sel ^ rsel)
#variant=(-1, (0, 0)), calculated shift=1, measured shift=34, cal-meas=-32 shift=0 sel=1 wdly=9 sw=17
print ("variant=%s, calculated shift=%d (clocks), measured shift=%d(words), cal-meas=%d(words), problems=%s"%(
str(variant),
data_shifts[variant],
measured_shift,
2*data_shifts[variant]-measured_shift,
str(read_problems)))
if sum(read_problems) < sum(read_problems_min):
read_problems_min=read_problems
best_dw,best_sel= dw,sel
......@@ -3949,6 +4178,7 @@ class X393McntrlAdjust(object):
print("-wdly=",wdly)
print("-rsel=",rsel)
print("-sum(read_problems_min)=",sum(read_problems_min))
print(" shift = ", (read_results[2] & 0x1ff)-16-read_results[3])
if sum(read_problems_min) ==0:
rslt[variant]={'wbuf_dly':wdly, 'sel':rsel}
......@@ -4002,7 +4232,7 @@ class X393McntrlAdjust(object):
if the remaining number of errors is odd
"""
#temporarily:
#self.load_mcntrl('dbg/proc_addr_odelay_0x55.pickle')
# self.load_mcntrl('dbg/x393_mcntrl.pickle')
#write/used block parameters
startValue=0
num8=8 # 8 bursts to read/write
......@@ -4041,7 +4271,8 @@ read_variants= {(-1, (0, 0)): {'sel': 1, 'wbuf_dly': 9},
if not read_var_set:
raise Exception ("No valid read variant is found, can not proceed with write setup")
if quiet <2:
print ("read_var_set=",read_var_set)
cmda_vars= self.get_delays_for_phase(phase = None,
list_branches=True,
target=CMDA_KEY,
......@@ -4103,7 +4334,8 @@ read_variants= {(-1, (0, 0)): {'sel': 1, 'wbuf_dly': 9},
print("%d: %s"%(phase,str(v)))
#variant - just for writing
write_only_map=self._map_varinats(write_phase_variants)
write_only_map=self._map_variants(list_variants=write_phase_variants,
var_template=(True,True))
if quiet < 3:
print ("write_only_map=",write_only_map)
......@@ -4134,7 +4366,8 @@ read_variants= {(-1, (0, 0)): {'sel': 1, 'wbuf_dly': 9},
print("%d: %s"%(phase,str(v)))
#read/write variants
read_write_map=self._map_varinats(read_write_variants)
read_write_map=self._map_variants(list_variants=read_write_variants,
var_template=(True,True,False))
if quiet < 3:
print ("read_write_map=",read_write_map)
......@@ -4165,17 +4398,20 @@ read_variants= {(-1, (0, 0)): {'sel': 1, 'wbuf_dly': 9},
'dqo': k_rw[1],
'dqso': k_rw[1][0],
'read_phase': phase,
'write_phase': phase}
'write_phase': phase,
'rel_sel':k_wo[0]+k_wo[1][1]-k_wo[1][0]}
break
else:
raise Exception("failed") # just to get to "except"
raise Exception("failed") # just assert
except:
phase=(write_only_map[k_wo][0]+read_write_map[k_wo][1]//2)% numPhases
write_settings[k_wo]={'cmda_write': k_wo[0],
'dqo': k_wo[1],
'dqso': k_wo[1][0],
'write_phase': phase}
'write_phase': phase,
'rel_sel':k_wo[0]+k_wo[1][1]-k_wo[1][0]}
write_settings[k_wo].update(default_read)
#rel_sel has a constant shift to wsel - this can be used to reduce number of measurements and/or verify consistency
if quiet < 3:
print ("write_settings=",write_settings)
"""
......@@ -4218,6 +4454,8 @@ write_settings= {
'dqi': (0, 0)}}
"""
# print ("**** REMOVE THIS RETURN ****")
# return
odd_list=[]
for write_variant_key, variant in write_settings.items():
......@@ -4267,12 +4505,13 @@ write_settings= {
raise Exception("set_write_branch(): failed to set phase = %d"%(phase))
#set wbuf delay
self.x393_mcntrl_timing.axi_set_wbuf_delay(readVars[(variant['cmda_read'],variant['dqi'])]['wbuf_dly'])
problems=self.x393_pio_sequences. set_and_read_inc(num8=num8, # max 512 16-bit words
read_results = self.x393_pio_sequences. set_and_read_inc(num8=num8, # max 512 16-bit words
ca=ca,
ra=ra,
ba=ba,
sel=readVars[(variant['cmda_read'],variant['dqi'])]['sel'],
quiet=quiet+1)
problems=read_results[:2]
if (problems_min is None) or (sum(problems) < sum(problems_min)):
problems_min=problems
best_wsel=wsel
......@@ -4302,11 +4541,11 @@ write_settings= {
def get_phase_range(self,
rsel=None, # None (any) or 0/1
wsel=None, # None (any) or 0/1
cmda_filter=None,
dqsi_filter=None,
dqi_filter= None,
dqso_filter=None,
dqo_filter= None,
filter_cmda=None,
filter_dqsi=None,
filter_dqi= None,
filter_dqso=None,
filter_dqo= None,
set_globals=True,
quiet=1):
"""
......@@ -4319,17 +4558,15 @@ write_settings= {
"""
#temporarily:
# self.load_mcntrl('dbg/proc_addr_odelay_0x55.pickle')
if cmda_filter is None:
cmda_filter = DFLT_DLY_FILT
if dqsi_filter is None:
dqsi_filter = DFLT_DLY_FILT
if dqi_filter is None:
dqi_filter = DFLT_DLY_FILT
if dqso_filter is None:
dqso_filter = DFLT_DLY_FILT
if dqo_filter is None:
dqo_filter = DFLT_DLY_FILT
# self.load_mcntrl('dbg/x393_mcntrl.pickle')
filters=dict(zip(SIG_LIST,[filter_cmda,filter_dqsi,filter_dqi,filter_dqso,filter_dqo]))
for k,v in filters.items():
if v is None:
filters[k]=DFLT_DLY_FILT
elif not isinstance (filters[k],(tuple,list)):
filters[k]=[filters[k]]
elif isinstance (filters[k],tuple):
filters[k]=list(filters[k]) # tuple not OK as it will be merged
try:
read_variants=self.adjustment_state['read_variants']
......@@ -4339,6 +4576,7 @@ write_settings= {
write_variants=self.adjustment_state['write_variants']
except:
write_variants=None
try:
dqs_pattern=self.adjustment_state["dqs_pattern"]
except:
......@@ -4370,31 +4608,31 @@ write_settings= {
cmda_vars= self.get_delays_for_phase(phase = None,
list_branches=True,
target=CMDA_KEY,
b_filter=cmda_filter,
b_filter=filters[CMDA_KEY],
cost=None, # if None - will default to NUM_FINE_STEPS, if 0 - will keep it
quiet = quiet+2)
dqsi_vars= self.get_delays_for_phase(phase = None,
list_branches=True,
target=DQSI_KEY,
b_filter=dqsi_filter,
b_filter=filters[DQSI_KEY],
cost=None, # if None - will default to NUM_FINE_STEPS, if 0 - will keep it
quiet = quiet+2)
dqi_vars= self.get_delays_for_phase(phase = None,
list_branches=True,
target=DQI_KEY,
b_filter=dqi_filter,
b_filter=filters[DQI_KEY],
cost=None, # if None - will default to NUM_FINE_STEPS, if 0 - will keep it
quiet = quiet+2)
dqso_vars= self.get_delays_for_phase(phase = None,
list_branches=True,
target=DQSO_KEY,
b_filter=dqso_filter,
b_filter=filters[DQSO_KEY],
cost=None, # if None - will default to NUM_FINE_STEPS, if 0 - will keep it
quiet = quiet+2)
dqo_vars= self.get_delays_for_phase(phase = None,
list_branches=True,
target=DQO_KEY,
b_filter=dqo_filter,
b_filter=filters[DQO_KEY],
cost=None, # if None - will default to NUM_FINE_STEPS, if 0 - will keep it
quiet = quiet+2)
numPhases=len(cmda_vars)
......@@ -4427,9 +4665,16 @@ write_settings= {
if quiet < 3:
print ("all_variants=",all_variants)
varints_map=self._map_varinats(all_variants)
varints_map=self._map_variants(list_variants=all_variants,
var_template=(True,True,False))
if quiet < 3: