1 |
8 |
gdevic |
#!/usr/bin/env python3
|
2 |
|
|
#
|
3 |
19 |
gdevic |
# Run this script to export necessary CPU files away and into your project.
|
4 |
8 |
gdevic |
#
|
5 |
|
|
#-------------------------------------------------------------------------------
|
6 |
19 |
gdevic |
# Copyright (C) 2014,2018 Goran Devic, www.baltazarstudios.com
|
7 |
8 |
gdevic |
#
|
8 |
|
|
# This program is free software; you can redistribute it and/or modify it
|
9 |
|
|
# under the terms of the GNU General Public License as published by the Free
|
10 |
|
|
# Software Foundation; either version 2 of the License, or (at your option)
|
11 |
|
|
# any later version.
|
12 |
|
|
#
|
13 |
|
|
# This program is distributed in the hope that it will be useful, but WITHOUT
|
14 |
|
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
15 |
|
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
16 |
|
|
# more details.
|
17 |
|
|
#-------------------------------------------------------------------------------
|
18 |
|
|
import sys
|
19 |
|
|
import os
|
20 |
|
|
from shutil import copyfile
|
21 |
|
|
|
22 |
|
|
if len(sys.argv) != 2:
|
23 |
|
|
print ("\nUsage: export.py <destination-folder>\n")
|
24 |
19 |
gdevic |
print ("Exports all necessary A-Z80 Verilog files to a project folder of your choice.")
|
25 |
8 |
gdevic |
exit(-1)
|
26 |
|
|
|
27 |
|
|
dest = sys.argv[1]
|
28 |
|
|
total = 0
|
29 |
|
|
|
30 |
|
|
if not os.path.exists(dest):
|
31 |
|
|
print ("ERROR: Destination folder does not exist!")
|
32 |
|
|
exit(-1)
|
33 |
|
|
|
34 |
|
|
if not os.path.isdir(dest):
|
35 |
|
|
print ("ERROR: Destination is not a directory!")
|
36 |
|
|
exit(-1)
|
37 |
|
|
|
38 |
|
|
with open('top-level-files.txt') as f:
|
39 |
|
|
files = f.read().splitlines()
|
40 |
|
|
|
41 |
|
|
with open('copyleft.txt') as f:
|
42 |
|
|
copyleft = f.read()
|
43 |
|
|
|
44 |
|
|
# Read and copy each file from the list of input files
|
45 |
|
|
for infile in files:
|
46 |
|
|
if infile.startswith('+'):
|
47 |
|
|
infile = infile[2:]
|
48 |
|
|
if infile.startswith('Files='):
|
49 |
|
|
files = int(infile[6:])
|
50 |
|
|
if total != files:
|
51 |
|
|
print ("ERROR: Incorrect number of files copied!")
|
52 |
|
|
exit(-1)
|
53 |
|
|
else:
|
54 |
17 |
gdevic |
print ("\nDone copying {0} files.\n".format(files))
|
55 |
8 |
gdevic |
if not os.path.isfile(infile):
|
56 |
|
|
continue
|
57 |
|
|
name = os.path.basename(infile)
|
58 |
|
|
print ('Copying', infile)
|
59 |
|
|
with open(dest + '/' + name, 'wt') as f:
|
60 |
|
|
f.write(copyleft)
|
61 |
|
|
with open(infile) as g:
|
62 |
|
|
f.write(g.read())
|
63 |
|
|
total += 1
|
64 |
17 |
gdevic |
|
65 |
|
|
print ("All necessary A-Z80 CPU files are copied to", dest)
|
66 |
|
|
print ("Add all Verilog files (*.v) to your project and ensure that Verilog include")
|
67 |
|
|
print ("files (*.vh) are on the include path.\n")
|
68 |
|
|
print ("Use z80_top_direct_n.v as your top-level interface file.\n")
|
69 |
|
|
print ("Note for the users of Lattice FPGA toolset: instead of data_pins.v, manually")
|
70 |
|
|
print ("copy and use data_pins_lattice.v file instead.")
|