Comments

Comments, like much of Spade’s syntax, are heavily inspired by that of Rust. It has a couple types of comments and they are properly integrated into the lexer to enable features such as nested multiline comments.

Types of Comment

Spade supports 4 types of comments:

Note: One area where Spade deviates from Rust in this regard is in the lack of inclusion of block documentation comments.

Non-Documentation Comments

Non-documentation (standard line and block comments) are treated by spade as whitespace and have no semantic meaning.

Block comments support nested usage, meaning each /* must have a matching */, even if it is within another comment:

/*
*    /* Inner comment */
*/

Documentation Comments

Documentation comments are treated as a form of attribute. They are used, as the name implies, to document items and modules. Content within them is treated as markdown.

//! This is top-level documentation applying to the module represented by this file


/// This is documentation on this type
struct MyType {
    x: Type used to represent unsigned integers. The generic parameter (<N>) specReturns the value of the first branch if the condition is true, otherwise the second branch.
Note that unlike software languages, Spade does not have conditional execution. You do not conditionally assign values inside if expressiosn, you compute a value and return it.
ies the number of bits
, /// Documentation on a specReturns the value of the first branch if the condition is true, otherwise the second branch.
Note that unlike software languages, Spade does not have conditional execution. You do not conditionally assign values inside if expressiosn, you compute a value and return it.
ic field
y: Type used to represent 1 bit values, } impl MyType { /// And this is documentation on a specReturns the value of the first branch if the condition is true, otherwise the second branch.
Note that unlike software languages, Spade does not have conditional execution. You do not conditionally assign values inside if expressiosn, you compute a value and return it.
ic method
Functions together with Entities together with fn and Defines a pipeline. The number in in the parentheses is input-to-output latency of the pipeline. are the basic building blocks of Spade circuits. Unlike fn, entity can contain registers and therefore have state and unlike Defines a pipeline. The number in in the parentheses is input-to-output latency of the pipeline., they do not have a statically known latency or Defines a pipeline. The number in in the parentheses is input-to-output latency of the pipeline. structure. and Defines a pipeline. The number in in the parentheses is input-to-output latency of the pipeline. are the basic building blocks of Spade circuits. Unlike entities and pipelines, functions have no internal state, they are combinational (pure). return_self(self) -> MyType { self } }