Functional.Makemodule I : Hardcaml.Interface.Smodule O : Hardcaml.Interface.Smodule Io_ports_for_imperative =
Hardcaml_step_testbench_kernel.Io_ports_for_imperativemodule Before_and_after_edge = Hardcaml.Before_and_after_edgemodule I = Imodule O = Omodule I_data : Digital_components.Data.S with type t = Hardcaml.Bits.t I.tmodule O_data : sig ... endtype 'a t =
('a, O_data.t, I_data.t) Hardcaml_step_testbench_kernel.Step_monad.tA testbench takes the circuit's output as its input and produces its output as input for the circuit. An 'a t describes a testbench computation that takes zero or more steps and produces a value of type 'a.
include Core.Monad.S with type 'a t := 'a tval return : 'a 'i 'p 'q. 'a -> 'a tConvert a value to a t.
Sequences computations. bind t ~f computes f v for value(s) v in t. Well-behaved monads satisfy these "laws" (where ( >>= ) is the infix bind operator):
map t ~f is equivalent to bind t ~f:(fun x -> return (f x))return x >>= f is equivalent to f xt >>= return is equivalent to t(t >>= f) >>= g is equivalent to t >>= fun x -> f x >>= gCombines nested t into just one layer. Equivalent to bind t ~f:Fn.id.
Ignores contained values of t. Equivalent to map t ~f:ignore.
module Monad_infix : sig ... endmodule Let_syntax : sig ... endval start :
('a -> 'b t) ->
'a ->
('b, I_data.t) Hardcaml_step_testbench_kernel.Step_monad.Component_finished.t
tcycle 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.
for_ i j f does f i, f (i+1), ... f j in sequence. If j < i, then for_ i j immediately returns unit.
delay inputs ~num_cycles applies inputs for num_cycles clock cycles and then returns unit. delay raises if num_cycles < 0.
type ('a, 'b) finished_event =
('a, 'b) Hardcaml_step_testbench_kernel.Step_monad.Component_finished.t
Hardcaml_step_testbench_kernel.Step_monad.Event.tval spawn :
?update_children_after_finish:bool ->
?period:int ->
(O_data.t -> 'a t) ->
('a, I_data.t) finished_event tLaunch a new task within the current simulation step.
merge_inputs ~parent ~child merges the child inputs into the parent. If a child input is empty, the parent's value is used.
val 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_data.t -> 'a t) ->
(('a, I_data.t) finished_event, 'o Before_and_after_edge.t, 'i)
Hardcaml_step_testbench_kernel.Step_monad.tLaunch 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 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.tCreate 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 ->
(O_data.t -> 'a t) ->
(('a, I_data.t) finished_event, unit Before_and_after_edge.t, unit)
Hardcaml_step_testbench_kernel.Step_monad.tSimilar 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 ->
(O_data.t -> Core.never_returns t) ->
(Core.never_returns, unit Before_and_after_edge.t, unit)
Hardcaml_step_testbench_kernel.Step_monad.tSpawns 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 : ('a, 'b) finished_event -> 'a tWait for the given event to occur, and extract its return value.
val wait_for_with_timeout :
('a, 'b) finished_event ->
timeout_in_cycles:int ->
'a option tLike 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.tCall 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.tCall run ~input_default:input_zero to set inputs to zero if unset by tasks in the testbench.
val forever : (unit -> unit t) -> Core.never_returns tCall 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 never : Core.never_returns tval run_effectful_computation :
((O_data.t, I_data.t) Digital_components.Step_effect.Handler.t @ local -> 'a) ->
'a tmodule List : sig ... endmodule Array : sig ... end