comparison analyze_olp.py @ 926:b290343e5664

Added some stuff for detecting refresh delays in one of my old logic analyzer scripts. Needs cleanup
author Michael Pavone <pavone@retrodev.com>
date Tue, 02 Feb 2016 22:24:40 -0800
parents be9c7b3e25ee
children 3e24de8d8073
comparison
equal deleted inserted replaced
924:1b86268a4cb3 926:b290343e5664
18 def detect_low(sample, bit): 18 def detect_low(sample, bit):
19 mask = 1 << bit 19 mask = 1 << bit
20 return not sample & mask 20 return not sample & mask
21 21
22 def analyze_delays(chanmap, datafile): 22 def analyze_delays(chanmap, datafile):
23 m68k_clk = chanmap['M68K CLK'] 23 if 'M68K_CLK' in chanmap:
24 m68k_clk = chanmap['M68K CLK']
25 elif 'CLK' in chanmap:
26 m68k_clk = chanmap['CLK']
24 m_as = chanmap['!AS'] 27 m_as = chanmap['!AS']
28 ram_oe = chanmap['RAM !LOE/!RFSH']
29 ram_ce = chanmap['RAM !CE']
25 last = False 30 last = False
31 prev = False
32 prevRefresh = False
26 clks = 0 33 clks = 0
27 as_start = 0 34 as_start = 0
28 for line in datafile.readlines(): 35 for line in datafile.readlines():
29 line = line.strip() 36 line = line.strip()
30 if line and not line.startswith(';'): 37 if line and not line.startswith(';'):
34 if detect_rise(last, sample, m68k_clk): 41 if detect_rise(last, sample, m68k_clk):
35 clks = clks + 1 42 clks = clks + 1
36 if detect_rise(last, sample, m_as): 43 if detect_rise(last, sample, m_as):
37 as_clks = clks - as_start 44 as_clks = clks - as_start
38 if as_clks > 2: 45 if as_clks > 2:
39 print '!AS held for', as_clks, 'cycles starting (delay of ' + str(as_clks - 2) + ') at', as_start, 'and ending at', clks 46 if not (prev is False):
47 print '!AS held for', as_clks, 'cycles starting (delay of ' + str(as_clks - 2) + ') at', as_start, 'and ending at', clks, 'delta since last delay:', as_start - prev
48 else:
49 print '!AS held for', as_clks, 'cycles starting (delay of ' + str(as_clks - 2) + ') at', as_start, 'and ending at', clks
50 prev = as_start
40 elif detect_fall(last, sample, m_as): 51 elif detect_fall(last, sample, m_as):
41 as_start = clks 52 as_start = clks
53 if detect_fall(last, sample, ram_oe) and detect_high( sample, ram_ce):
54 if prevRefresh is False:
55 print 'RAM refresh at ', clks
56 else:
57 print 'RAM refresh at', clks, 'delta since last:', clks-prevRefresh
58 prevRefresh = clks
42 last = sample 59 last = sample
60
61 def analyze_refresh(chanmap, datafile):
62 if 'M68K_CLK' in chanmap:
63 m68k_clk = chanmap['M68K CLK']
64 elif 'CLK' in chanmap:
65 m68k_clk = chanmap['CLK']
66 ram_oe = chanmap['RAM !LOE/!RFSH']
67 ram_ce = chanmap['RAM !CE']
68 clks = 0
69 last = False
70 prevRefresh = False
71 for line in datafile.readlines():
72 line = line.strip()
73 if line and not line.startswith(';'):
74 sample,_,num = line.partition('@')
75 sample = int(sample, 16)
76 if not (last is False):
77 if detect_rise(last, sample, m68k_clk):
78 clks = clks + 1
79 if detect_fall(last, sample, ram_oe) and detect_high( sample, ram_ce):
80 if prevRefresh is False:
81 print 'RAM refresh at ', clks
82 else:
83 print 'RAM refresh at', clks, 'delta since last:', clks-prevRefresh
84 prevRefresh = clks
85 last = sample
86
43 87
44 def main(args): 88 def main(args):
45 if len(args) < 2: 89 if len(args) < 2:
46 print 'Usage: analyze_olp.py filename' 90 print 'Usage: analyze_olp.py filename'
47 exit(1) 91 exit(1)
48 olpfile = ZipFile(args[1], "r") 92 olpfile = ZipFile(args[1], "r")
49 channelfile = olpfile.open('channel.labels') 93 channelfile = olpfile.open('channel.labels')
50 channels = [line.strip() for line in channelfile.readlines()] 94 channels = [line.strip() for line in channelfile.readlines()]
51 channelfile.close() 95 channelfile.close()
96 print channels
52 chanmap = {} 97 chanmap = {}
53 for i in xrange(0, len(channels)): 98 for i in xrange(0, len(channels)):
54 chanmap[channels[i]] = i 99 chanmap[channels[i]] = i
55 datafile = olpfile.open('data.ols') 100 datafile = olpfile.open('data.ols')
56 analyze_delays(chanmap, datafile) 101 analyze_delays(chanmap, datafile)
57 102 datafile.close()
103 #datafile = olpfile.open('data.ols')
104 #analyze_refresh(chanmap, datafile)
58 105
59 if __name__ == '__main__': 106 if __name__ == '__main__':
60 main(argv) 107 main(argv)