core

LatencyOffset #(T, int OFFSET)

Unsafe builtin to circumvent the Latency Counting System. Connects dout to din without adding the requisite latency Or: used for negative latencies, for instance to implement Almost-Full FIFOs, stateful for loops, etc.

module LatencyOffset #(T, int OFFSET) {
    interface LatencyOffset : T din'0 -> T dout'OFFSET
}

CrossDomain #(T)

Unsafe builtin to connect wires from different clock domains. Important: This is a plain connection from a wire in one clock domain to a wire in another. This performs no synchronization or other data integrity measures!

module CrossDomain #(T) {
    clock in_clk
    input T din'0
    clock out_clk
    output T dout'0
}

LatencyOffsetAction #(T, int OFFSET, int DATA_DELAY)

module LatencyOffsetAction #(T, int OFFSET, int DATA_DELAY) {
    action din'0 : T data_i'DATA_DELAY
    trigger dout'OFFSET : T data_o'OFFSET+DATA_DELAY
}

LatencyOffsetActionNoData #(int OFFSET)

module LatencyOffsetActionNoData #(int OFFSET) {
    action din'0
    trigger dout'OFFSET
}

IntToBits #(int NUM_BITS)

Convert signed int to 2s complement bits. (bits[0] is value's Least Significant Bit)

Requires -pow2 #(E: NUM_BITS - 1) <= value < pow2 #(E: NUM_BITS - 1)

Runtime equivalent of IntToBitsGen

module IntToBits #(int NUM_BITS) {
    interface IntToBits : int #(FROM: -pow2 #(E: NUM_BITS - 1), TO: pow2 #(E: NUM_BITS - 1)) value'0 -> bool[NUM_BITS] bits'0
}

UIntToBits #(int NUM_BITS)

Convert int to unsigned bits. (bits[0] is value's Least Significant Bit)

Requires 0 <= value < pow2 #(E: NUM_BITS)

Runtime equivalent of UIntToBitsGen

module UIntToBits #(int NUM_BITS) {
    interface UIntToBits : int #(FROM: 0, TO: pow2 #(E: NUM_BITS)) value'0 -> bool[NUM_BITS] bits'0
}

BitsToInt #(int NUM_BITS)

Convert 2s complement bits to a signed int. (bits[0] is value's Least Significant Bit)

Creates an int in the range -pow2 #(E: NUM_BITS - 1) <= value < pow2 #(E: NUM_BITS - 1)

Runtime equivalent of BitsToIntGen

module BitsToInt #(int NUM_BITS) {
    interface BitsToInt : bool[NUM_BITS] bits'0 -> int #(FROM: -pow2 #(E: NUM_BITS - 1), TO: pow2 #(E: NUM_BITS - 1)) value'0
}

BitsToUInt #(int NUM_BITS)

Convert unsigned bits to an unsigned int. (bits[0] is value's Least Significant Bit)

Creates an int in the range 0 <= value < pow2 #(E: NUM_BITS)

Runtime equivalent of BitsToUIntGen

module BitsToUInt #(int NUM_BITS) {
    interface BitsToUInt : bool[NUM_BITS] bits'0 -> int #(FROM: 0, TO: pow2 #(E: NUM_BITS)) value'0
}

ToBits #(T)

Bitwise conversion of type T to a sizeof#(T)-bit bitset.

module ToBits #(T) {
    interface ToBits : T value'0 -> bool[sizeof #(T)] bits'0
}

FromBits #(T)

Bitwise conversion of a sizeof#(T)-bit bitset to type T.

module FromBits #(T) {
    interface FromBits : bool[sizeof #(T)] bits'0 -> T value'0
}

Transmute #(T1, T2)

Bitwise conversion of T1 into T2. sizeof#(T: type T1) == sizeof#(T: type T2)

module Transmute #(T1, T2) {
    interface Transmute : T1 a'0 -> T2 b'0
}

IntNarrow #(int FROM_I, int TO_I, int FROM, int TO)

Unsafely shrinks the bounds of an integer. The result is not defined if the value lies outside the FROM:TO range. For folding behavior choose the mod operator instead.

module IntNarrow #(int FROM_I, int TO_I, int FROM, int TO) {
    interface IntNarrow : int#(FROM: FROM_I, TO: TO_I) din'0 -> int#(FROM, TO) dout'0
}