Skip to main content

fabricgate / crc32Verified

Hardware CRC-32 calculator matching zlib.crc32 for nanopynq

License: MITAuthor: FabricGate Project
fabricgate pull fabricgate/crc32:1.0.0 --platform tangnano20k/nanopynq

Versions

Platforms (v1.0.0)

tangnano20k/nanopynqtangnano9k/nanopynq

CRC-32 calculator

A CRC-32 checksum in hardware. You send bytes to the FPGA one at a time and read back their CRC-32, the same checksum that zip files, PNG images, and Ethernet frames use. Python has it too, as zlib.crc32, so you can check the circuit's answer against the computer's.

Built with nanopynq. Nothing to install: in Chrome or Edge, on this version's page, select your board, press Open the panel, then Write to the board, Connect, and Open the notebook.

What is on the board

IPAddressWhat it is
crc0x7000the CRC-32 calculator
leds0x1000the six on-board LEDs
buttons0x2000buttons S1 and S2
sys0x0design information

The registers of crc (byte offsets):

OffsetNameAccessMeaning
0x0initwowrite anything to start over
0x4datawothe next byte (the low 8 bits of what you write)
0x8crcrothe CRC-32 of the bytes since init
0xclengthrohow many bytes were written since init

init and data are write-only: register_map omits them, and the panel does not read them.

Try it

The first cell of the notebook shows ol.crc.register_map: {'crc': 0, 'length': 0} on a freshly written board, and zlib.crc32(b"") is 0 as well.

The standard check value: the CRC-32 of b"123456789" is 0xcbf43926.

import zlib

def crc32_on_board(data):
    ol.crc.write(0x0, 0)        # init
    for b in data:
        ol.crc.write(0x4, b)    # data
    return ol.crc.read(0x8)

data = b"123456789"
hex(crc32_on_board(data)), hex(zlib.crc32(data)), ol.crc.read(0xc)

Random bytes, compared with zlib:

import os
data = os.urandom(100)
crc32_on_board(data) == zlib.crc32(data)

Each byte is one write over the USB serial link, so this is a demonstration, not a fast checksum: about a thousand bytes a second.

From local Python with pip install "nanopynq[fabricgate]":

from nanopynq import Overlay

ol = Overlay("fabricgate://fabricgate/crc32:1.0.0", board="tangnano9k")  # or board="tangnano20k"

License

MIT License. Copyright (c) 2026 FabricGate Contributors.