Skip to content

oisee/zvdb-minz

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

8 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

ZVDB-MinZ

A 256-bit vector database implementation in MinZ, demonstrating modern AI/ML algorithms on Z80 hardware.

๐ŸŽฏ What is ZVDB?

ZVDB (Z80 Vector Database) is a 1-bit quantized vector similarity search system designed for vintage computing hardware. This MinZ implementation showcases how modern vector database concepts can run efficiently on 1980s processors.

๐Ÿš€ Features

Vector Database Core

  • 256-bit binary vectors for compact representation
  • Hamming distance for fast similarity computation
  • Popcount optimization with lookup tables (3.3x speedup*)
  • K-nearest neighbors search
  • Bit-packed structures for 67% memory savings on metadata**
  • Comprehensive test suite with 20+ test cases

๐Ÿ”’ Cryptographic Engine

  • Complete SHA256 implementation in pure Z80 assembly (commit 2b870c2)
  • High-performance 32-bit operations: ADD32 (34 T-states), XOR32 (56 T-states)
  • Page-aligned memory layout for optimal Z80 performance
  • ~45,000 T-states per 512-bit block (~11ms @ 4MHz, ~45KB/sec throughput)
  • Memory efficient: <2KB total including constants and workspace
  • Vector fingerprinting for deduplication and integrity verification

* For bit counting operations specifically
** Metadata only; vectors still require full 256 bits

๐Ÿ“ฆ Repository Structure

zvdb-minz/
โ”œโ”€โ”€ README.md              # This file
โ”œโ”€โ”€ zvdb.minz              # Main ZVDB implementation
โ”œโ”€โ”€ zvdb.a80               # Generated Z80 assembly (for verification)
โ”œโ”€โ”€ zvdb_test.minz         # Test suite
โ”œโ”€โ”€ zvdb_test.a80          # Test suite assembly (for verification)
โ”œโ”€โ”€ run_zvdb_tests.sh      # Test runner
โ”œโ”€โ”€ ZVDB_README.md         # Performance analysis
โ”œโ”€โ”€ sha256_z80.asm         # ๐Ÿ”ฅ High-performance SHA256 implementation
โ”œโ”€โ”€ SHA256_README.md       # SHA256 documentation
โ”œโ”€โ”€ sha256_integration.minz # MinZ/assembly integration examples  
โ”œโ”€โ”€ simple_sha256_demo.minz # Simple MinZ demonstration
โ””โ”€โ”€ zvdb_experiments/      # Development iterations

๐Ÿ” Verify Our Claims!

The .a80 assembly files are included so you can:

  • Count actual T-states for operations
  • Verify the SMC optimizations
  • Check the popcount LUT implementation
  • See exactly what code runs on your Z80

The SHA256 implementation (sha256_z80.asm) includes:

  • All 1,438 lines of optimized Z80 assembly code
  • Performance annotations with exact T-state counts
  • Test function with known hash verification
  • Complete technical documentation

๐Ÿ› ๏ธ Requirements

  • MinZ compiler v0.9.0+
  • Z80 assembler (sjasmplus) for final binary generation
  • Z80 hardware or emulator for execution

๐ŸŽฎ Quick Start

# Clone the repository
git clone https://github.com/oisee/zvdb-minz
cd zvdb-minz

# Run tests (requires MinZ compiler)
./run_zvdb_tests.sh

# Compile to Z80 assembly
minzc zvdb.minz -o zvdb.a80

# Assemble to binary (requires sjasmplus)
sjasmplus zvdb.a80

# Load at 0x8000 on your Z80 system

๐Ÿ“Š Performance

Vector Database Performance

Metric Value Notes
Vector size 256 bits 32 bytes per vector
Popcount speedup 3.3x LUT vs bit loop
Metadata compression 67% Using bit fields
Development time Hours vs days in assembly
Test coverage 20+ cases Comprehensive suite

SHA256 Cryptographic Performance

Metric Value Notes
Throughput ~45KB/sec @ 4MHz Z80
T-states per block ~45,000 512-bit blocks
Memory footprint <2KB Including workspace
ADD32 performance 34 T-states Fastest possible on Z80
XOR32 performance 56 T-states Optimized via A register

See ZVDB_README.md for detailed performance analysis with honest benchmarks and disclaimers.

๐Ÿ”— Related Projects

๐Ÿค Contributing

This is a demonstration project showing MinZ capabilities. Feel free to:

  • Port to other vintage platforms
  • Optimize further
  • Add new similarity metrics
  • Improve test coverage

๐Ÿ“œ License

MIT License - See LICENSE file for details

๐Ÿ™ Acknowledgments

  • The MinZ compiler team (=myself and my imaginary friend Claude Code) for making Z80 development fun again
  • The Z80 community for keeping vintage computing alive
  • Researchers working on 1-bit quantization making AI accessible to all hardware

โš ๏ธ Disclaimer

This implementation has been tested in compilation but not on actual Z80 hardware. Performance claims are based on T-state analysis and estimates. Your mileage may vary. But hey, it compiles! ๐ŸŽ‰


Built with โค๏ธ for the intersection of vintage computing and modern AI

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors