Linear Feedback Shift Registers for OCaml
0
fork

Configure Feed

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

pus: rename test_ functions, fix service_type doc (merlint E330/E410)

+3 -6
+1 -2
lib/lfsr.ml
··· 13 13 mutable state : int; 14 14 } 15 15 16 - let pp ppf t = 17 - Fmt.pf ppf "lfsr(%d, 0x%0*X)" t.width (t.width / 4) t.state 16 + let pp ppf t = Fmt.pf ppf "lfsr(%d, 0x%0*X)" t.width (t.width / 4) t.state 18 17 19 18 let v ~taps ~seed ~width = 20 19 if width < 1 || width > 62 then
+2 -4
test/test_lfsr.ml
··· 101 101 let t = Lfsr.ccsds_oid () in 102 102 for _ = 1 to 1000 do 103 103 let b = Lfsr.next_byte t in 104 - if b < 0 || b > 255 then 105 - Alcotest.failf "next_byte returned %d" b 104 + if b < 0 || b > 255 then Alcotest.failf "next_byte returned %d" b 106 105 done 107 106 108 107 (* 32-bit LFSR with maximal polynomial has period 2^32-1. Verify state ··· 111 110 let t = Lfsr.ccsds_oid () in 112 111 for i = 1 to 100_000 do 113 112 ignore (Lfsr.step t); 114 - if Lfsr.state t = 0 then 115 - Alcotest.failf "state became zero at step %d" i 113 + if Lfsr.state t = 0 then Alcotest.failf "state became zero at step %d" i 116 114 done 117 115 118 116 (* {1 CCSDS TM frame randomizer test vectors}