Mercurial > repos > blastem
annotate analyze_olp.py @ 1137:9e0f2ea4a0fc
Fix slot tracking screwup
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 01 Jan 2017 23:00:28 -0800 |
parents | b290343e5664 |
children | 3e24de8d8073 |
rev | line source |
---|---|
455
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1 #!/usr/bin/env python |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2 |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3 from zipfile import ZipFile |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
4 from sys import exit, argv |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5 |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
6 def detect_rise(last, sample, bit): |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
7 mask = 1 << bit |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
8 return (not last & mask) and (sample & mask) |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
9 |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
10 def detect_fall(last, sample, bit): |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
11 mask = 1 << bit |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
12 return (last & mask) and (not sample & mask) |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
13 |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
14 def detect_high(sample, bit): |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
15 mask = 1 << bit |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
16 return sample & mask |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
17 |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
18 def detect_low(sample, bit): |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
19 mask = 1 << bit |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
20 return not sample & mask |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
21 |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
22 def analyze_delays(chanmap, datafile): |
926
b290343e5664
Added some stuff for detecting refresh delays in one of my old logic analyzer scripts. Needs cleanup
Michael Pavone <pavone@retrodev.com>
parents:
455
diff
changeset
|
23 if 'M68K_CLK' in chanmap: |
b290343e5664
Added some stuff for detecting refresh delays in one of my old logic analyzer scripts. Needs cleanup
Michael Pavone <pavone@retrodev.com>
parents:
455
diff
changeset
|
24 m68k_clk = chanmap['M68K CLK'] |
b290343e5664
Added some stuff for detecting refresh delays in one of my old logic analyzer scripts. Needs cleanup
Michael Pavone <pavone@retrodev.com>
parents:
455
diff
changeset
|
25 elif 'CLK' in chanmap: |
b290343e5664
Added some stuff for detecting refresh delays in one of my old logic analyzer scripts. Needs cleanup
Michael Pavone <pavone@retrodev.com>
parents:
455
diff
changeset
|
26 m68k_clk = chanmap['CLK'] |
455
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
27 m_as = chanmap['!AS'] |
926
b290343e5664
Added some stuff for detecting refresh delays in one of my old logic analyzer scripts. Needs cleanup
Michael Pavone <pavone@retrodev.com>
parents:
455
diff
changeset
|
28 ram_oe = chanmap['RAM !LOE/!RFSH'] |
b290343e5664
Added some stuff for detecting refresh delays in one of my old logic analyzer scripts. Needs cleanup
Michael Pavone <pavone@retrodev.com>
parents:
455
diff
changeset
|
29 ram_ce = chanmap['RAM !CE'] |
455
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
30 last = False |
926
b290343e5664
Added some stuff for detecting refresh delays in one of my old logic analyzer scripts. Needs cleanup
Michael Pavone <pavone@retrodev.com>
parents:
455
diff
changeset
|
31 prev = False |
b290343e5664
Added some stuff for detecting refresh delays in one of my old logic analyzer scripts. Needs cleanup
Michael Pavone <pavone@retrodev.com>
parents:
455
diff
changeset
|
32 prevRefresh = False |
455
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
33 clks = 0 |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
34 as_start = 0 |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
35 for line in datafile.readlines(): |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
36 line = line.strip() |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
37 if line and not line.startswith(';'): |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
38 sample,_,num = line.partition('@') |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
39 sample = int(sample, 16) |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
40 if not (last is False): |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
41 if detect_rise(last, sample, m68k_clk): |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
42 clks = clks + 1 |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
43 if detect_rise(last, sample, m_as): |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
44 as_clks = clks - as_start |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
45 if as_clks > 2: |
926
b290343e5664
Added some stuff for detecting refresh delays in one of my old logic analyzer scripts. Needs cleanup
Michael Pavone <pavone@retrodev.com>
parents:
455
diff
changeset
|
46 if not (prev is False): |
b290343e5664
Added some stuff for detecting refresh delays in one of my old logic analyzer scripts. Needs cleanup
Michael Pavone <pavone@retrodev.com>
parents:
455
diff
changeset
|
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 |
b290343e5664
Added some stuff for detecting refresh delays in one of my old logic analyzer scripts. Needs cleanup
Michael Pavone <pavone@retrodev.com>
parents:
455
diff
changeset
|
48 else: |
b290343e5664
Added some stuff for detecting refresh delays in one of my old logic analyzer scripts. Needs cleanup
Michael Pavone <pavone@retrodev.com>
parents:
455
diff
changeset
|
49 print '!AS held for', as_clks, 'cycles starting (delay of ' + str(as_clks - 2) + ') at', as_start, 'and ending at', clks |
b290343e5664
Added some stuff for detecting refresh delays in one of my old logic analyzer scripts. Needs cleanup
Michael Pavone <pavone@retrodev.com>
parents:
455
diff
changeset
|
50 prev = as_start |
455
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
51 elif detect_fall(last, sample, m_as): |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
52 as_start = clks |
926
b290343e5664
Added some stuff for detecting refresh delays in one of my old logic analyzer scripts. Needs cleanup
Michael Pavone <pavone@retrodev.com>
parents:
455
diff
changeset
|
53 if detect_fall(last, sample, ram_oe) and detect_high( sample, ram_ce): |
b290343e5664
Added some stuff for detecting refresh delays in one of my old logic analyzer scripts. Needs cleanup
Michael Pavone <pavone@retrodev.com>
parents:
455
diff
changeset
|
54 if prevRefresh is False: |
b290343e5664
Added some stuff for detecting refresh delays in one of my old logic analyzer scripts. Needs cleanup
Michael Pavone <pavone@retrodev.com>
parents:
455
diff
changeset
|
55 print 'RAM refresh at ', clks |
b290343e5664
Added some stuff for detecting refresh delays in one of my old logic analyzer scripts. Needs cleanup
Michael Pavone <pavone@retrodev.com>
parents:
455
diff
changeset
|
56 else: |
b290343e5664
Added some stuff for detecting refresh delays in one of my old logic analyzer scripts. Needs cleanup
Michael Pavone <pavone@retrodev.com>
parents:
455
diff
changeset
|
57 print 'RAM refresh at', clks, 'delta since last:', clks-prevRefresh |
b290343e5664
Added some stuff for detecting refresh delays in one of my old logic analyzer scripts. Needs cleanup
Michael Pavone <pavone@retrodev.com>
parents:
455
diff
changeset
|
58 prevRefresh = clks |
455
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
59 last = sample |
926
b290343e5664
Added some stuff for detecting refresh delays in one of my old logic analyzer scripts. Needs cleanup
Michael Pavone <pavone@retrodev.com>
parents:
455
diff
changeset
|
60 |
b290343e5664
Added some stuff for detecting refresh delays in one of my old logic analyzer scripts. Needs cleanup
Michael Pavone <pavone@retrodev.com>
parents:
455
diff
changeset
|
61 def analyze_refresh(chanmap, datafile): |
b290343e5664
Added some stuff for detecting refresh delays in one of my old logic analyzer scripts. Needs cleanup
Michael Pavone <pavone@retrodev.com>
parents:
455
diff
changeset
|
62 if 'M68K_CLK' in chanmap: |
b290343e5664
Added some stuff for detecting refresh delays in one of my old logic analyzer scripts. Needs cleanup
Michael Pavone <pavone@retrodev.com>
parents:
455
diff
changeset
|
63 m68k_clk = chanmap['M68K CLK'] |
b290343e5664
Added some stuff for detecting refresh delays in one of my old logic analyzer scripts. Needs cleanup
Michael Pavone <pavone@retrodev.com>
parents:
455
diff
changeset
|
64 elif 'CLK' in chanmap: |
b290343e5664
Added some stuff for detecting refresh delays in one of my old logic analyzer scripts. Needs cleanup
Michael Pavone <pavone@retrodev.com>
parents:
455
diff
changeset
|
65 m68k_clk = chanmap['CLK'] |
b290343e5664
Added some stuff for detecting refresh delays in one of my old logic analyzer scripts. Needs cleanup
Michael Pavone <pavone@retrodev.com>
parents:
455
diff
changeset
|
66 ram_oe = chanmap['RAM !LOE/!RFSH'] |
b290343e5664
Added some stuff for detecting refresh delays in one of my old logic analyzer scripts. Needs cleanup
Michael Pavone <pavone@retrodev.com>
parents:
455
diff
changeset
|
67 ram_ce = chanmap['RAM !CE'] |
b290343e5664
Added some stuff for detecting refresh delays in one of my old logic analyzer scripts. Needs cleanup
Michael Pavone <pavone@retrodev.com>
parents:
455
diff
changeset
|
68 clks = 0 |
b290343e5664
Added some stuff for detecting refresh delays in one of my old logic analyzer scripts. Needs cleanup
Michael Pavone <pavone@retrodev.com>
parents:
455
diff
changeset
|
69 last = False |
b290343e5664
Added some stuff for detecting refresh delays in one of my old logic analyzer scripts. Needs cleanup
Michael Pavone <pavone@retrodev.com>
parents:
455
diff
changeset
|
70 prevRefresh = False |
b290343e5664
Added some stuff for detecting refresh delays in one of my old logic analyzer scripts. Needs cleanup
Michael Pavone <pavone@retrodev.com>
parents:
455
diff
changeset
|
71 for line in datafile.readlines(): |
b290343e5664
Added some stuff for detecting refresh delays in one of my old logic analyzer scripts. Needs cleanup
Michael Pavone <pavone@retrodev.com>
parents:
455
diff
changeset
|
72 line = line.strip() |
b290343e5664
Added some stuff for detecting refresh delays in one of my old logic analyzer scripts. Needs cleanup
Michael Pavone <pavone@retrodev.com>
parents:
455
diff
changeset
|
73 if line and not line.startswith(';'): |
b290343e5664
Added some stuff for detecting refresh delays in one of my old logic analyzer scripts. Needs cleanup
Michael Pavone <pavone@retrodev.com>
parents:
455
diff
changeset
|
74 sample,_,num = line.partition('@') |
b290343e5664
Added some stuff for detecting refresh delays in one of my old logic analyzer scripts. Needs cleanup
Michael Pavone <pavone@retrodev.com>
parents:
455
diff
changeset
|
75 sample = int(sample, 16) |
b290343e5664
Added some stuff for detecting refresh delays in one of my old logic analyzer scripts. Needs cleanup
Michael Pavone <pavone@retrodev.com>
parents:
455
diff
changeset
|
76 if not (last is False): |
b290343e5664
Added some stuff for detecting refresh delays in one of my old logic analyzer scripts. Needs cleanup
Michael Pavone <pavone@retrodev.com>
parents:
455
diff
changeset
|
77 if detect_rise(last, sample, m68k_clk): |
b290343e5664
Added some stuff for detecting refresh delays in one of my old logic analyzer scripts. Needs cleanup
Michael Pavone <pavone@retrodev.com>
parents:
455
diff
changeset
|
78 clks = clks + 1 |
b290343e5664
Added some stuff for detecting refresh delays in one of my old logic analyzer scripts. Needs cleanup
Michael Pavone <pavone@retrodev.com>
parents:
455
diff
changeset
|
79 if detect_fall(last, sample, ram_oe) and detect_high( sample, ram_ce): |
b290343e5664
Added some stuff for detecting refresh delays in one of my old logic analyzer scripts. Needs cleanup
Michael Pavone <pavone@retrodev.com>
parents:
455
diff
changeset
|
80 if prevRefresh is False: |
b290343e5664
Added some stuff for detecting refresh delays in one of my old logic analyzer scripts. Needs cleanup
Michael Pavone <pavone@retrodev.com>
parents:
455
diff
changeset
|
81 print 'RAM refresh at ', clks |
b290343e5664
Added some stuff for detecting refresh delays in one of my old logic analyzer scripts. Needs cleanup
Michael Pavone <pavone@retrodev.com>
parents:
455
diff
changeset
|
82 else: |
b290343e5664
Added some stuff for detecting refresh delays in one of my old logic analyzer scripts. Needs cleanup
Michael Pavone <pavone@retrodev.com>
parents:
455
diff
changeset
|
83 print 'RAM refresh at', clks, 'delta since last:', clks-prevRefresh |
b290343e5664
Added some stuff for detecting refresh delays in one of my old logic analyzer scripts. Needs cleanup
Michael Pavone <pavone@retrodev.com>
parents:
455
diff
changeset
|
84 prevRefresh = clks |
b290343e5664
Added some stuff for detecting refresh delays in one of my old logic analyzer scripts. Needs cleanup
Michael Pavone <pavone@retrodev.com>
parents:
455
diff
changeset
|
85 last = sample |
b290343e5664
Added some stuff for detecting refresh delays in one of my old logic analyzer scripts. Needs cleanup
Michael Pavone <pavone@retrodev.com>
parents:
455
diff
changeset
|
86 |
455
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
87 |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
88 def main(args): |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
89 if len(args) < 2: |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
90 print 'Usage: analyze_olp.py filename' |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
91 exit(1) |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
92 olpfile = ZipFile(args[1], "r") |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
93 channelfile = olpfile.open('channel.labels') |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
94 channels = [line.strip() for line in channelfile.readlines()] |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
95 channelfile.close() |
926
b290343e5664
Added some stuff for detecting refresh delays in one of my old logic analyzer scripts. Needs cleanup
Michael Pavone <pavone@retrodev.com>
parents:
455
diff
changeset
|
96 print channels |
455
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
97 chanmap = {} |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
98 for i in xrange(0, len(channels)): |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
99 chanmap[channels[i]] = i |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
100 datafile = olpfile.open('data.ols') |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
101 analyze_delays(chanmap, datafile) |
926
b290343e5664
Added some stuff for detecting refresh delays in one of my old logic analyzer scripts. Needs cleanup
Michael Pavone <pavone@retrodev.com>
parents:
455
diff
changeset
|
102 datafile.close() |
b290343e5664
Added some stuff for detecting refresh delays in one of my old logic analyzer scripts. Needs cleanup
Michael Pavone <pavone@retrodev.com>
parents:
455
diff
changeset
|
103 #datafile = olpfile.open('data.ols') |
b290343e5664
Added some stuff for detecting refresh delays in one of my old logic analyzer scripts. Needs cleanup
Michael Pavone <pavone@retrodev.com>
parents:
455
diff
changeset
|
104 #analyze_refresh(chanmap, datafile) |
455
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
105 |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
106 if __name__ == '__main__': |
be9c7b3e25ee
Added analysis script used for investigating direct color DMA timing
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
107 main(argv) |