OpenCores
URL https://opencores.org/ocsvn/a-z80/a-z80/trunk

Subversion Repositories a-z80

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /a-z80/trunk/tools
    from Rev 3 to Rev 8
    Reverse comparison

Rev 3 → Rev 8

/z80_pla_checker/source/ClassPLA.cs
21,6 → 21,11
public List<int> IgnoredPla = new List<int>();
 
/// <summary>
/// List of PLA entries not used by our Timings matrix
/// </summary>
public List<int> NotUsedPla = new List<int>();
 
/// <summary>
/// Returns the total number of PLA table entries
/// </summary>
public int Count()
59,19 → 64,19
 
////============================================================
//// Ignore duplicate PLA entries
//IgnoredPla.Add(98); // Duplicate of 37
//IgnoredPla.Add(94); // Duplicate of 12 and 18
//IgnoredPla.Add(93); // Duplicate of 11 and 19
//IgnoredPla.Add(90); // Duplicate of 26
//IgnoredPla.Add(36); // Duplicate of 8
//IgnoredPla.Add(87); // Duplicate of 83
//IgnoredPla.Add(71); // Duplicate of 25
//IgnoredPla.Add(63); // Duplicate of 17
//IgnoredPla.Add(87); // Duplicate of 83
//IgnoredPla.Add(60); // Duplicate of 15
//IgnoredPla.Add(94); // Duplicate of 12 and 18
//IgnoredPla.Add(18); // Duplicate of 12 and 94
//IgnoredPla.Add(93); // Duplicate of 11 and 19
//IgnoredPla.Add(19); // Duplicate of 11 and 93
//IgnoredPla.Add(98); // Duplicate of 37
//IgnoredPla.Add(41); // Duplicate of 3
//IgnoredPla.Add(36); // Duplicate of 8
//IgnoredPla.Add(32); // Duplicate of 4
//IgnoredPla.Add(19); // Duplicate of 11 and 93
//IgnoredPla.Add(18); // Duplicate of 12 and 94
 
////============================================================
//// Special signals (not instructions)
83,15 → 88,13
//IgnoredPla.Add(28); // This signal specifies the OUT operation for PLA 37. Otherwise, it is operation.
//IgnoredPla.Add(27); // This signal goes along individual IN/OUT instructions in the ED table.
//IgnoredPla.Add(16); // This signal specifies a PUSH operation for PLA23. Otherwise, it is a POP operation.
//IgnoredPla.Add(14); // This signal specifies a decrement operation for PLA 9. Otherwise, it is an increment.
//IgnoredPla.Add(13); // This signal specifies whether the value is being loaded or stored for PLA entries 8, 30 and 38.
//IgnoredPla.Add(4); // This signal goes along instructions that access I and R register (PLA 57 and 83).
//IgnoredPla.Add(0); // This signal specifies *not* to repeat block instructions.
 
////============================================================
//// Ignore our own reserved entries
//IgnoredPla.Add(107);
//IgnoredPla.Add(106);
//IgnoredPla.Add(107);
 
//============================================================
// Remove op-bits so we the output is more readable
113,6 → 116,16
IgnoredPla.Add(76);
 
//============================================================
// Signals not used in the Timings spreadsheet. For those, PLA table entries are not generated.
// This list is used only when generating the PLA table.
NotUsedPla.Add(67); // This signal defines a specific in(), but we use in/out pla[27] + pla[34]
NotUsedPla.Add(62); // This signal is issued for all CB opcodes
NotUsedPla.Add(54); // This signal specifies every CB with IX/IY
NotUsedPla.Add(22); // This signal specifies CB prefix w/o IX/IY
NotUsedPla.Add(14); // This signal specifies a decrement operation for PLA 9. Otherwise, it is an increment.
NotUsedPla.Add(4); // This signal goes along instructions that access I and R register (PLA 57 and 83).
 
//============================================================
// Mark all PLA entries we decided to ignore
foreach (var p in pla)
{
298,34 → 311,44
module += @"//=====================================================================================" + Environment.NewLine;
module += @"// This file is automatically generated by the z80_pla_checker tool. Do not edit! " + Environment.NewLine;
module += @"//=====================================================================================" + Environment.NewLine;
module += @"module pla_decode (opcode, prefix, pla);" + Environment.NewLine;
module += @"module pla_decode" + Environment.NewLine;
module += @"(" + Environment.NewLine;
module += @" input wire [6:0] prefix," + Environment.NewLine;
module += @" input wire [7:0] opcode," + Environment.NewLine;
module += @" output wire [" + max + ":0] pla" + Environment.NewLine;
module += @");" + Environment.NewLine;
module += @"" + Environment.NewLine;
module += @"input wire [6:0] prefix;" + Environment.NewLine;
module += @"input wire [7:0] opcode;" + Environment.NewLine;
module += @"output reg [" + max + ":0] pla;" + Environment.NewLine;
module += @"" + Environment.NewLine;
module += @"always_comb" + Environment.NewLine;
module += @"begin" + Environment.NewLine;
 
foreach (var p in pla)
{
if (p.IsDuplicate())
if (p.IsDuplicate() || NotUsedPla.Contains(p.N))
continue;
 
String bitstream = p.GetBitstream();
module += string.Format(@" if ({{prefix[6:0], opcode[7:0]}} ==? 15'b{0}) pla[{1,3}]=1'b1; else pla[{1,3}]=1'b0; // {2}",
bitstream, p.N, p.Comment) + Environment.NewLine;
module += string.Format(@"assign pla[{0,3}] = (({{prefix[6:0], opcode[7:0]}} & 15'b{1}) == 15'b{2}) ? 1'b1 : 1'b0; // {3}",
p.N,
bitstream.Replace('0', '1').Replace('X', '0'), // Create "AND" mask
bitstream.Replace('X', '0'), // Create a value to compare to
p.Comment) + Environment.NewLine;
}
 
// Dump all PLA entries that are ignored
// List all PLA entries that are not used
module += @"" + Environment.NewLine;
module += @" // Duplicate or ignored entries" + Environment.NewLine;
module += @"// Entries not used by our timing matrix" + Environment.NewLine;
foreach (var n in NotUsedPla)
{
module += string.Format(@"assign pla[{0,3}] = 1'b0; // {1}", n, pla[n].Comment) + Environment.NewLine;
}
 
// List all PLA entries that are ignored
module += @"" + Environment.NewLine;
module += @"// Duplicate entries" + Environment.NewLine;
foreach (var p in pla)
{
if (p.IsDuplicate())
module += string.Format(@" pla[{0,3}]=1'b0; // {1}", p.N, p.Comment) + Environment.NewLine;
module += string.Format(@"assign pla[{0,3}] = 1'b0; // {1}", p.N, p.Comment) + Environment.NewLine;
}
 
module += @"end" + Environment.NewLine;
module += @"" + Environment.NewLine;
module += @"endmodule" + Environment.NewLine;
 
/z80_pla_checker/z80_pla_checker.exe Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream
/dongle/daa/z80-instruction-test-daa.py
52,7 → 52,7
if not indata:
break
if indata[0]!=':':
if (("#017" in indata) or ("#020" in indata) or ("#053" in indata) or ("#056" in indata)):
if ("#017" in indata) or ("#020" in indata) or ("#053" in indata) or ("#056" in indata):
print (indata.rstrip('\r\n'))
sys.stderr.write (indata)
 
/dongle/daa/simulate-daa.py
1,4 → 1,4
#!/usr/bin/env python
#!/usr/bin/env python3
#
# This script simulates 'daa' calculation and generates values for numbers 0-255.
# These can be compared with a real Z80 run values.
15,7 → 15,7
inA = int(line[7:9], 16)
outA = int(line[13:15], 16)
outF = int(line[18:20], 16)
#print 'F:' + ("%0.2X" % inF) + ' A:' + ("%0.2X" % inA) + ' -> ' + ("%0.2X" % outA) + ' F:' + ("%0.2X" % outF)
#print ('F:' + ("%0.2X" % inF) + ' A:' + ("%0.2X" % inA) + ' -> ' + ("%0.2X" % outA) + ' F:' + ("%0.2X" % outF))
 
# Get the flags that will determine daa operation
hf = (inF>>4) & 1
59,4 → 59,4
 
flags = (sf<<7) | (zf<<6) | (yf<<5) | (hf<<4) | (xf<<3) | (pf<<2) | (nf<<1) | (cf<<0)
 
print 'F:' + ("%0.2X" % inF) + ' A:' + ("%0.2X" % inA) + ' -> ' + ("%0.2X" % finalA) + ' F:' + ("%0.2X" % flags)
print ('F:' + ("%0.2X" % inF) + ' A:' + ("%0.2X" % inA) + ' -> ' + ("%0.2X" % finalA) + ' F:' + ("%0.2X" % flags))
/dongle/sbc/simulate-sbc.py
1,4 → 1,4
#!/usr/bin/env python
#!/usr/bin/env python3
#
# This script simulates 'sbc' calculation and generates values for selected numbers.
# These can be compared with a real Z80 run values.
39,11 → 39,11
s += 'C'
else:
s += ' '
print 'Flags = %s' % s
print ('Flags = %s' % s)
 
def sbc(inA, op2, CYin):
print '------------------------------------------'
print 'Input: %0.2X SBC %0.2X CY = %0.2X' % ( inA, op2, CYin)
print ('------------------------------------------')
print ('Input: %0.2X SBC %0.2X CY = %0.2X' % ( inA, op2, CYin))
 
double_cpl = 0 # Flag that we did a double 1's complement
cplOp2 = op2 ^ 0xFF # Bit-wise complement of OP2
91,37 → 91,37
 
flags = (sf<<7) | (zf<<6) | (yf<<5) | (hf<<4) | (xf<<3) | (vf<<2) | (nf<<1) | (cf<<0)
 
print 'Out: A -> %0.2X Flags = %0.2X' % ( finalA, flags)
print ('Out: A -> %0.2X Flags = %0.2X' % ( finalA, flags))
printFlags(flags)
 
sbc(0, 0, 0)
print 'Should be A -> 00 Flags = 42'
print ('Should be A -> 00 Flags = 42')
printFlags(0x42)
sbc(0, 1, 0)
print 'Should be A -> FF Flags = BB'
print ('Should be A -> FF Flags = BB')
printFlags(0xBB)
 
sbc(0, 0, 1)
print 'Should be A -> FF Flags = BB'
print ('Should be A -> FF Flags = BB')
printFlags(0xBB)
sbc(0, 1, 1)
print 'Should be A -> FE Flags = BB'
print ('Should be A -> FE Flags = BB')
printFlags(0xBB)
 
sbc(0xAA, 0x55, 0)
print 'Should be A -> 55 Flags = 06'
print ('Should be A -> 55 Flags = 06')
printFlags(0x06)
sbc(0x55, 0xAA, 0)
print 'Should be A -> AB Flags = BF'
print ('Should be A -> AB Flags = BF')
printFlags(0xBF)
 
sbc(0xAA, 0x55, 1)
print 'Should be A -> 54 Flags = 06'
print ('Should be A -> 54 Flags = 06')
printFlags(0x06)
sbc(0x55, 0xAA, 1)
print 'Should be A -> AA Flags = BF'
print ('Should be A -> AA Flags = BF')
printFlags(0xBF)
 
sbc(0x0F, 0x03, 1)
print 'Should be A -> 0B Flags = 0A'
print ('Should be A -> 0B Flags = 0A')
printFlags(0x0A)
/dongle/sbc/simulate-sub.py
1,4 → 1,4
#!/usr/bin/env python
#!/usr/bin/env python3
#
# This script simulates 'sub' calculation and generates values for selected numbers.
# These can be compared with a real Z80 run values.
39,11 → 39,11
s += 'C'
else:
s += ' '
print 'Flags = %s' % s
print ('Flags = %s' % s)
 
def sbc(inA, op2, CYin):
print '------------------------------------------'
print 'Input: %0.2X SUB %0.2X' % ( inA, op2)
print ('------------------------------------------')
print ('Input: %0.2X SUB %0.2X' % ( inA, op2))
 
cplA = inA ^ 0xFF # Bit-wise complement of A
CYin = 1
79,23 → 79,23
 
flags = (sf<<7) | (zf<<6) | (yf<<5) | (hf<<4) | (xf<<3) | (vf<<2) | (nf<<1) | (cf<<0)
 
print 'Out: A -> %0.2X Flags = %0.2X' % ( finalA, flags)
print ('Out: A -> %0.2X Flags = %0.2X' % ( finalA, flags))
printFlags(flags)
 
sbc(0, 0, 0)
print 'Should be A -> 00 Flags = 42'
print ('Should be A -> 00 Flags = 42')
printFlags(0x42)
sbc(0, 1, 0)
print 'Should be A -> FF Flags = BB'
print ('Should be A -> FF Flags = BB')
printFlags(0xBB)
 
sbc(0xAA, 0x55, 0)
print 'Should be A -> 55 Flags = 06'
print ('Should be A -> 55 Flags = 06')
printFlags(0x06)
sbc(0x55, 0xAA, 0)
print 'Should be A -> AB Flags = BF'
print ('Should be A -> AB Flags = BF')
printFlags(0xBF)
 
sbc(0x0F, 0x03, 0)
print 'Should be A -> 0C Flags = 0A'
print ('Should be A -> 0C Flags = 0A')
printFlags(0x0A)
/dongle/neg/simulate-neg.py
1,4 → 1,4
#!/usr/bin/env python
#!/usr/bin/env python3
#
# This script simulates 'neg' calculation and generates values for numbers 0-255.
# These can be compared with a real Z80 run values.
55,4 → 55,4
 
flags = (sf<<7) | (zf<<6) | (yf<<5) | (hf<<4) | (xf<<3) | (vf<<2) | (nf<<1) | (cf<<0)
 
print '%0.2X -> %0.2X Flags = %0.2X' % ( inA, finalA, flags)
print ('%0.2X -> %0.2X Flags = %0.2X' % ( inA, finalA, flags))
/zmac/fpga.hex File deleted
/zmac/make_fpga.bat
1,9 → 1,11
@echo off
Rem
Rem Creates an Intel HEX file format from a Z80 source file.
Rem This hex file is loaded into the ROM module for both the ModelSim
Rem and to be included into the target FPGA data file at the "host" level.
Rem Assembles Z80 source file into object code and generates various
Rem formats of that code to be used by FPGA test projects.
Rem
Rem Intel HEX files are used by ModelSim and Altera synthesis,
Rem COE and MIF files are used by Xilinx and its ISim simulation.
Rem
Rem Give it an argument of the ASM file you want to use, or you can simply drag
Rem and drop an asm file into it. If you drop an ASM file and there were errors,
Rem this script will keep the DOS window open so you can see the errors.
12,16 → 14,22
if errorlevel 1 goto error
bin2hex.exe zout\%~n1.cim fpga.hex
if errorlevel 1 goto error
python bin2coe.py zout\%~n1.cim ram.coe
if errorlevel 1 goto error
python bin2mif.py --simple zout\%~n1.cim ram.mif
if errorlevel 1 goto error
 
Rem Copy hex files to their target Quartus/ModelSim host directories
copy /Y fpga.hex ..\..\host\basic
copy /Y fpga.hex ..\..\host\basic\simulation\modelsim
copy /Y fpga.hex ..\..\host\basic_de1
copy /Y fpga.hex ..\..\host\basic_de1\simulation\modelsim
 
Rem Copy .mif and .coe files to their target Xilinx host directories
copy /Y ram.mif ..\..\host\basic_nexys3\work
goto end
 
:error
@echo ------------------------------------------------------
@echo Errors assembling %1
@echo Errors processing %1
@echo ------------------------------------------------------
cmd
:end
/zmac/bindump.py
1,4 → 1,4
#!/usr/bin/env python
#!/usr/bin/env python3
#
# This script reads a binary file and writes it out in the ASCII format
# that lists each 8-bit word in a hex format without 0x.
11,18 → 11,22
#
import sys
 
if len(sys.argv)<2:
print ("Usage: python bindump.py <input-file> [<output-file>]")
exit(-1)
 
filename = sys.argv[1]
outfile = "out.hex"
col = 0;
if len(sys.argv) > 2:
outfile = sys.argv[2]
if len(sys.argv)==3:
outfile = sys.argv[2]
with open(filename, "rb") as f, open(outfile, "w") as o:
block = f.read(65536)
for ch in block:
#print '{0:02X}'.format(ord(ch))
o.write('{0:02X} '.format(ord(ch)))
#print ('{0:02X}'.format(ch))
o.write('{0:02X} '.format(ch))
col = col + 1
if col==16:
o.write("\n")
col = 0;
print "Created " + outfile
print ("Created", outfile)
/zmac/bin2coe.py
0,0 → 1,39
#!/usr/bin/env python3
import sys, os
from argparse import ArgumentParser
 
parser = ArgumentParser(description='Converts binary file to Xilinx coe file')
 
parser.add_argument('infile', help='Input binary file')
parser.add_argument('outfile', help='Output coe file')
parser.add_argument('-d', '--depth', type=int, default=0)
args = parser.parse_args()
 
with open(args.infile, 'rb') as f:
depth = os.path.getsize(args.infile)
if args.depth > 0:
if args.depth < depth:
print ("ERROR: Input file is larger than the specified depth!")
exit (-1)
depth = args.depth
 
with open(args.outfile, 'w') as fmif:
fmif.write('; Automatically generated by bin2coe.py\n')
fmif.write('; Translated from ' + args.infile + '\n')
fmif.write('memory_initialization_radix=16;\n')
fmif.write('memory_initialization_vector=\n')
 
count = 0
buffer = f.read()
for b in buffer:
if count > 0:
fmif.write(',\n')
fmif.write('{0:02x}'.format(b))
count += 1
 
while count < depth:
if count < depth:
fmif.write(',\n')
fmif.write('00')
count += 1
fmif.write(';\n')
/zmac/hello_world.asm
132,11 → 132,14
 
ld (stack),sp
 
; Several options on which values we want to dump, uncomment only one:
ld hl, text+5
ld a,(stack+1)
; ld a,(stack+1) ; Dump stack pointer (useful to check SP)
ld a, i ; Show IR register
call tohex
ld hl, text+7
ld a,(stack)
; ld a,(stack) ; Dump stack pointer (useful to check SP)
ld a, r ; Show IR register
call tohex
 
; Two versions of the code: either keep printing the text indefinitely (which
181,5 → 184,6
hello:
db 13,10
text:
db '0000 0000 Hello, World!',13,10,'$'
db '---- ---- Hello, World!$'
 
end
/zmac/bin2mif.py
0,0 → 1,48
#!/usr/bin/env python3
import sys, os
from argparse import ArgumentParser
 
parser = ArgumentParser(description='Converts binary file to mif file')
 
parser.add_argument('infile', help='Input binary file')
parser.add_argument('outfile', help='Output mif file')
parser.add_argument('-d', '--depth', help='Total memory depth (fill with zeros)', type=int, default=0)
parser.add_argument('-s', '--simple', help='Simple format (data only)', action="store_true", default=False)
args = parser.parse_args()
 
with open(args.infile, 'rb') as f:
depth = os.path.getsize(args.infile)
if args.depth > 0:
if args.depth < depth:
print ("ERROR: Input file is larger than the specified depth!")
exit (-1)
depth = args.depth
 
with open(args.outfile, 'w') as fmif:
if args.simple:
count = 0
buffer = f.read()
for b in buffer:
fmif.write('{0:08b}\n'.format(b))
count += 1
while count < depth:
fmif.write('00000000')
count += 1
else:
fmif.write('-- Automatically generated by bin2mif.py\n')
fmif.write('-- Translated from ' + args.infile + '\n')
fmif.write('DEPTH = {};\n'.format(depth))
fmif.write('WIDTH = 8;\n')
fmif.write('ADDRESS_RADIX = DEC;\n')
fmif.write('DATA_RADIX = HEX;\n')
fmif.write('CONTENT\n')
fmif.write('BEGIN\n')
 
count = 0
buffer = f.read()
for b in buffer:
fmif.write('{0:<4}: {1:02x};\n'.format(count, b))
count += 1
if count < depth:
fmif.write('[{0}..{1}] : 0;\n'.format(count, depth))
fmif.write('END;\n')
/readme.txt
1,4 → 1,4
This directory contains various tools:
This directory contains various tools related to the project:
 
Arduino
=======
8,22 → 8,22
 
dongle
======
Several scripts and files that run Z80 instructions through the Arduino
Scripts and files that run Z80 instructions through the Arduino
dongle to collect timing and functional data.
 
Some instructions (daa, neg, sbc) have separate simulation scripts
that contain functional implementation which is then compared to
containing functional implementation which is then compared to
the response of a physical Z80 CPU (through the dongle).
 
 
z80_pla_checker
===============
A Visual Studio 2010 project that loads PLA table and provides interactive
A Visual Studio project that loads PLA table and provides interactive
simulation of opcodes and logic responses. The program also generates a
Verilog PLA table source code to be included in the A-Z80 project.
Verilog PLA table source code used in the A-Z80 project.
 
 
zmac
====
A handy Z80 assember.
Assembly source files that test and verify A-Z80 processor.
Various assembly source files that test and verify A-Z80 processor.

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.