comparison analyze_olp.py @ 455:be9c7b3e25ee

Added analysis script used for investigating direct color DMA timing
author Mike Pavone <pavone@retrodev.com>
date Mon, 02 Sep 2013 01:03:08 -0700
parents
children b290343e5664
comparison
equal deleted inserted replaced
454:e9b6fe443bf2 455:be9c7b3e25ee
1 #!/usr/bin/env python
2
3 from zipfile import ZipFile
4 from sys import exit, argv
5
6 def detect_rise(last, sample, bit):
7 mask = 1 << bit
8 return (not last & mask) and (sample & mask)
9
10 def detect_fall(last, sample, bit):
11 mask = 1 << bit
12 return (last & mask) and (not sample & mask)
13
14 def detect_high(sample, bit):
15 mask = 1 << bit
16 return sample & mask
17
18 def detect_low(sample, bit):
19 mask = 1 << bit
20 return not sample & mask
21
22 def analyze_delays(chanmap, datafile):
23 m68k_clk = chanmap['M68K CLK']
24 m_as = chanmap['!AS']
25 last = False
26 clks = 0
27 as_start = 0
28 for line in datafile.readlines():
29 line = line.strip()
30 if line and not line.startswith(';'):
31 sample,_,num = line.partition('@')
32 sample = int(sample, 16)
33 if not (last is False):
34 if detect_rise(last, sample, m68k_clk):
35 clks = clks + 1
36 if detect_rise(last, sample, m_as):
37 as_clks = clks - as_start
38 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
40 elif detect_fall(last, sample, m_as):
41 as_start = clks
42 last = sample
43
44 def main(args):
45 if len(args) < 2:
46 print 'Usage: analyze_olp.py filename'
47 exit(1)
48 olpfile = ZipFile(args[1], "r")
49 channelfile = olpfile.open('channel.labels')
50 channels = [line.strip() for line in channelfile.readlines()]
51 channelfile.close()
52 chanmap = {}
53 for i in xrange(0, len(channels)):
54 chanmap[channels[i]] = i
55 datafile = olpfile.open('data.ols')
56 analyze_delays(chanmap, datafile)
57
58
59 if __name__ == '__main__':
60 main(argv)