Skip to content

Commit 9764a44

Browse files
committed
Switch crcmod to crc
Fixed #217 and hopefully makes peoply trying to to bundle/install Apicual in weird ways a little happier for having to compile less C.
1 parent 153fc97 commit 9764a44

File tree

4 files changed

+7
-15
lines changed

4 files changed

+7
-15
lines changed

.github/workflows/chipdb.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ jobs:
305305
sudo make install
306306
cd ../nextpnr
307307
git checkout ${{ matrix.nextpnr }}
308-
cmake . -DBUILD_PYTHON=OFF -DARCH="gowin;himbaechel" -DHIMBAECHEL_GOWIN_DEVICES="GW1N-1;GW1NZ-1;GW1N-4;GW1N-9;GW1N-9C;GW1NS-4;GW2A-18;GW2A-18C" -DPython3_EXECUTABLE=${{ steps.pysetup.outputs.python-path }}
308+
cmake . -DBUILD_PYTHON=OFF -DARCH="gowin;himbaechel" -DHIMBAECHEL_GOWIN_DEVICES="all" -DPython3_EXECUTABLE=${{ steps.pysetup.outputs.python-path }}
309309
make -j$(nproc)
310310
sudo make install
311311
cd ../examples

Dockerfile

+1-9
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,7 @@ RUN curl -so gowin.tgz "http://cdn.gowinsemi.com.cn/Gowin_V1.9.8_linux.tar.gz" &
66
tar -xf gowin.tgz && \
77
rm gowin.tgz
88

9-
RUN mkdir -p "/root/Documents/gowinsemi/" && \
10-
curl -so "/root/Documents/gowinsemi/GW1N-9 Pinout.xlsx" "https://wishfulcoding.nl/gowin/UG114-1.4E_GW1N-9%20Pinout.xlsx" && \
11-
curl -so "/root/Documents/gowinsemi/GW1NR-9 Pinout.xlsx" "https://wishfulcoding.nl/gowin/UG801-1.5E_GW1NR-9%20Pinout.xlsx" && \
12-
curl -so "/root/Documents/gowinsemi/GW1N-4 Pinout.xlsx" "https://wishfulcoding.nl/gowin/UG105-1.6E_GW1N-4%20Pinout.xlsx" && \
13-
curl -so "/root/Documents/gowinsemi/GW1N-1 Pinout.xlsx" "https://wishfulcoding.nl/gowin/UG107-1.09E_GW1N-1%20Pinout.xlsx" && \
14-
curl -so "/root/Documents/gowinsemi/GW1NS-2C Pinout.xlsx" "https://wishfulcoding.nl/gowin/UG825-1.2.1E_GW1NS-2C%20Pinout.xlsx" && \
15-
curl -so "/root/Documents/gowinsemi/GW1NS-2 Pinout.xlsx" "https://wishfulcoding.nl/gowin/UG822-1.2.1E_GW1NS-2%20Pinout.xlsx"
16-
17-
RUN pip install --no-cache-dir numpy crcmod
9+
RUN pip install --no-cache-dir numpy crc
1810

1911
WORKDIR /usr/src/apicula
2012

apycula/bslib.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from math import ceil
22
import numpy as np
3-
from crcmod.predefined import mkPredefinedCrcFun
3+
import crc
44

5-
crc16arc = mkPredefinedCrcFun('crc-16')
5+
crc16arc = crc.Calculator(crc.Configuration(width=16, polynomial=0x8005, reverse_input=True, reverse_output=True))
66

77
def chunks(l, n):
88
"""Yield successive n-sized chunks from l."""
@@ -64,7 +64,7 @@ def read_bitstream(fname):
6464
continue
6565
crcdat.extend(ba[:-8])
6666
crc1 = (ba[-7] << 8) + ba[-8]
67-
crc2 = crc16arc(crcdat)
67+
crc2 = crc16arc.checksum(crcdat)
6868
assert crc1 == crc2, f"Not equal {crc1} {crc2}"
6969
crcdat = ba[-6:]
7070
bitmap.append(bitarr(line, padding))
@@ -122,7 +122,7 @@ def write_bitstream(fname, bs, hdr, ftr, compress):
122122
ba = compressLine(ba, key8Z, key4Z, key2Z)
123123
f.write(''.join(f"{b:08b}" for b in ba))
124124
crcdat.extend(ba)
125-
crc = crc16arc(crcdat)
125+
crc = crc16arc.checksum(crcdat)
126126
crcdat = bytearray(b'\xff'*6)
127127
f.write(f"{crc&0xff:08b}{crc>>8:08b}")
128128
f.write('1'*48)

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
],
2020
install_requires=[
2121
'numpy',
22-
'crcmod',
22+
'crc',
2323
],
2424
python_requires='>=3.6',
2525
package_data={

0 commit comments

Comments
 (0)