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

Subversion Repositories a-z80

[/] [a-z80/] [trunk/] [cpu/] [export.py] - Blame information for rev 17

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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