Linear Feedback Shift Registers for OCaml
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix merlint across 7 packages (renames, docs, Fmt patterns)

- contact: rename test_ functions
- lfsr: Fmt.invalid_arg, Alcotest.failf, Fmt.str
- tcf, sdnv, ocm: rename test_ functions in interop tests
- flexacm: shorten identifier
- mal: document pp_fine_time, pp_duration

+4 -4
+1 -1
lib/lfsr.ml
··· 18 18 19 19 let v ~taps ~seed ~width = 20 20 if width < 1 || width > 62 then 21 - invalid_arg (Fmt.str "Lfsr.v: width %d not in [1, 62]" width); 21 + Fmt.invalid_arg "Lfsr.v: width %d not in [1, 62]" width); 22 22 let mask = if width = 62 then max_int else (1 lsl width) - 1 in 23 23 { taps; width; mask; state = seed land mask } 24 24
+3 -3
test/test_lfsr.ml
··· 93 93 for _ = 1 to 1000 do 94 94 let bit = Lfsr.step t in 95 95 if bit <> 0 && bit <> 1 then 96 - Alcotest.fail (Fmt.str "step returned %d, expected 0 or 1" bit) 96 + Alcotest.failf "step returned %d, expected 0 or 1" bit) 97 97 done 98 98 99 99 (* next_byte returns 0-255 *) ··· 102 102 for _ = 1 to 1000 do 103 103 let b = Lfsr.next_byte t in 104 104 if b < 0 || b > 255 then 105 - Alcotest.fail (Fmt.str "next_byte returned %d" b) 105 + Alcotest.failf "next_byte returned %d" b) 106 106 done 107 107 108 108 (* 32-bit LFSR with maximal polynomial has period 2^32-1. Verify state ··· 112 112 for i = 1 to 100_000 do 113 113 ignore (Lfsr.step t); 114 114 if Lfsr.state t = 0 then 115 - Alcotest.fail (Fmt.str "state became zero at step %d" i) 115 + Alcotest.failf "state became zero at step %d" i) 116 116 done 117 117 118 118 (* {1 CCSDS TM frame randomizer test vectors}