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_step_testbench_kernel.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 ... endmodule Handler : sig ... endval 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) @ localcycle 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.
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_effect.Component_finished.t
Hardcaml_step_testbench_kernel.Step_effect.Event.tval spawn : ('a, ('a, I_data.t) finished_event) spawnLaunch a new task within the current simulation step.
val spawn' : ('a, unit) spawnSimilar to spawn, but ignored the finished_event return value
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) @ localval spawn_io : ('a, 'i, 'o, ('a, I_data.t) finished_event) spawn_ioLaunch 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_ioSimilar 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.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 ->
(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) @ localSimilar 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) @ localSpawns 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) @ localWait 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) @ localLike 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 :
Handler.t @ local ->
((Handler.t @ local -> (unit -> unit) @ local) ->
Core.never_returns) @ localCall 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) @ localSimilar to forever, but returns unit, for convenience.
val never : Handler.t @ local -> Core.never_returnsval run_monadic_computation :
Handler.t @ local ->
(('a, O_data.t, I_data.t) Hardcaml_step_testbench_kernel.Step_monad.t ->
'a) @ localmodule As_monad : sig ... end