OpenCores
URL https://opencores.org/ocsvn/tv80/tv80/trunk

Subversion Repositories tv80

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /tv80/branches/restruc1/scripts
    from Rev 46 to Rev 84
    Reverse comparison

Rev 46 → Rev 84

/run2
0,0 → 1,57
#!/usr/bin/env python
# Copyright (c) 2004 Guy Hutchison (ghutchis@opencores.org)
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
import sys, os, getopt
 
def print_help ():
print "Usage: run [-dh] <testname>"
print " -d : instruction decode"
print " -h : option help (this list)"
sys.exit(0)
 
# parse command line options
# d : instruction trace
# h : help
(options, args) = getopt.getopt (sys.argv[1:], "dh")
if len(args) == 0:
print_help()
testname = args[0]
simulator = "cver"
 
filelist = " -f env/tb.vf"
testdef = " +incdir+env -l logs/%s.log +define+DUMPFILE_NAME=\\\"logs/%s.dump\\\" +define+ROM_FILE=\\\"tests/%s.vmem\\\" +define+RAM_FILE=\\\"tests/%s.vmem\\\"" % (testname, testname, testname+"_rom", testname+"_ram")
 
for option in options:
if option[0] == "-d":
print "Adding TV80_INSTRUCTION_DECODE"
testdef += " +define+TV80_INSTRUCTION_DECODE=1"
if option[0] == "-h":
print_help()
 
os.chdir ("tests")
os.system ("make %s.vmem" % testname)
os.chdir ("..")
 
command = simulator + filelist + testdef
 
print "command:",command
os.system (command)
 
run2 Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: run =================================================================== --- run (nonexistent) +++ run (revision 84) @@ -0,0 +1,63 @@ +#!/usr/bin/env python +# Copyright (c) 2004 Guy Hutchison (ghutchis@opencores.org) +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +import sys, os, getopt + +def print_help (): + print "Usage: run [-th] [-d ###] " + print " -t : instruction decode (trace)" + print " -d : enable dumping start at time ###" + print " -h : option help (this list)" + sys.exit(0) + +# parse command line options +# t : instruction trace +# d : dump starting at +# h : help +(options, args) = getopt.getopt (sys.argv[1:], "thd:") +if len(args) == 0: + print_help() +testname = args[0] +simulator = "cver" + +filelist = " -f env/tb.vf" +testdef = " +incdir+env -l logs/%s.log +define+DUMPFILE_NAME=\\\"logs/%s.dump\\\" +define+PROGRAM_FILE=\\\"tests/%s.vmem\\\"" % (testname, testname, testname) + +for option in options: + if option[0] == "-t": + print "Adding TV80_INSTRUCTION_DECODE" + testdef += " +define+TV80_INSTRUCTION_DECODE=1" + elif option[0] == "-d": + testdef += " +define+DUMP_START=%s" % option[1] + elif option[0] == "-h": + print_help() + else: + print_help() + +os.chdir ("tests") +os.system ("make %s.vmem" % testname) +os.chdir ("..") + +command = simulator + filelist + testdef + +print "command:",command +os.system (command) +
run Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: s80_convert.py =================================================================== --- s80_convert.py (nonexistent) +++ s80_convert.py (revision 84) @@ -0,0 +1,36 @@ +#!/usr/bin/env python +# Copyright (c) 2004 Guy Hutchison (ghutchis@opencores.org) +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +import mem_image +import sys + +ram_start = 0x8000 +ram_end = 0xffff +rom_start = 0x0000 +rom_end = 0x7fff +src_file = "tests/tvs80.ihx" +rom_file = "tests/tvs80_rom.vmem" +ram_file = "tests/tvs80_ram.vmem" + +conv = mem_image.mem_image() +conv.load_ihex (src_file) +conv.save_vmem (rom_file, rom_start, rom_end) +conv.save_vmem (ram_file, ram_start, ram_end)
s80_convert.py Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: ihex2mem.py =================================================================== --- ihex2mem.py (nonexistent) +++ ihex2mem.py (revision 84) @@ -0,0 +1,102 @@ +#!/usr/bin/env python +# +# Intel Hex to Verilog Memory format converter +# +# Copyright (c) 2004 Guy Hutchison (ghutchis@opencores.org) +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +class mem_image: + def __init__ (self): + self.min = 100000 + self.max = -1 + self.map = {} + self.bcount = 0 + + def load_ihex (self, infile): + ifh = open (infile, 'r') + + line = ifh.readline() + while (line != ''): + if (line[0] == ':'): + rlen = int(line[1:3], 16) + addr = int(line[3:7], 16) + rtyp = int(line[7:9], 16) + ptr = 9 + for i in range (0, rlen): + laddr = addr + i + val = int(line[9+i*2:9+i*2+2], 16) + self.map[laddr] = val + self.bcount += 1 + if (laddr > self.max): self.max = laddr + if (laddr < self.min): self.min = laddr + + line = ifh.readline() + + ifh.close() + + def save_vmem (self, outfile, start=-1, stop=-1): + if (start == -1): start = self.min + if (stop == -1): stop = self.max + + ofh = open (outfile, 'w') + for addr in range(start, stop+1): + if self.map.has_key (addr): + ofh.write ("@%02x %02x\n" % (addr, self.map[addr])) + ofh.close() + +def ihex2mem (infile, outfile): + ifh = open (infile, 'r') + ofh = open (outfile, 'w') + + bcount = 0 + line = ifh.readline() + while (line != ''): + if (line[0] == ':'): + rlen = int(line[1:3], 16) + addr = int(line[3:7], 16) + rtyp = int(line[7:9], 16) + ptr = 9 + for i in range (0, rlen): + val = int(line[9+i*2:9+i*2+2], 16) + ofh.write ("@%02x %02x\n" % (addr+i, val)) + bcount += 1 + + line = ifh.readline() + + ifh.close() + ofh.close() + + return bcount + +def cmdline (): + import sys + + infile = sys.argv[1] + outfile = sys.argv[2] + + #bc = ihex2mem (infile, outfile) + conv = mem_image() + conv.load_ihex(infile) + conv.save_vmem(outfile) + print "Converted %d bytes from %s to %s" % (conv.bcount, infile, outfile) + +if __name__ == '__main__': + cmdline() +
ihex2mem.py Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: mem_image.py =================================================================== --- mem_image.py (nonexistent) +++ mem_image.py (revision 84) @@ -0,0 +1,60 @@ +#!/usr/bin/env python +# Copyright (c) 2004 Guy Hutchison (ghutchis@opencores.org) +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +class mem_image: + def __init__ (self): + self.min = 100000 + self.max = -1 + self.map = {} + self.bcount = 0 + + def load_ihex (self, infile): + ifh = open (infile, 'r') + + line = ifh.readline() + while (line != ''): + if (line[0] == ':'): + rlen = int(line[1:3], 16) + addr = int(line[3:7], 16) + rtyp = int(line[7:9], 16) + ptr = 9 + for i in range (0, rlen): + laddr = addr + i + val = int(line[9+i*2:9+i*2+2], 16) + self.map[laddr] = val + self.bcount += 1 + if (laddr > self.max): self.max = laddr + if (laddr < self.min): self.min = laddr + + line = ifh.readline() + + ifh.close() + + def save_vmem (self, outfile, start=-1, stop=-1): + if (start == -1): start = self.min + if (stop == -1): stop = self.max + + ofh = open (outfile, 'w') + for addr in range(start, stop+1): + if self.map.has_key (addr): + ofh.write ("@%02x %02x\n" % (addr-start, self.map[addr])) + ofh.close() +

powered by: WebSVN 2.1.0

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