···1414}
15151616let pp ppf t =
1717- Format.fprintf ppf "lfsr(%d, 0x%0*X)" t.width (t.width / 4) t.state
1717+ Fmt.pf ppf "lfsr(%d, 0x%0*X)" t.width (t.width / 4) t.state
18181919let v ~taps ~seed ~width =
2020 if width < 1 || width > 62 then
2121- Fmt.invalid_arg "Lfsr.v: width %d not in [1, 62]" width);
2121+ Fmt.invalid_arg "Lfsr.v: width %d not in [1, 62]" width;
2222 let mask = if width = 62 then max_int else (1 lsl width) - 1 in
2323 { taps; width; mask; state = seed land mask }
2424
+3-3
test/test_lfsr.ml
···9393 for _ = 1 to 1000 do
9494 let bit = Lfsr.step t in
9595 if bit <> 0 && bit <> 1 then
9696- Alcotest.failf "step returned %d, expected 0 or 1" bit)
9696+ Alcotest.failf "step returned %d, expected 0 or 1" bit
9797 done
98989999(* next_byte returns 0-255 *)
···102102 for _ = 1 to 1000 do
103103 let b = Lfsr.next_byte t in
104104 if b < 0 || b > 255 then
105105- Alcotest.failf "next_byte returned %d" b)
105105+ Alcotest.failf "next_byte returned %d" b
106106 done
107107108108(* 32-bit LFSR with maximal polynomial has period 2^32-1. Verify state
···112112 for i = 1 to 100_000 do
113113 ignore (Lfsr.step t);
114114 if Lfsr.state t = 0 then
115115- Alcotest.failf "state became zero at step %d" i)
115115+ Alcotest.failf "state became zero at step %d" i
116116 done
117117118118(* {1 CCSDS TM frame randomizer test vectors}