Show HN: SHDL โ€“ A minimal hardware description language built from logic gates

https://news.ycombinator.com/rss Hits: 2
Summary

SHDL - Simple Hardware Description Language A lightweight hardware description language and Python driver for digital circuit simulation using exclusively logic gates! SHDL provides an intuitive syntax for defining digital circuits and a clean Python API for interacting with them (PySHDL). Features ๐Ÿš€ Simple Syntax - Easy-to-learn hardware description language - Easy-to-learn hardware description language ๐Ÿ Python Integration - Seamless Python API for circuit simulation - Seamless Python API for circuit simulation โšก C Backend - Compiles to optimized C code for fast simulation and portability - Compiles to optimized C code for fast simulation and portability ๐Ÿ”ง Command Line Tools - Built-in compiler and utilities - Built-in compiler and utilities ๐Ÿ“ฆ Component Reuse - Import and compose reusable circuit components - Import and compose reusable circuit components ๐Ÿ”ข Constants Support - Use named constants for parameterizable designs Installation We recommend using uv for using PySHDL. If you don't have it installed, you can install it via pip: pip install PySHDL Quick Start 1. Define a Circuit (SHDL) Create a file fullAdder.shdl : component FullAdder(A, B, Cin) -> (Sum, Cout) { x1: XOR; a1: AND; x2: XOR; a2: AND; o1: OR; connect { A -> x1.A; B -> x1.B; A -> a1.A; B -> a1.B; x1.O -> x2.A; Cin -> x2.B; x1.O -> a2.A; Cin -> a2.B; a1.O -> o1.A; a2.O -> o1.B; x2.O -> Sum; o1.O -> Cout; } } 2. Use in Python from SHDL import Circuit # Load and compile the circuit with Circuit ( "fullAdder.shdl" ) as c : # Set input values c . poke ( "A" , 1 ) c . poke ( "B" , 1 ) c . poke ( "Cin" , 1 ) # Run simulation c . step ( 10 ) # Read output result = c . peek ( "Sum" ) print ( f"Result: { result } " ) # Output: Result: 60 3. Compile from Command Line # Compile SHDL to C shdlc adder.shdl -o adder.c # Compile and build executable shdlc adder.shdl --optimize 3 CLI Options shdlc [options] <input.shdl> Options: -o, --output FILE Output C file (default: <input>.c) -I, --include DIR Add directory...

First seen: 2026-01-28 19:28

Last seen: 2026-01-28 20:28