Skip to content

Switch to new IDE v1.9.10.03 #342

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 1 addition & 24 deletions .github/workflows/chipdb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,24 +104,6 @@ jobs:
with:
name: gw1n-4-stage
path: GW1N-4*
gw1ns2:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build gw1ns-2 chipdb
run: |
docker pull ${{ env.APICULA_IMAGE }}
docker run -v $(pwd):/usr/src/apicula ${{ env.APICULA_IMAGE }} make apycula/GW1NS-2.pickle
- name: Archive artifact
uses: actions/upload-artifact@v4
with:
name: gw1ns-2-chipdb
path: apycula/GW1NS-2.pickle
- name: Archive stage artifact
uses: actions/upload-artifact@v4
with:
name: gw1ns-2-stage
path: GW1NS-2*
gw1ns4:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -178,7 +160,7 @@ jobs:
path: GW2A-18C*
pypi:
runs-on: ubuntu-latest
needs: [gw1n1, gw1nz1, gw1n9, gw1n9c, gw1n4, gw1ns2, gw1ns4, gw2a18, gw2a18c]
needs: [gw1n1, gw1nz1, gw1n9, gw1n9c, gw1n4, gw1ns4, gw2a18, gw2a18c]
steps:
- uses: actions/checkout@v4
- name: Download gw1n-1 chipdb
Expand Down Expand Up @@ -206,11 +188,6 @@ jobs:
with:
name: gw1n-9c-chipdb
path: apycula
- name: Download gw1ns-2 chipdb
uses: actions/download-artifact@v4
with:
name: gw1ns-2-chipdb
path: apycula
- name: Download gw1ns-4 chipdb
uses: actions/download-artifact@v4
with:
Expand Down
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ endif

.SECONDARY:
.PHONY: all clean

all: apycula/GW1N-1.pickle apycula/GW1N-9.pickle apycula/GW1N-4.pickle \
apycula/GW1NS-2.pickle apycula/GW1NS-4.pickle apycula/GW1N-9C.pickle \
apycula/GW1NZ-1.pickle apycula/GW2A-18.pickle apycula/GW2A-18C.pickle
apycula/GW1NS-4.pickle apycula/GW1N-9C.pickle apycula/GW1NZ-1.pickle \
apycula/GW2A-18.pickle apycula/GW2A-18C.pickle
#apycula/GW2A-18.pickle apycula/GW2A-18C.pickle apycula/GW5A-25A.pickle

%_stage1.pickle: apycula/tiled_fuzzer.py
python3 -m apycula.tiled_fuzzer $*
Expand Down
74 changes: 71 additions & 3 deletions apycula/attrids.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,23 @@
'IOBUF_IODUTY': 46,
'IOBUF_ODT_DYNTERM': 47,
'MIPI_IBUF_DRIVE': 48,
'MIPI_IBUF_DRIVE_LEVEL': 49
'MIPI_IBUF_DRIVE_LEVEL': 49,

'IOB_UNKNOWN51': 51,
'IOB_UNKNOWN52': 52,
'IOB_UNKNOWN55': 55,
'IOB_UNKNOWN56': 56,
'IOB_UNKNOWN57': 57,
'IOB_UNKNOWN58': 58,
'IOB_UNKNOWN59': 59,
'IOB_UNKNOWN60': 60,
'IOB_UNKNOWN61': 61,
'IOB_UNKNOWN66': 66,
'IOB_UNKNOWN68': 68,
'IOB_UNKNOWN69': 69,
'IOB_UNKNOWN70': 70,
'IOB_UNKNOWN71': 71,
'IOB_UNKNOWN72': 72
}

iob_attrvals = {
Expand Down Expand Up @@ -1183,8 +1199,8 @@
'F1': 4,
'F2': 5,
'F3': 6,
'USED': 7,
'UNUSED': 8,
'UNUSED': 7,
'USED': 8,
'FALSE': 9
}

Expand Down Expand Up @@ -1336,6 +1352,58 @@
'INDEL_1': 67,
'IMON_CENTSEL_0': 68,
'IMON_CENTSEL_1': 69,
'IOLOGIC_UNKNOWN74': 74,
'IOLOGIC_UNKNOWN77': 77,
'IOLOGIC_UNKNOWN78': 78,
'IOLOGIC_UNKNOWN79': 79,
'IOLOGIC_UNKNOWN82': 82,
'IOLOGIC_UNKNOWN83': 83,
'IOLOGIC_UNKNOWN84': 84,
'IOLOGIC_UNKNOWN85': 85,
'IOLOGIC_UNKNOWN86': 86,
'IOLOGIC_UNKNOWN87': 87,
'IOLOGIC_UNKNOWN88': 88,
'IOLOGIC_UNKNOWN89': 89,
'IOLOGIC_UNKNOWN90': 90,
'IOLOGIC_UNKNOWN91': 91,
'IOLOGIC_UNKNOWN92': 92,
'IOLOGIC_UNKNOWN93': 93,
'IOLOGIC_UNKNOWN95': 95,
'IOLOGIC_UNKNOWN97': 97,
'IOLOGIC_UNKNOWN98': 98,
'IOLOGIC_UNKNOWN99': 99,
'IOLOGIC_UNKNOWN100': 100,
'IOLOGIC_UNKNOWN101': 101,
'IOLOGIC_UNKNOWN102': 102,
'IOLOGIC_UNKNOWN103': 103,
'IOLOGIC_UNKNOWN104': 104,
'IOLOGIC_UNKNOWN105': 105,
'IOLOGIC_UNKNOWN106': 106,
'IOLOGIC_UNKNOWN107': 107,
'IOLOGIC_UNKNOWN108': 108,
'IOLOGIC_UNKNOWN109': 109,
'IOLOGIC_UNKNOWN110': 110,
'IOLOGIC_UNKNOWN111': 111,
'IOLOGIC_UNKNOWN112': 112,
'IOLOGIC_UNKNOWN113': 113,
'IOLOGIC_UNKNOWN114': 114,
'IOLOGIC_UNKNOWN115': 115,
'IOLOGIC_UNKNOWN116': 116,
'IOLOGIC_UNKNOWN118': 118,
'IOLOGIC_UNKNOWN119': 119,
'IOLOGIC_UNKNOWN120': 120,
'IOLOGIC_UNKNOWN121': 121,
'IOLOGIC_UNKNOWN122': 122,
'IOLOGIC_UNKNOWN123': 123,
'IOLOGIC_UNKNOWN124': 124,
'IOLOGIC_UNKNOWN125': 125,
'IOLOGIC_UNKNOWN126': 126,
'IOLOGIC_UNKNOWN127': 127,
'IOLOGIC_UNKNOWN128': 128,
'IOLOGIC_UNKNOWN129': 129,
'IOLOGIC_UNKNOWN130': 130,
'IOLOGIC_UNKNOWN135': 135,
'IOLOGIC_UNKNOWN136': 136
}

iologic_attrvals = {
Expand Down
7 changes: 7 additions & 0 deletions apycula/bitmatrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ def flipud(bmp):
"""
return bmp[::-1]

def transpose(bmp):
"""
Transposes a bitmap (swaps rows and cols)
Returns a reference
"""
return [[bmp[j][i] for j in range(len(bmp))] for i in range(len(bmp[0]))]

def vstack(bmp_0, bmp_1):
"""
Stack matrices in sequence vertically (row wise).
Expand Down
59 changes: 50 additions & 9 deletions apycula/bslib.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,39 @@ def bitarr(frame, pad):
data = frame.strip()[pad:-64]
return [int(n, base=2) for n in data]

def read_bitstream_version(fname):
ver = "UNKNOWN"
with open(fname) as inp:
for line in inp:
if line.startswith("//Tool Version:"):
ver = line[16:]
break
return ver

def read_bitstream(fname):
bitmap = []
returnBitmap = []
hdr = []
ftr = []
is_hdr = True
crcdat = bytearray()
preamble = 3
frames = 0
c = 0
is5ASeries = False

calc = crc.Calculator(crc16arc)
compressed = False
compress_keys = {}
with open(fname) as inp:
for line in inp:
if line.startswith("//"): continue
if line.startswith("//"):
#print("line: ", line)
continue
ba = bytearr(line)
if not frames:
if is_hdr:
#print("header:", ba)
hdr.append(ba)
if ba[0] == 0x10 and (int.from_bytes(ba, 'big') & (1 << 13)):
compressed = True
Expand All @@ -47,11 +62,14 @@ def read_bitstream(fname):
if ba[7]:
compress_keys[f'{ba[7]:08b}'] = 2
else:
#print("footer:", ba)
ftr.append(ba)
if not preamble and ba[0] != 0xd2: # SPI address
#print("spi address", ba)
crcdat.extend(ba)
if not preamble and ba[0] == 0x3b: # frame count
frames = int.from_bytes(ba[2:], 'big')
print("frame count: ", frames, ba)
is_hdr = False
if not preamble and ba[0] == 0x06: # device ID
if ba == b'\x06\x00\x00\x00\x11\x00\x58\x1b': # GW1N-9
Expand All @@ -69,23 +87,30 @@ def read_bitstream(fname):
elif ba == b'\x06\x00\x00\x00\x01\x00h\x1b': # GW1NZ-1
padding = 0
compress_padding = 0
elif ba == b'\x06\x00\x00\x00\x03\x00\x18\x1b': # XXX
padding = 0
elif ba == b'\x06\x00\x00\x00\x01\x00\x98\x1b': # GW1NS-4
padding = 0
compress_padding = 8
elif ba == b'\x06\x00\x00\x00\x00\x00\x08\x1b': # GW2A-18(C)
padding = 0
compress_padding = 16
elif ba == b'\x06\x00\x00\x00\x00\x01\x28\x1b': # GW5A-25A
padding = 0
is5ASeries = True
else:
raise ValueError("Unsupported device", ba)
preamble = max(0, preamble-1)
continue
crcdat.extend(ba[:-8])
crc1 = (ba[-7] << 8) + ba[-8]
crc2 = calc.checksum(crcdat)
assert crc1 == crc2, f"Not equal {crc1} {crc2} for {crcdat}"
crcdat = ba[-6:]
if is5ASeries == False:
crcdat.extend(ba[:-8])
crc1 = (ba[-7] << 8) + ba[-8]
crc2 = calc.checksum(crcdat)
assert crc1 == crc2, f"Not equal {crc1} {crc2} for {crcdat}"
if crc1 != crc2:
print("frame: ", c, ba, len(ba))
print("crcdata: ", crcdat, len(crcdat))
print("crc error - frame:", c, frames, " : ", crc1, " != ", crc2)

crcdat = ba[-6:]
if compressed:
uncompressed_line = ''
for byte_str in chunks(line[:-64], 8):
Expand All @@ -99,9 +124,16 @@ def read_bitstream(fname):
bitmap.append(bitarr(uncompressed_line, compress_padding))
else:
bitmap.append(bitarr(line, padding))

frames = max(0, frames-1)
c = c + 1

if is5ASeries == False:
returnBitmap = bitmatrix.fliplr(bitmap)
else:
returnBitmap = bitmatrix.transpose(bitmap)

return bitmatrix.fliplr(bitmap), hdr, ftr
return returnBitmap, hdr, ftr

def compressLine(line, key8Z, key4Z, key2Z):
newline = []
Expand Down Expand Up @@ -183,10 +215,19 @@ def write_bitstream(fname, bs, hdr, ftr, compress):

def display(fname, data):
from PIL import Image
"""
im = Image.frombytes(
mode='1',
size=data.shape[::-1],
data=bitmatrix.packbits(data, axis = 1))
"""

tdata = bitmatrix.packbits(data, axis = 1)
im = Image.new('RGB', bitmatrix.shape(tdata)[::-1], 255)
idata = im.load()
for x in range(im.size[0]):
for y in range(im.size[1]):
idata[x, y] = (tdata[y][x], tdata[y][x], tdata[y][x])
if fname:
im.save(fname)
return im
Loading
Loading