jvm.chisel.db

Fragment builders shared by the hardware database operators.

These functions do not build modules; they return Chisel Data values (or Clojure vectors of them) assembled from jvm.chisel primitives, meant to be called inside a jvm.chisel/module body. Keeping them as fragments lets the operators in jvm.chisel.db.* compose into larger datapaths.

cmp-vec

(cmp-vec values constant op n)

Lane-parallel compare of a Vec values against constant with op (a jvm.chisel comparison fn: eq/neq/lt/lte/gt/gte). Returns a Clojure vector of n Bool Data (lsb-first lane order).

gated

(gated values mask n identity-data)

Gate each lane of values (Vec n UInt(w)) by a bitmask: lane i becomes (mux mask[i] values[i] identity). identity-data is a Data of width w.

log2

(log2 n)

ceil(log2 n): depth of an n-leaf reduction tree (for sum-width bookkeeping).

log2-ceil

(log2-ceil n)

Smallest number of bits that can represent values 0..n (i.e. ceil(log2(n+1))).

mask-pack

(mask-pack bits)

Pack a Clojure seq of Bool/Bits into a UInt bitmask (lsb first).

mhash

(mhash key width k log-n)

Multiplicative hash: high log-n bits of (key * K) viewed as 2*width bits. key is UInt(width); returns UInt(log-n).

one-hot

(one-hot idx width)

UInt(width) with the single (dynamic) bit idx set: 1 << idx.

op->fn

map from comparison keyword to the jvm.chisel operator

popcount

(popcount mask n)

Sum of the set bits of a bitmask mask of width n (adder tree). Leaves are zero-extended to the result width before summing so the tree never adds two 1-bit values (see widen).

tree-reduce

(tree-reduce combine zero elems)

Balanced binary tree reduction of a Clojure vector of Data using combine (a fn of two Data -> Data). zero is the identity for empty input.