URL
https://opencores.org/ocsvn/a-z80/a-z80/trunk
[/] [a-z80/] [trunk/] [tools/] [dongle/] [z80-instruction-run-ed.py] - Blame information for rev 4
Go to most recent revision |
Details |
Compare with Previous |
View Log
Line No. |
Rev |
Author |
Line |
1 |
3 |
gdevic |
#!/usr/bin/env python
|
2 |
|
|
#
|
3 |
|
|
# This script is used to dump Z80 instruction timing data by running the
|
4 |
|
|
# instructions through the Arduino Z80 dongle and parsing the dump output.
|
5 |
|
|
# It needs:
|
6 |
|
|
# 1. Arduino Z80 dongle: http://www.baltazarstudios.com
|
7 |
|
|
# 2. Instructions data file: '../../resources/opcodes-??.txt'
|
8 |
|
|
# Needs pyserial from https://pypi.python.org/pypi/pyserial
|
9 |
|
|
#
|
10 |
|
|
import serial
|
11 |
|
|
import sys
|
12 |
|
|
|
13 |
|
|
ser = serial.Serial("\\.\COM9", 115200, timeout=1)
|
14 |
|
|
|
15 |
|
|
# Flush the serial buffer, removes any command response
|
16 |
|
|
def serialFlush(ser):
|
17 |
|
|
while 1:
|
18 |
|
|
indata = ser.readline().rstrip('\n')
|
19 |
|
|
if not indata:
|
20 |
|
|
break
|
21 |
|
|
|
22 |
|
|
try:
|
23 |
|
|
# Open opcode file and read opcode + mnemonics
|
24 |
|
|
with open('../../resources/opcodes-ed.txt') as tmpFile:
|
25 |
|
|
ops = [line.rstrip('\n') for line in tmpFile]
|
26 |
|
|
|
27 |
|
|
serialFlush(ser)
|
28 |
|
|
# Stop after the second M1 cycle effectively running only one instruction
|
29 |
|
|
ser.write("s 4 3\r")
|
30 |
|
|
serialFlush(ser)
|
31 |
|
|
|
32 |
|
|
print ('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">')
|
33 |
|
|
print ('<HTML><HEAD><TITLE>Z80 Instructions Timing</TITLE></HEAD><BODY>')
|
34 |
|
|
print ('<H1>Opcodes with ED prefix</H1>')
|
35 |
|
|
for line in ops:
|
36 |
|
|
print (line[0:2] + ' ' + line[2:4] + ' .. <A href=\"#' + line[2:4] + '\">' + line[12:] + '</A><BR>')
|
37 |
|
|
|
38 |
|
|
print ('<H1>Instructions Timing</H1>')
|
39 |
|
|
|
40 |
|
|
for line in ops:
|
41 |
|
|
ram = ':10000000' + line[0:4] + '0102030405060708090A0B0C0D00'
|
42 |
|
|
|
43 |
|
|
ser.write(ram + '\r')
|
44 |
|
|
indata = ser.readline().rstrip('\n')
|
45 |
|
|
ser.write('r\r')
|
46 |
|
|
|
47 |
|
|
print ('<H3 id=\"' + line[2:4] + '\">Opcode: ' + line[0:2] + " " + line[2:8] + ' => ' + line[12:] + '</H3>')
|
48 |
|
|
sys.stderr.write (line + '\n')
|
49 |
|
|
|
50 |
|
|
# Skip initial response from Arduino, includes two empty cycles after the reset
|
51 |
|
|
for x in range(1,7):
|
52 |
|
|
indata = ser.readline()
|
53 |
|
|
|
54 |
|
|
print ('<PRE>')
|
55 |
|
|
while 1:
|
56 |
|
|
indata = ser.readline()
|
57 |
|
|
if not indata:
|
58 |
|
|
break
|
59 |
|
|
if indata[0]!=':':
|
60 |
|
|
print (indata.rstrip('\r\n'))
|
61 |
|
|
print ('</PRE>')
|
62 |
|
|
|
63 |
|
|
print ('</BODY></HTML>')
|
64 |
|
|
|
65 |
|
|
except KeyboardInterrupt:
|
66 |
|
|
ser.close()
|
© copyright 1999-2024
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.