Spade Hardware Description Language

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

Spade Spade is a new hardware description language which makes hardware description easier and less error-prone. It does this by taking lessons from software programming languages, and adding language level support for common hardware constructs, all without compromising low level control over what hardware gets generated. Key Features Language Level Pipelines Pipelines are a first class construct in Spade, making re-timing and re-pipelining trivial. The reg separates code into stages, meaning you never have to manually define pipeline registers, and that behavior is separated from physical implementation. When you need to update your design to meet timing, you can simply add or move reg statements. The compiler is smart enough to figure out when these changes affect the timing of instantiating modules and tells you where to update your code to keep the original behavior. pipeline(4) X(clk: clk, a: int<32>, b: int<32>) -> int<64> { let product = a * b; reg * 3; let result = f(a, product); reg; result } For more complex pipelines with feedback, such as a processor data path, re-timing becomes less trivial, but being able to reason about signals in stages instead of individual registers is still very helpful. Types and Enums Spade has a powerful type system with structs, arrays, tuples and sum types called enums. A strong type system makes interoperability with external or internal modules easier, and means you can refactor your code with confidence. The compiler will tell you where your changes affect the behavior of your code. Enums are of particular importance: unlike the enums of C and Verilog, they can have associated payload. You can model a value which may or may not be available with the Option enum: enum Option<T> { Some(val: T), None } Or why not model the instruction set of a CPU? enum Insn { Set { dreg: int<5>, val: int<32> }, Add { dreg: int<5>, lhs: int<5>, rhs: int<5> }, Sub { dreg: int<5>, lhs: int<5>, rhs: int<5> }, Jump { target: int<32> } } The comp...

First seen: 2025-05-12 13:27

Last seen: 2025-05-12 22:28