diff options
| author | Brian Campbell | 2018-10-04 11:53:41 +0100 |
|---|---|---|
| committer | Brian Campbell | 2018-10-04 11:53:41 +0100 |
| commit | de7fda6c197fe2fdb265aa4ecfeafacaa6297a19 (patch) | |
| tree | d556a1fd2f4ef155c1855f0efe451b5e3e6b2190 /src/sail_lib.ml | |
| parent | 145860bf8fee0c4620b3c41bb49109b281df3a78 (diff) | |
| parent | 94ed5ae4b5e185e40b4bf6fbeb89cb7fe01b53ef (diff) | |
Merge branch 'ocaml-instruction-generation' into sail2
Diffstat (limited to 'src/sail_lib.ml')
| -rw-r--r-- | src/sail_lib.ml | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/sail_lib.ml b/src/sail_lib.ml index fbe700aa..28015945 100644 --- a/src/sail_lib.ml +++ b/src/sail_lib.ml @@ -1121,3 +1121,19 @@ let load_raw (paddr, file) = (* XXX this could count cycles and exit after given limit *) let cycle_count () = () + +(* TODO range, atom, register(?), int, nat, bool, real(!), list, string, itself(?) *) +let rand_zvector (g : 'generators) (size : int) (order : bool) (elem_gen : 'generators -> 'a) : 'a list = + List.init size (fun _ -> elem_gen g) + +let rand_zbit (g : 'generators) : bit = + if Random.bool() then B0 else B1 + +let rand_zbool (g : 'generators) : bool = + Random.bool() + +let rand_zunit (g : 'generators) : unit = () + +let rand_choice l = + let n = List.length l in + List.nth l (Random.int n) |
