File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change 1+ /**
2+ * Computes the number of bits needed to represent the constant [N].
3+ * Usage:
4+ * ```filament
5+ * BN := new BitsNeeded[N];
6+ * let Bits = BN::Out; // Out represents number of bits for [N]
7+ * ```
8+ */
9+ comp BitsNeeded[N]<'G:1>() -> () with {
10+ some Out where Out == log2(N)+1, Out > 0;
11+ } {
12+ let Bits = log2(N)+1; assume Bits > 0;
13+ Out := Bits;
14+ }
Original file line number Diff line number Diff line change 11import "primitives/core.fil";
2+ import "primitives/param-funcs.fil";
23
34// A highly parameterized serializer. The parameters are:
45// * W: The width of the inputs
@@ -201,7 +202,8 @@ comp CollectValid[W, N]<'G:1>(
201202 out[N]: ['G, 'G+1] W,
202203 block_valid: ['G, 'G+1] 1
203204) where W > 0 {
204- let Bits = log2(N)+1; assume Bits > 0;
205+ BN := new BitsNeeded[N];
206+ let Bits = BN::Out;
205207
206208 // Increment the index if the value on the stream is valid
207209 idx := new Prev[Bits, 1]<'G>(reset.out);
You can’t perform that action at this time.
0 commit comments