package hardcaml_step_testbench

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
module Monads : sig ... end
module type S = sig ... end
include S
include Imperative.S with module Step_monad = Monads.Step_monad
module No_data : Digital_components.Data.S with type t = unit
module Step_monad = Monads.Step_monad
type 'a t = ('a, No_data.t, No_data.t) Step_monad.t
include Core.Monad.S with type 'a t := 'a t
val (>>=) : 'a t -> ('a -> 'b t) -> 'b t

t >>= f returns a computation that sequences the computations represented by two monad elements. The resulting computation first does t to yield a value v, and then runs the computation returned by f v.

val (>>|) : 'a t -> ('a -> 'b) -> 'b t

t >>| f is t >>= (fun a -> return (f a)).

module Monad_infix : sig ... end
val bind : 'a t -> f:('a -> 'b t) -> 'b t

bind t ~f = t >>= f

val return : 'a -> 'a t

return v returns the (trivial) computation that returns v.

val map : 'a t -> f:('a -> 'b) -> 'b t

map t ~f is t >>| f.

val join : 'a t t -> 'a t

join t is t >>= (fun t' -> t').

val ignore_m : 'a t -> unit t

ignore_m t is map t ~f:(fun _ -> ()). ignore_m used to be called ignore, but we decided that was a bad name, because it shadowed the widely used Stdlib.ignore. Some monads still do let ignore = ignore_m for historical reasons.

val all : 'a t list -> 'a list t
val all_unit : unit t list -> unit t

Like all, but ensures that every monadic value in the list produces a unit value, all of which are discarded rather than being collected into a list.

module Let_syntax : sig ... end

These are convenient to have in scope when programming with a monad:

val cycle : ?num_cycles:int -> unit -> unit t

cycle i_data ~num_cycles waits for num_cycles cycles of the simulator to run. cycle raises if num_cycles < 1.

val for_ : int -> int -> (int -> unit t) -> unit t

for_ i j f does f i, f (i+1), ... f j in sequence. If j < i, then for_ i j immediately returns unit.

val start : ('a -> 'b t) -> 'a -> ('b, No_data.t) Step_monad.Component_finished.t t
type 'a finished_event = ('a, unit) Step_monad.Component_finished.t Step_monad.Event.t
val spawn : (unit -> 'a t) -> 'a finished_event t

Launch a new task within the current simulation step.

val wait_for : 'a finished_event -> 'a t

Wait for the given event to occur, and extract its return value.

val wait_for_with_timeout : 'a finished_event -> timeout_in_cycles:int -> 'a option t

Like wait_for except it stops waiting after timeout_in_cycles and returns None. Note that the spawned task continues to execute.

module List : sig ... end
module Array : sig ... end
val run_with_timeout : ?update_children_after_finish:bool -> ?timeout:int -> unit -> simulator:(_, _) Hardcaml.Cyclesim.t -> testbench:(No_data.t -> 'a t) -> 'a option

Run the testbench until the main task finishes.

The optional timeout argument stops the simulation after the given number of steps and returns None. Otherwise it will continue until the testbech completes.

val run_until_finished : ?update_children_after_finish:bool -> unit -> simulator:(_, _) Hardcaml.Cyclesim.t -> testbench:(No_data.t -> 'a t) -> 'a

Run the testbench until completion.

OCaml

Innovation. Community. Security.