Skip to content

Raa-23/Huffman-ASIC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Huffman Encoding — Hardware Implementation in Verilog

A hardware-based lossless text compression and decompression system implemented in Verilog, targeting the SkyWater 130nm (sky130) PDK. The design encodes and decodes English text using a predefined Huffman tree optimized for English character frequency distribution.


Overview

Huffman Encoding assigns shorter binary codewords to more frequent characters and longer codewords to rarer ones, achieving efficient lossless compression. This project implements the full encode-decode pipeline as synthesizable RTL, verified through a file-driven Verilog testbench, and targeted for ASIC implementation using an open-source EDA flow.


Architecture

The system is built around a single dual-mode RTL module controlled by the SEL signal.

Dual-Mode Module (decoder.v)

SEL Mode Input Output
0 Encoder 8-bit ASCII char 16-bit Huffman code + length
1 Decoder 16-bit encoded bits 8-bit recovered ASCII char

Encoding Table Format

Each entry in the encoding file is a 28-bit word:

[27:24] — Code length (4 bits)
[23:8]  — Huffman code, left-justified (16 bits)
[7:0]   — ASCII character value (8 bits)

How It Works

Encoding (SEL=0)

  1. Testbench reads one ASCII character at a time from textfile
  2. Testbench scans the encoding file entry by entry, presenting each 28-bit entry to the DUT
  3. DUT compares input_ascii against encoding[7:0]; on match, outputs the Huffman code and length
  4. Testbench writes the Huffman bits to outputfile.txt
  5. Process repeats until ETX (0x03) is encountered

Decoding (SEL=1)

  1. Testbench reads the compressed bitstream from outputfile.txt, assembling 16-bit chunks
  2. DUT accumulates bits in a 32-bit internal buffer
  3. Testbench scans the encoding file; DUT compares the top bits of its buffer against each entry
  4. On match, DUT outputs the recovered ASCII character and removes the consumed bits from the buffer
  5. Testbench writes the recovered character to outputfile2.txt

EDA Tool Flow

Stage Tool
Simulation Icarus Verilog (iverilog)
Waveform Viewing GTKWave
Synthesis Yosys + sky130 PDK
Place and Route OpenROAD
Physical Verification Magic
PDK SkyWater 130nm (sky130)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors