Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file hardcaml_step_testbench_intf.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130open!ImportmoduletypeS=sigmoduleI:Hardcaml.Interface.SmoduleO:Hardcaml.Interface.S(** A simulator for the design being tested. *)moduleSimulator:sigtypet=Cyclesim.With_interface(I)(O).t[@@derivingsexp_of]endmoduleI_data:Data.Swithtypet=Bits.tI.tmoduleO_data:sigtypet=Bits.tO.tBefore_and_after_edge.t[@@derivingsexp_of]valbefore_edge:t->Bits.tO.tvalafter_edge:t->Bits.tO.tincludeData.Swithtypet:=tend(** A 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]. *)type'at=('a,O_data.t,I_data.t)Step_monad.tincludeMonad.Swithtype'at:='at(** [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]. *)valcycle:?num_cycles:int(** default is 1 *)->I_data.t->O_data.tt(** [for_ i j f] does [f i], [f (i+1)], ... [f j] in sequence. If [j < i], then [for_ i
j] immediately returns unit. *)valfor_:int->int->(int->unitt)->unitt(** [delay inputs ~num_cycles] applies [inputs] for [num_cycles] clock cycles and then
returns unit. [delay] raises if [num_cycles < 0]. *)valdelay:I_data.t->num_cycles:int->unitttype('a,'b)finished_event=('a,'b)Step_monad.Component_finished.tStep_monad.Event.t(** Launch a new task within the current simulation step. *)valspawn:(O_data.t->'at)->('a,I_data.t)finished_eventt(** [merge_inputs ~parent ~child] merges the child inputs into the parent. If a child
input is [empty], the parent's value is used. *)valmerge_inputs:parent:I_data.t->child:I_data.t->I_data.t(** Launch a task from a testbench with a [cycle] funtion 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. *)valspawn_io:inputs:(parent:'i->child:I_data.t->'i)->outputs:('o->Bits.tO.t)->(O_data.t->'at)->(('a,I_data.t)finished_event,'oBefore_and_after_edge.t,'i)Step_monad.t(** Wait for the given event to occur, and extract its return value. *)valwait_for:('a,'b)finished_event->'at(** Like [wait_for] except it stops waiting after [timeout_in_cycles] and returns
[None]. Note that the spawned task continues to execute. *)valwait_for_with_timeout:('a,'b)finished_event->timeout_in_cycles:int->'aoptiont(** Call [run ~input_default:input_hold] to hold inputs their previous value if they are
unset by tasks in the testbench. *)valinput_hold:Bits.tI.t(** Call [run ~input_default:input_zero] to set inputs to zero if unset by tasks in the
testbench. *)valinput_zero:Bits.tI.t(** Run the testbench until the main task finishes. The [input_default] argument
controls what should happen if an input is unset by tasks in the testbench on any
particular cycle. If a field is set to [Bits.empty] then the previous value should
be held. Otherwise, the value provided is used as the default value for that field.
The optional timeout argument stops the simulation after the given number of steps
and returns None. Otherwise it will continue until the testbech completes. *)valrun_with_timeout:?input_default:Bits.tI.t(** default is [input_hold] *)->?show_steps:bool(** default is [false] *)->?timeout:int(** default is [None] *)->unit->simulator:Simulator.t->testbench:(O_data.t->'at)->'aoption(** Run the testbench until completion. *)valrun_until_finished:?input_default:Bits.tI.t(** default is [input_hold] *)->?show_steps:bool(** default is [false] *)->unit->simulator:Simulator.t->testbench:(O_data.t->'at)->'amoduleList:sig(** Construct a list of step monad results. The binds occurs from [0, 1, ...] which is
the same as [Deferred.List.init] but opposite to [Base.List.init]. *)valinit:int->f:(int->'at)->'alisttvaliter:'alist->f:('a->unitt)->unittvaliteri:'alist->f:(int->'a->unitt)->unittvaliter2_exn:'alist->'blist->f:('a->'b->unitt)->unittvalmap:'alist->f:('a->'bt)->'blisttvalmapi:'alist->f:(int->'a->'bt)->'blisttendmoduleArray:sigvalinit:int->f:(int->'at)->'aarraytvaliter:'aarray->f:('a->unitt)->unittvaliteri:'aarray->f:(int->'a->unitt)->unittvalmap:'aarray->f:('a->'bt)->'barraytendendmoduletypeHardcaml_step_testbench=sigmoduletypeS=SmoduleBefore_and_after_edge=Before_and_after_edgemoduleMake(I:Interface.S)(O:Interface.S):SwithmoduleI:=IandmoduleO:=Oend