Guest User

fuse_from_render.py

a guest
Jan 21st, 2025
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.32 KB | None | 0 0
  1. bitplanes = []
  2. bitlines = []
  3. wordlines = {}
  4. with open('../../desired_render.txt', 'r') as fh:
  5.     line = fh.readline().strip()
  6.     bitplanes = [x for x in line.split(' ') if x != '']
  7.     assert(bitplanes[0] == 'bp:')
  8.     bitplanes = bitplanes[1:]
  9.     bitplanes = [int(x) for x in bitplanes]
  10.     assert(len(bitplanes) == 24)
  11.  
  12.     line = fh.readline().strip()
  13.     assert(line[0:6] == 'bl(h):')
  14.     bl_h = line[6:].replace(' ', '')
  15.     assert(len(bl_h) == 768)
  16.  
  17.     line = fh.readline().strip()
  18.     assert(line[0:6] == 'bl(l):')
  19.     bl_l = line[6:].replace(' ', '')
  20.     assert(len(bl_l) == 768)
  21.  
  22.     for i in range(len(bl_l)):
  23.         bitlines.append(int(f'{bl_h[i]}{bl_l[i]}', 16))
  24.  
  25.     for line in fh:
  26.         wordline, bits = line.strip().replace(' ', '').split(':')
  27.         wordline = int(wordline, 16)
  28.         assert(len(bits) == 768)
  29.         bits = bits.replace('.', '0')
  30.         bits = bits.replace('o', '1')
  31.         wordlines[wordline] = bits
  32.  
  33. words = [0] * 4096
  34. for wl, bits in wordlines.items():
  35.     wl_offset = wl * 32
  36.     for i, bit in enumerate(bits):
  37.         bl = bitlines[i]
  38.         bp = bitplanes[int(i / 32)]
  39.         value = int(bit) << bp
  40.         #print((wl_offset + bl), wl, bl, bp, bit, value)
  41.         words[wl_offset + bl] += value
  42.  
  43. for word in words:
  44.     print(f'0x{word:06x}')
  45.  
  46. #eof
  47.  
Advertisement
Add Comment
Please, Sign In to add comment