Module Functional.Make

Parameters

Signature

module I = I
module O = O
module O_data : sig ... end
module Handler : sig ... end
val start : Handler.t @ local -> ((Handler.t @ local -> ('a -> 'b) @ local) -> ('a -> ('b, I_data.t) Hardcaml_step_testbench_kernel.Step_effect.Component_finished.t) @ local) @ local
val cycle : Handler.t @ local -> (?num_cycles:int -> (I_data.t -> O_data.t) @ local) @ local

cycle i_data ~num_cycles waits for num_cycles cycles of the simulator to run, applying i_data to the simulator input ports, and returns the output computed in the final cycle. cycle raises if num_cycles < 1.

val delay : ?num_cycles:int -> Handler.t @ local -> (I_data.t -> unit) @ local

delay inputs ~num_cycles applies inputs for num_cycles clock cycles and then returns unit. delay raises if num_cycles < 0.

type ('a, 'ret) spawn := ?update_children_after_finish:bool -> ?period:int -> Handler.t @ local -> ((Handler.t @ local -> (O_data.t -> 'a) @ local) -> 'ret) @ local
val spawn : ('a, ('a, I_data.t) finished_event) spawn

Launch a new task within the current simulation step.

val spawn' : ('a, unit) spawn

Similar to spawn, but ignored the finished_event return value

val merge_inputs : parent:I_data.t -> child:I_data.t -> I_data.t

merge_inputs ~parent ~child merges the child inputs into the parent. If a child input is empty, the parent's value is used.

type ('a, 'i, 'o, 'ret) spawn_io := ?update_children_after_finish:bool -> ?period:int -> inputs:(parent:'i -> child:I_data.t -> 'i) -> outputs:('o -> Hardcaml.Bits.t O.t) -> ('o Before_and_after_edge.t, 'i) Hardcaml_step_testbench_kernel.Step_effect.Handler.t @ local -> ((Handler.t @ local -> (O_data.t -> 'a) @ local) -> 'ret) @ local
val spawn_io : ('a, 'i, 'o, ('a, I_data.t) finished_event) spawn_io

Launch a task from a testbench with a cycle function taking 'i to 'o. The inputs and outputs arguments should construct I_data.t and O_data.t from the types of the child testbench.

See documentation of spawn for an explaination of update_children_after_finish.

val spawn_io' : ('a, 'i, 'o, unit) spawn_io

Similar to spawn_io, but ignored the finished_event return value

val create_io_ports_for_imperative : ('i, 'o) Hardcaml.Cyclesim.t -> inputs:('i -> Hardcaml.Bits.t Core.ref I.t) -> outputs:('o -> Hardcaml.Bits.t Core.ref O.t) -> (Hardcaml.Bits.t Core.ref I.t, Hardcaml.Bits.t Core.ref O.t) Io_ports_for_imperative.t

Create io ports to be used with spawn_from_imperative from a simulator.

val spawn_from_imperative : ?update_children_after_finish:bool -> ?period:int -> (Hardcaml.Bits.t Core.ref I.t, Hardcaml.Bits.t Core.ref O.t) Io_ports_for_imperative.t -> (unit Before_and_after_edge.t, unit) Hardcaml_step_testbench_kernel.Step_effect.Handler.t @ local -> ((Handler.t @ local -> (O_data.t -> 'a) @ local) -> ('a, I_data.t) finished_event) @ local

Similar to spawn_io, but for a task (which uses the functional step testbench) from a task that's using the imperative step testbench.

val exec_never_returns_from_imperative : ?update_children_after_finish:bool -> ?period:int -> (Hardcaml.Bits.t Core.ref I.t, Hardcaml.Bits.t Core.ref O.t) Io_ports_for_imperative.t -> (unit Before_and_after_edge.t, unit) Hardcaml_step_testbench_kernel.Step_effect.Handler.t @ local -> ((Handler.t @ local -> (O_data.t -> Core.never_returns) @ local) -> Core.never_returns) @ local

Spawns a functional step testbench infinite loop from a imperative testbench, and block forever.

This semantically similar to spawn_from_imperative >>= wait_for under the hood but with nicer types.

val wait_for : Handler.t @ local -> (('a, 'b) finished_event -> 'a) @ local

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

val wait_for_with_timeout : Handler.t @ local -> (('a, 'b) finished_event -> (timeout_in_cycles:int -> 'a option) @ local) @ local

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

val input_hold : Hardcaml.Bits.t I.t

Call run ~input_default:input_hold to hold inputs their previous value if they are unset by tasks in the testbench.

val input_zero : Hardcaml.Bits.t I.t

Call run ~input_default:input_zero to set inputs to zero if unset by tasks in the testbench.

val forever : Handler.t @ local -> ((Handler.t @ local -> (unit -> unit) @ local) -> Core.never_returns) @ local

Call forever f to run f forever. forever never returns.

To prevent starving other tasks, it's the caller's responsibility to ensure that f calls cycle or delay under the hood!

val forever_unit : Handler.t @ local -> ((Handler.t @ local -> (unit -> unit) @ local) -> unit) @ local

Similar to forever, but returns unit, for convenience.

val never : Handler.t @ local -> Core.never_returns
val run_monadic_computation : Handler.t @ local -> (('a, O_data.t, I_data.t) Hardcaml_step_testbench_kernel.Step_monad.t -> 'a) @ local
module As_monad : sig ... end