Home / Learn Verilog / Project 19: Simple Hash Core (Checksum and Mixer)

Project 19: Simple Hash Core (Checksum and Mixer)

A mixing round and a Fletcher-style checksum, with the real SHA idea.

Bottom lineA mixing round and a Fletcher-style checksum, with the real SHA idea.

Breaking it down

Hashmessagepaddinground FSMdigest
Hash

Definition

Build a small hash-like mixing core with rotates, XOR and additions, and a Fletcher checksum. Learn how the real SHA-256 round functions are built from the same pieces.

Why you need this

Projects turn knowledge into skill: you design, simulate, debug and finally see real hardware react.

How it works

Simulate in the browser, then build for your board following the steps.

Where you'll see this

  • Portfolio
  • Interviews
  • Learning by doing

What you will build

Build a small hash-like mixing core with rotates, XOR and additions, and a Fletcher checksum. Learn how the real SHA-256 round functions are built from the same pieces.

LevelTimeWorks in simulation only?
Advanced6 hoursSimulation; this is a teaching hash, not secure

What you need (equipment and tools)

Read this table once and you will know exactly what to buy or prepare. You can do the simulation part with only a computer and the free tools.

ItemWhat it is (in simple words)Why you need itApprox. cost
Computer (Windows, Linux or macOS)Your normal laptop or desktop. You write Verilog here and run the free tools.Simulator, synthesis and programmer all run on it.you have it
Free software: Icarus Verilog + GTKWave (simulation), Yosys + nextpnr or the vendor IDE (build), openFPGALoader (program)The programs that compile and simulate your design.Everything in this course can be simulated with only these free tools.free
FPGA development board (e.g. Tang Nano 9K, Basys 3, iCEBreaker, Arty A7)A small circuit board with an FPGA chip, an oscillator (clock), LEDs, buttons and a USB port. The FPGA is the "blank hardware" that your Verilog turns into a real circuit.This is where your design actually runs. Without it you can only simulate.about $15 (Tang Nano 9K) to $150 (Arty A7)
USB-to-serial adapter (CP2102, CH340 or FT232, 3.3 V level)A small dongle that turns USB into TX/RX pins that a UART design can talk to.Lets the PC send/receive bytes with your design in a terminal program.$3

Connections

SignalDirectionGoes toNote
uart_rxinputbytes to hash
uart_txoutputresult bytes

Step 1: simulate the design

Mixing rounds with rotate and XORVerilog: edit and run

The exact value matters less than the idea: small changes in input flip many output bits.

Step by step

  1. Run the mixer and change one letter; compare outputs.
  2. Count how many bits differ between the two hashes.
  3. Convert the loop into a one-round-per-clock FSM.
  4. Read the SHA-256 spec and implement the sigma functions.
  5. Add UART input and output.

If it does not work

SymptomLikely causeFix
Board not detectedCharge-only cable or no driverUse a data cable, install the vendor driver
Nothing happensWrong pin constraintsRecheck every pin against the board manual
Different result each runUninitialized stateSet the initial value
Rotate wrongShift amountUse (v << n) | (v >> (32-n))
Tip:Keep your first board test tiny: if the LED blinks, the toolchain, cable and clock are fine. Then add your project piece by piece.

Test what you just read

1. Avalanche effect means...