Commit 9326e242 authored by Andrey Filippov's avatar Andrey Filippov

debugging

parent 27a6599b
...@@ -89,7 +89,7 @@ def extractTasks(obj,inst): ...@@ -89,7 +89,7 @@ def extractTasks(obj,inst):
func_args=obj.__dict__[name].func_code.co_varnames[1:obj.__dict__[name].func_code.co_argcount] func_args=obj.__dict__[name].func_code.co_varnames[1:obj.__dict__[name].func_code.co_argcount]
callableTasks[name]={'func':obj.__dict__[name],'args':func_args,'inst':inst,'docs':inspect.getdoc(obj.__dict__[name])} callableTasks[name]={'func':obj.__dict__[name],'args':func_args,'inst':inst,'docs':inspect.getdoc(obj.__dict__[name])}
def execTask(commandLine): def execTask(commandLine):
# result=None result=None
cmdList=commandLine #.split() cmdList=commandLine #.split()
try: try:
funcName=cmdList[0] funcName=cmdList[0]
...@@ -106,6 +106,7 @@ def execTask(commandLine): ...@@ -106,6 +106,7 @@ def execTask(commandLine):
result = callableTasks[funcName]['func'](callableTasks[funcName]['inst'],*funcArgs) result = callableTasks[funcName]['func'](callableTasks[funcName]['inst'],*funcArgs)
except Exception as e: except Exception as e:
print ('Error while executing %s %s'%(funcName,str(funcArgs))) print ('Error while executing %s %s'%(funcName,str(funcArgs)))
print ("QUIET=%d"%QUIET)
try: try:
funcFArgs= callableTasks[funcName]['args'] funcFArgs= callableTasks[funcName]['args']
except: except:
...@@ -139,7 +140,7 @@ def getFuncArgsString(name): ...@@ -139,7 +140,7 @@ def getFuncArgsString(name):
def main(argv=None): # IGNORE:C0111 def main(argv=None): # IGNORE:C0111
'''Command line options.''' '''Command line options.'''
global QUIET
if argv is None: if argv is None:
argv = sys.argv argv = sys.argv
else: else:
...@@ -187,7 +188,11 @@ USAGE ...@@ -187,7 +188,11 @@ USAGE
# Process arguments # Process arguments
args = parser.parse_args() args = parser.parse_args()
QUIET = args.exceptions == 0 if not args.exceptions:
args.exceptions=0
QUIET = (1,0)[args.exceptions]
# print ("args.exception=%d, QUIET=%d"%(args.exceptions,QUIET))
if not args.simulated: if not args.simulated:
if not os.path.exists("/dev/xdevcfg"): if not os.path.exists("/dev/xdevcfg"):
args.simulated=True args.simulated=True
...@@ -315,11 +320,13 @@ USAGE ...@@ -315,11 +320,13 @@ USAGE
extractTasks(x393_mcntrl_tests.X393McntrlTests,x393Tests) extractTasks(x393_mcntrl_tests.X393McntrlTests,x393Tests)
# #
"""
if verbose > 3: if verbose > 3:
funcName="read_mem" funcName="read_mem"
funcArgs=[0x377,123] funcArgs=[0x377,123]
print ('==== testing function : '+funcName+str(funcArgs)+' ====') print ('==== testing function : '+funcName+str(funcArgs)+' ====')
# execTask(commandLine) # execTask(commandLine)
try: try:
callableTasks[funcName]['func'](callableTasks[funcName]['inst'],*funcArgs) callableTasks[funcName]['func'](callableTasks[funcName]['inst'],*funcArgs)
except Exception as e: except Exception as e:
...@@ -332,7 +339,7 @@ USAGE ...@@ -332,7 +339,7 @@ USAGE
sFuncArgs+=' <'+str(a)+'>' sFuncArgs+=' <'+str(a)+'>'
print ("Usage:\n%s %s"%(funcName,sFuncArgs)) print ("Usage:\n%s %s"%(funcName,sFuncArgs))
print ("exception message:"+str(e)) print ("exception message:"+str(e))
"""
for cmdLine in commands: for cmdLine in commands:
print ('Running task: '+str(cmdLine)) print ('Running task: '+str(cmdLine))
rslt= execTask(cmdLine) rslt= execTask(cmdLine)
...@@ -354,6 +361,8 @@ USAGE ...@@ -354,6 +361,8 @@ USAGE
sFuncArgs=getFuncArgsString(name) sFuncArgs=getFuncArgsString(name)
print ("Usage: %s %s"%(name,sFuncArgs)) print ("Usage: %s %s"%(name,sFuncArgs))
print ('\n"parameters" and "defines" list known defined parameters and macros') print ('\n"parameters" and "defines" list known defined parameters and macros')
print ("args.exception=%d, QUIET=%d"%(args.exceptions,QUIET))
elif (len(line) > len("help")) and (line[:len("help")]=='help'): elif (len(line) > len("help")) and (line[:len("help")]=='help'):
helpFilter=line[len('help'):].strip() helpFilter=line[len('help'):].strip()
try: try:
......
...@@ -65,30 +65,39 @@ def getParWidthLo(bitRange): ...@@ -65,30 +65,39 @@ def getParWidthLo(bitRange):
return (32,0) return (32,0)
else: else:
try: try:
# print(">>bitRange=%s"%bitRange,end=" ")
if bitRange[0] != '[': if bitRange[0] != '[':
# print("\nbitRange[0]=%s"%(bitRange[0]))
return None # may also fail through except if bitRange="" return None # may also fail through except if bitRange=""
startPosHi=1 startPosHi=1
endPosHi=bitRange.index(':') endPosHi=bitRange.index(':')
startPosLo=endPosHi+1 startPosLo=endPosHi+1
endPosLo=bitRange.index(']') endPosLo=bitRange.index(']')
# print("startPosHi=%d, endPosHi=%d, startPosLo=%d, endPosLo=%d"%(startPosHi,endPosHi,startPosLo,endPosLo))
if endPosHi<0: if endPosHi<0:
endPosHi=endPosLo endPosHi=endPosLo
startPosLo=-1 startPosLo=-1
except: except:
return None return None
# print("1: startPosHi=%d, endPosHi=%d, startPosLo=%d, endPosLo=%d"%(startPosHi,endPosHi,startPosLo,endPosLo))
if endPosHi <0: if endPosHi <0:
return None # no ":" or terminating "]" return None # no ":" or terminating "]"
loBit=0 loBit=0
try: try:
if startPosLo >0: if startPosLo > 0:
loBit=int(bitRange[startPosLo,endPosLo]) # print("2. startPosHi=%d, endPosHi=%d, startPosLo=%d, endPosLo=%d"%(startPosHi,endPosHi,startPosLo,endPosLo))
width=int(bitRange[startPosHi,endPosHi])-loBit+1 # print("bitRange[startPosLo,endPosLo]=%s"%(bitRange[startPosLo:endPosLo]))
# print("bitRange[startPosHi,endPosHi]=%s"%(bitRange[startPosHi:endPosHi]))
loBit=int(bitRange[startPosLo:endPosLo])
width=int(bitRange[startPosHi:endPosHi])-loBit+1
return (width,loBit) return (width,loBit)
except: except:
return None # could not parse: undefined width return None # could not parse: undefined width
def getParWidth(bitRange): def getParWidth(bitRange):
wl=getParWidthLo(bitRange) wl=getParWidthLo(bitRange)
print("\n***wl=%s, bitRange=%s"%(str(wl),str(bitRange)))
# print("bitRange=%s wl=%s"%(bitRange,str(wl))) # print("bitRange=%s wl=%s"%(bitRange,str(wl)))
if not wl: if not wl:
return None return None
......
...@@ -83,13 +83,13 @@ class X393McntrlTests(object): ...@@ -83,13 +83,13 @@ class X393McntrlTests(object):
<chn_reset>): immediately reset all the internal circuitry <chn_reset>): immediately reset all the internal circuitry
""" """
return concat ( return concat ((
((0,1)[byte32], 1), # byte32, ((0,1)[byte32], 1), # byte32,
((0,1)[keep_open],1), # keep_open, ((0,1)[keep_open],1), # keep_open,
(extra_pages, 2), # extra_pages, (extra_pages, 2), # extra_pages,
((0,1)[write_mem],1), # write_mem, ((0,1)[write_mem],1), # write_mem,
((0,1)[enable], 1), #enable, ((0,1)[enable], 1), #enable,
((1,0)[chn_reset],1)) # ~chn_reset}; ((1,0)[chn_reset],1)))# ~chn_reset};
def func_encode_mode_scanline(self, # function [4:0] def func_encode_mode_scanline(self, # function [4:0]
extra_pages, # input [1:0] extra_pages; # number of extra pages that need to stay (not to be overwritten) in the buffer extra_pages, # input [1:0] extra_pages; # number of extra pages that need to stay (not to be overwritten) in the buffer
...@@ -112,7 +112,7 @@ class X393McntrlTests(object): ...@@ -112,7 +112,7 @@ class X393McntrlTests(object):
((0,1)[enable], 1), #enable, ((0,1)[enable], 1), #enable,
((1,0)[chn_reset],1)) # ~chn_reset}; ((1,0)[chn_reset],1)) # ~chn_reset};
def task_set_up(self, def task_set_up(self,
set_per_pin_delays): set_per_pin_delays=0):
""" """
Initial setup of the memory controller, including: Initial setup of the memory controller, including:
tristate patterns tristate patterns
...@@ -545,18 +545,18 @@ class X393McntrlTests(object): ...@@ -545,18 +545,18 @@ class X393McntrlTests(object):
self.x393_axi_tasks.write_contol_register(start_addr + self.MCNTRL_TILED_FRAME_FULL_WIDTH, self.x393_axi_tasks.write_contol_register(start_addr + self.MCNTRL_TILED_FRAME_FULL_WIDTH,
self.FRAME_FULL_WIDTH) self.FRAME_FULL_WIDTH)
self.x393_axi_tasks.write_contol_register(start_addr + self.MCNTRL_TILED_WINDOW_WH, self.x393_axi_tasks.write_contol_register(start_addr + self.MCNTRL_TILED_WINDOW_WH,
concat((window_height,16), concat(((window_height,16),
(window_width, 16))) # {window_height,window_width}); (window_width, 16)))) # {window_height,window_width});
self.x393_axi_tasks.write_contol_register(start_addr + self.MCNTRL_TILED_WINDOW_X0Y0, self.x393_axi_tasks.write_contol_register(start_addr + self.MCNTRL_TILED_WINDOW_X0Y0,
concat((window_top, 16), concat(((window_top, 16),
(window_left, 16))) # {window_top,window_left}); (window_left, 16)))) # {window_top,window_left});
self.x393_axi_tasks.write_contol_register(start_addr + self.MCNTRL_TILED_WINDOW_STARTXY, self.x393_axi_tasks.write_contol_register(start_addr + self.MCNTRL_TILED_WINDOW_STARTXY,
concat((self.TILED_STARTY, 16), concat(((self.TILED_STARTY, 16),
(self.TILED_STARTX, 16))) # TILED_STARTX+(TILED_STARTY<<16)); (self.TILED_STARTX, 16)))) # TILED_STARTX+(TILED_STARTY<<16));
self.x393_axi_tasks.write_contol_register(start_addr + self.MCNTRL_TILED_TILE_WHS, self.x393_axi_tasks.write_contol_register(start_addr + self.MCNTRL_TILED_TILE_WHS,
concat((tile_vstep, 8), concat(((tile_vstep, 8),
(tile_height, 8), (tile_height, 8),
(tile_width, 8))) # {8'b0,tile_vstep,tile_height,tile_width});#tile_width+(tile_height<<8)+(tile_vstep<<16)); (tile_width, 8)))) # {8'b0,tile_vstep,tile_height,tile_width});#tile_width+(tile_height<<8)+(tile_vstep<<16));
self.x393_axi_tasks.write_contol_register(start_addr + self.MCNTRL_TILED_MODE, mode);# set mode register: {extra_pages[1:0],enable,!reset} self.x393_axi_tasks.write_contol_register(start_addr + self.MCNTRL_TILED_MODE, mode);# set mode register: {extra_pages[1:0],enable,!reset}
self.x393_axi_tasks.configure_channel_priority(channel,0) # lowest priority channel 3 self.x393_axi_tasks.configure_channel_priority(channel,0) # lowest priority channel 3
self.x393_axi_tasks.enable_memcntrl_en_dis(channel,1); self.x393_axi_tasks.enable_memcntrl_en_dis(channel,1);
...@@ -672,18 +672,18 @@ class X393McntrlTests(object): ...@@ -672,18 +672,18 @@ class X393McntrlTests(object):
self.x393_axi_tasks.write_contol_register(start_addr + self.MCNTRL_TILED_FRAME_FULL_WIDTH, self.x393_axi_tasks.write_contol_register(start_addr + self.MCNTRL_TILED_FRAME_FULL_WIDTH,
self.FRAME_FULL_WIDTH) self.FRAME_FULL_WIDTH)
self.x393_axi_tasks.write_contol_register(start_addr + self.MCNTRL_TILED_WINDOW_WH, self.x393_axi_tasks.write_contol_register(start_addr + self.MCNTRL_TILED_WINDOW_WH,
concat((window_height,16), concat(((window_height,16),
(window_width, 16))) # {window_height,window_width}); (window_width, 16)))) # {window_height,window_width});
self.x393_axi_tasks.write_contol_register(start_addr + self.MCNTRL_TILED_WINDOW_X0Y0, self.x393_axi_tasks.write_contol_register(start_addr + self.MCNTRL_TILED_WINDOW_X0Y0,
concat((window_top, 16), concat(((window_top, 16),
(window_left, 16))) # {window_top,window_left}); (window_left, 16)))) # {window_top,window_left});
self.x393_axi_tasks.write_contol_register(start_addr + self.MCNTRL_TILED_WINDOW_STARTXY, self.x393_axi_tasks.write_contol_register(start_addr + self.MCNTRL_TILED_WINDOW_STARTXY,
concat((self.TILED_STARTY, 16), concat(((self.TILED_STARTY, 16),
(self.TILED_STARTX, 16))) # TILED_STARTX+(TILED_STARTY<<16)); (self.TILED_STARTX, 16)))) # TILED_STARTX+(TILED_STARTY<<16));
self.x393_axi_tasks.write_contol_register(start_addr + self.MCNTRL_TILED_TILE_WHS, self.x393_axi_tasks.write_contol_register(start_addr + self.MCNTRL_TILED_TILE_WHS,
concat((tile_vstep, 8), concat(((tile_vstep, 8),
(tile_height, 8), (tile_height, 8),
(tile_width, 8))) # {8'b0,tile_vstep,tile_height,tile_width});#tile_width+(tile_height<<8)+(tile_vstep<<16)); (tile_width, 8)))) # {8'b0,tile_vstep,tile_height,tile_width});#tile_width+(tile_height<<8)+(tile_vstep<<16));
self.x393_axi_tasks.write_contol_register(start_addr + self.MCNTRL_TILED_MODE, mode);# set mode register: {extra_pages[1:0],enable,!reset} self.x393_axi_tasks.write_contol_register(start_addr + self.MCNTRL_TILED_MODE, mode);# set mode register: {extra_pages[1:0],enable,!reset}
self.x393_axi_tasks.configure_channel_priority(channel,0) # lowest priority channel 3 self.x393_axi_tasks.configure_channel_priority(channel,0) # lowest priority channel 3
self.x393_axi_tasks.enable_memcntrl_en_dis(channel,1); self.x393_axi_tasks.enable_memcntrl_en_dis(channel,1);
......
...@@ -133,8 +133,8 @@ class X393McntrlTiming(object): ...@@ -133,8 +133,8 @@ class X393McntrlTiming(object):
""" """
if self.DEBUG_MODE > 1: if self.DEBUG_MODE > 1:
print("SET DQ IDELAY=0x%x"%delay) print("SET DQ IDELAY=0x%x"%delay)
self.x393_axi_tasks.axi_set_multiple_delays(self.LD_DLY_LANE0_IDELAY, 8, delay) self.axi_set_multiple_delays(self.LD_DLY_LANE0_IDELAY, 8, delay)
self.x393_axi_tasks.axi_set_multiple_delays(self.LD_DLY_LANE1_IDELAY, 8, delay) self.axi_set_multiple_delays(self.LD_DLY_LANE1_IDELAY, 8, delay)
self.x393_axi_tasks.write_contol_register (self.DLY_SET,0);# // set all delays self.x393_axi_tasks.write_contol_register (self.DLY_SET,0);# // set all delays
def axi_set_dq_odelay(self, def axi_set_dq_odelay(self,
...@@ -145,8 +145,8 @@ class X393McntrlTiming(object): ...@@ -145,8 +145,8 @@ class X393McntrlTiming(object):
""" """
if self.DEBUG_MODE > 1: if self.DEBUG_MODE > 1:
print("SET DQ ODELAY=0x%x"%delay) print("SET DQ ODELAY=0x%x"%delay)
self.x393_axi_tasks.axi_set_multiple_delays(self.LD_DLY_LANE0_ODELAY, 8, delay); self.axi_set_multiple_delays(self.LD_DLY_LANE0_ODELAY, 8, delay);
self.x393_axi_tasks.axi_set_multiple_delays(self.LD_DLY_LANE1_ODELAY, 8, delay); self.axi_set_multiple_delays(self.LD_DLY_LANE1_ODELAY, 8, delay);
self.x393_axi_tasks.write_contol_register(self.DLY_SET,0); # set all delays self.x393_axi_tasks.write_contol_register(self.DLY_SET,0); # set all delays
def axi_set_dqs_idelay(self, def axi_set_dqs_idelay(self,
...@@ -157,8 +157,8 @@ class X393McntrlTiming(object): ...@@ -157,8 +157,8 @@ class X393McntrlTiming(object):
""" """
if self.DEBUG_MODE > 1: if self.DEBUG_MODE > 1:
print("SET DQS IDELAY=0x%x"%delay) print("SET DQS IDELAY=0x%x"%delay)
self.x393_axi_tasks.axi_set_multiple_delays(self.LD_DLY_LANE0_IDELAY + 8, 1, delay) self.axi_set_multiple_delays(self.LD_DLY_LANE0_IDELAY + 8, 1, delay)
self.x393_axi_tasks.axi_set_multiple_delays(self.LD_DLY_LANE1_IDELAY + 8, 1, delay) self.axi_set_multiple_delays(self.LD_DLY_LANE1_IDELAY + 8, 1, delay)
self.x393_axi_tasks.write_contol_register(self.DLY_SET,0); # set all delays self.x393_axi_tasks.write_contol_register(self.DLY_SET,0); # set all delays
def axi_set_dqs_odelay(self, def axi_set_dqs_odelay(self,
...@@ -169,8 +169,8 @@ class X393McntrlTiming(object): ...@@ -169,8 +169,8 @@ class X393McntrlTiming(object):
""" """
if self.DEBUG_MODE > 1: if self.DEBUG_MODE > 1:
print("SET DQS ODELAY=0x%x"%delay) print("SET DQS ODELAY=0x%x"%delay)
self.x393_axi_tasks.axi_set_multiple_delays(self.LD_DLY_LANE0_ODELAY + 8, 1, delay) self.axi_set_multiple_delays(self.LD_DLY_LANE0_ODELAY + 8, 1, delay)
self.x393_axi_tasks.axi_set_multiple_delays(self.LD_DLY_LANE1_ODELAY + 8, 1, delay) self.axi_set_multiple_delays(self.LD_DLY_LANE1_ODELAY + 8, 1, delay)
self.x393_axi_tasks.write_contol_register(self.DLY_SET,0); # set all delays self.x393_axi_tasks.write_contol_register(self.DLY_SET,0); # set all delays
def axi_set_dm_odelay (self, def axi_set_dm_odelay (self,
...@@ -181,8 +181,8 @@ class X393McntrlTiming(object): ...@@ -181,8 +181,8 @@ class X393McntrlTiming(object):
""" """
if self.DEBUG_MODE > 1: if self.DEBUG_MODE > 1:
print("SET DQM IDELAY=0x%x"%delay) print("SET DQM IDELAY=0x%x"%delay)
self.x393_axi_tasks.axi_set_multiple_delays(self.LD_DLY_LANE0_ODELAY + 9, 1, delay) self.axi_set_multiple_delays(self.LD_DLY_LANE0_ODELAY + 9, 1, delay)
self.x393_axi_tasks.axi_set_multiple_delays(self.LD_DLY_LANE1_ODELAY + 9, 1, delay) self.axi_set_multiple_delays(self.LD_DLY_LANE1_ODELAY + 9, 1, delay)
self.x393_axi_tasks.write_contol_register(self.DLY_SET,0) # set all delays self.x393_axi_tasks.write_contol_register(self.DLY_SET,0) # set all delays
def axi_set_cmda_odelay(self, def axi_set_cmda_odelay(self,
...@@ -193,7 +193,7 @@ class X393McntrlTiming(object): ...@@ -193,7 +193,7 @@ class X393McntrlTiming(object):
""" """
if self.DEBUG_MODE > 1: if self.DEBUG_MODE > 1:
print("SET COMMAND and ADDRESS ODELAY=0x%x"%delay) print("SET COMMAND and ADDRESS ODELAY=0x%x"%delay)
self.x393_axi_tasks.axi_set_multiple_delays(self.LD_DLY_CMDA, 32, delay); self.axi_set_multiple_delays(self.LD_DLY_CMDA, 32, delay);
self.x393_axi_tasks.write_contol_register(self.DLY_SET,0) # set all delays self.x393_axi_tasks.write_contol_register(self.DLY_SET,0) # set all delays
def axi_set_multiple_delays(self, def axi_set_multiple_delays(self,
...@@ -246,13 +246,16 @@ class X393McntrlTiming(object): ...@@ -246,13 +246,16 @@ class X393McntrlTiming(object):
Set sequencer patterns for the tristate ON/OFF (defined by parameters) Set sequencer patterns for the tristate ON/OFF (defined by parameters)
""" """
# may fail if some of the parameters used have undefined width # may fail if some of the parameters used have undefined width
delays=concat((0,16), # {16'h0, print("DQTRI_FIRST=%s, DQTRI_FIRST__TYPE=%s"%(str(self.DQTRI_FIRST),str(self.DQTRI_FIRST__TYPE)))
print("DQTRI_LAST=%s, DQTRI_LAST__TYPE=%s"%(str(self.DQTRI_LAST),str(self.DQTRI_LAST__TYPE)))
delays=concat(((0,16), # {16'h0,
(self.DQSTRI_LAST, getParWidth(self.DQSTRI_LAST__TYPE)), # DQSTRI_LAST, (self.DQSTRI_LAST, getParWidth(self.DQSTRI_LAST__TYPE)), # DQSTRI_LAST,
(self.DQSTRI_FIRST,getParWidth(self.DQSTRI_FIRST__TYPE)), # DQSTRI_FIRST, (self.DQSTRI_FIRST,getParWidth(self.DQSTRI_FIRST__TYPE)), # DQSTRI_FIRST,
(self.DQTRI_LAST, getParWidth(self.DQTRI_LAST_FIRST__TYPE)), # DQTRI_LAST, (self.DQTRI_LAST, getParWidth(self.DQTRI_LAST__TYPE)), # DQTRI_LAST,
(self.DQTRI_FIRST, getParWidth(self.DQTRI_FIRST__TYPE)) # DQTRI_FIRST}); (self.DQTRI_FIRST, getParWidth(self.DQTRI_FIRST__TYPE))) # DQTRI_FIRST});
) )[0]
if self.DEBUG_MODE > 1: if self.DEBUG_MODE > 1:
print("SET TRISTATE PATTERNS, combined delays=%s"%str(delays))
print("SET TRISTATE PATTERNS, combined delays=0x%x"%delays) print("SET TRISTATE PATTERNS, combined delays=0x%x"%delays)
self.x393_axi_tasks.write_contol_register(self.MCONTR_PHY_16BIT_ADDR +self.MCONTR_PHY_16BIT_PATTERNS_TRI, delays) # DQSTRI_LAST, DQSTRI_FIRST, DQTRI_LAST, DQTRI_FIRST}); self.x393_axi_tasks.write_contol_register(self.MCONTR_PHY_16BIT_ADDR +self.MCONTR_PHY_16BIT_PATTERNS_TRI, delays) # DQSTRI_LAST, DQSTRI_FIRST, DQTRI_LAST, DQTRI_FIRST});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment