XUANTIE-RV / wujian100_open

IC design and development should be faster,simpler and more reliable
MIT License
1.86k stars 572 forks source link

Update Srec2vmem.py #33

Closed ghost closed 4 years ago

ghost commented 4 years ago

Fix the following bugs

Traceback (most recent call last):
  File "../tools/Srec2vmem.py", line 187, in <module>
    main(sys.argv[1:])
  File "../tools/Srec2vmem.py", line 184, in main
    hex2vmem(o_argv_info)
  File "../tools/Srec2vmem.py", line 138, in hex2vmem
    line_addr = cur_line[(line_addr_idx):(line_addr_end)]
TypeError: slice indices must be integers or None or have an __index__ method
Traceback (most recent call last):
  File "../tools/Srec2vmem.py", line 187, in <module>
    main(sys.argv[1:])
  File "../tools/Srec2vmem.py", line 184, in main
    hex2vmem(o_argv_info)
  File "../tools/Srec2vmem.py", line 139, in hex2vmem
    line_data = cur_line[(line_data_idx):(line_data_end)]
TypeError: slice indices must be integers or None or have an __index__ method
Traceback (most recent call last):
  File "../tools/Srec2vmem.py", line 187, in <module>
    main(sys.argv[1:])
  File "../tools/Srec2vmem.py", line 184, in main
    hex2vmem(o_argv_info)
  File "../tools/Srec2vmem.py", line 176, in hex2vmem
    ofile_id.write("@%08x %s\n" %(cur_mem_addr, cur_mem_data))
TypeError: %x format: an integer is required, not float
ghost commented 4 years ago

python3:

>>> 10 / 2 
5.0
>>> int(10 / 2)
5

python2:

>>> 10 / 2 
5
>>> int(10 / 2)
5

add int() Compatible with both python2 and python3

birdshanshan commented 4 years ago

Thanks to PYGC's update, which making this script can be executed either by python2 or python3.