-
Notifications
You must be signed in to change notification settings - Fork 1
Type System
FLUTSCH is strongly typed language.
The primitive types (logic, int) are 1 bit wide. To form words, these types can be aggregated into an array (logic[32], int[32]). The array width can be any integer number; if it is zero or negative, the type behaves like a void or null type. Type checking is still performed, and assigning a int[-3] to an int[-4] is still an error. We expect this regularity to simplify parametrised designs.
Types of arbitrary widths do not have a direction, e.g. logic [32]. This is in contrast to other HDLs that describe types like this: logic [31:0]. In FLUTSCH a types index always starts at 0 and the type's width is explicitly given. Multi-dimensional types (or arrays) are supported.
As hardware is intrinsically 4-state (meaning 0,1,X,U), FLUTSCH supports 4-state logic.
There are 2-state types and 4-state types, and one has to explicitly change between 4 to 2 state logic types. E.g. one has to cast a logic[32] type to Option<int[32]>, where Option<T> wraps a 2-state type so that it can represent a 4-state type.
From there one can use .unwrap() on the signal to remove the Option<T> wrapper and get the pure 2-state value.
A similar idea is to use MaybeUndefined-Types
let input: logic[32];
let index: int<32>? = input.to_int();
if let Valid(idx) = index {
for i in 0..idx {
/* do stuff */
}
} else {
output = (others => 'U');
}
Clocks and resets are special signals and should be treated as such. Therefor there is a type modifier in FLUTSCH that marks them as such. Most operations are not possible on clocks and resets, as combinational logic on clocks and resets is usually a bad idea. Use unsafe { /* ... */ } to disable the compile time checks if you need such combinational logic.