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

Subversion Repositories diogenes

[/] [diogenes/] [trunk/] [bin2coe.py] - Diff between revs 194 and 236

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 194 Rev 236
Line 1... Line 1...
 
#!/usr/bin/python
 
 
 
import sys
 
from array import *
 
import os
 
 
 
from stat import *
 
 
 
def main():
 
  print 'memory_initialization_radix=16;'
 
  print 'memory_initialization_vector='
 
 
 
  num = sys.argv[2]
 
  if num == '':
 
    num = '1'
 
 
 
  if num == '4':
 
    x = array('L')
 
  elif num == '2':
 
    x = array('H')
 
  else:
 
    x = array('B')
 
 
 
  f = open(sys.argv[1], 'rb')
 
  x.fromfile(f, os.stat(sys.argv[1])[ST_SIZE]/int(num))
 
 
 
  first = 1
 
  for el in x:
 
    if not first:
 
      print ','
 
    else:
 
      first = 0
 
    sys.stdout.write('%02x' % el)
 
 
 
  print ';'
 
 
 
if __name__ == "__main__":
 
    main()
 
 
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

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