def U32Word.mask

bend-osdev-u32@0.1.0.0 · u32.bend:72

import bend-osdev-u32@0.1.0.0/u32.bend as U32
import Base

72# the word of width n whose low k bits are set (2^k - 1, for k <= n): the
73# mask that U32.and(x, m) takes x's low k bits with
74def U32Word.mask(n: Nat, k: Nat) -> Word(n):
75  match n:
76    case 0n:
77      WNil{}
78    case 1n+p:
79      match k:
80        case 0n:
81          Word.zero(1n+p)
82        case 1n+j:
83          WCon{True{}, U32Word.mask(p, j)}

Uses (6)

Used by (5)