123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243(** Interfaces specify the widths and names of a group of signals, and some functions for
manipulating the signals as a group.
They are generally used with [ppx_deriving_hardcaml] as follows
{[
type t = { ... } [@@deriving sexp_of, hardcaml]
]}
The [sexp_of] is required, and must appear before [hardcaml]. This syntax
generates a call to [Interface.Make], which therefore does not need to be
explicitly called. *)open!ImportmoduletypePre=sigtype'at[@@derivingsexp_of]valt:(string*int)tvaliter:'at->f:('a->unit)->unitvaliter2:'at->'bt->f:('a->'b->unit)->unitvalmap:'at->f:('a->'b)->'btvalmap2:'at->'bt->f:('a->'b->'c)->'ctvalto_list:'at->'alistendmoduletypeAst=sig(** The PPX can optionally generate an [ast] field containing an [Ast.t]. This
represents the structure of the interface, including how it is constructed from
fields, arrays, lists and sub-modules.
This is of particular use when generating further code from the interface i.e. a
register interace specification.
[ast]s are not generated by default. *)modulerecAst:sigtypet=Field.tlist[@@derivingsexp_of]endandField:sigtypet={name:string(** Name of the field *);type_:Type.t(** Field type - a signal or a sub-module *);sequence:Sequence.toption(** Is the field type an array or list? *);doc:stringoption(** Ocaml documentation string, if any. Note that this must be placed in the [ml]
and not [mli].*)}[@@derivingsexp_of]endandType:sigtypet=|Signalof{bits:int;rtlname:string}|Moduleof{name:string;ast:Ast.t}[@@derivingsexp_of]endandSequence:sigmoduleKind:sigtypet=Array|List[@@derivingsexp_of]endtypet={kind:Kind.t;length:int}[@@derivingsexp_of]endtypet=Ast.t[@@derivingsexp_of]endmoduletypeComb=sigtype'ainterfacetypecombtypet=combinterface[@@derivingsexp_of](** Actual bit widths of each field. *)valwidths:t->intinterface(** Each field is set to the constant integer value provided. *)valconst:int->t(** [consts c] sets each field to the integer value in [c] using the declared field bit
width. *)valconsts:intinterface->t(** Pack interface into a vector. *)valpack:?rev:bool->t->comb(** Unpack interface from a vector. *)valunpack:?rev:bool->comb->t(** Multiplex a list of interfaces. *)valmux:comb->tlist->tvalmux2:comb->t->t->t(** Concatenate a list of interfaces. *)valconcat:tlist->tendmoduletypeS=sigincludePreincludeEqual.S1withtype'at:='at(** RTL names specified in the interface definition - commonly also the OCaml field
name. *)valport_names:stringt(** Bit widths specified in the interface definition. *)valport_widths:intt(** Create association list indexed by field names. *)valto_alist:'at->(string*'a)list(** Create interface from association list indexed by field names *)valof_alist:(string*'a)list->'atvalzip:'at->'bt->('a*'b)tvalzip3:'at->'bt->'ct->('a*'b*'c)tvalzip4:'at->'bt->'ct->'dt->('a*'b*'c*'d)tvalzip5:'at->'bt->'ct->'dt->'et->('a*'b*'c*'d*'e)tvalmap3:'at->'bt->'ct->f:('a->'b->'c->'d)->'dtvalmap4:'at->'bt->'ct->'dt->f:('a->'b->'c->'d->'e)->'etvalmap5:'at->'bt->'ct->'dt->'et->f:('a->'b->'c->'d->'e->'f)->'ftvaliter3:'at->'bt->'ct->f:('a->'b->'c->unit)->unitvaliter4:'at->'bt->'ct->'dt->f:('a->'b->'c->'d->unit)->unitvaliter5:'at->'bt->'ct->'dt->'et->f:('a->'b->'c->'d->'e->unit)->unitvalfold:'at->init:'b->f:('b->'a->'b)->'bvalfold2:'at->'bt->init:'c->f:('c->'a->'b->'c)->'c(** Offset of each field within the interface. The first field is placed at the least
significant bit, unless the [rev] argument is true. *)valoffsets:?rev:bool(** default is [false]. *)->unit->intt(** Take a list of interfaces and produce a single interface where each field is a
list. *)valof_interface_list:'atlist->'alistt(** Create a list of interfaces from a single interface where each field is a list.
Raises if all lists don't have the same length. *)valto_interface_list:'alistt->'atlistmoduletypeComb=Combwithtype'ainterface:='atmoduleMake_comb(Comb:Comb.S):Combwithtypecomb=Comb.tmoduleOf_bits:Combwithtypecomb=Bits.tmoduleOf_signal:sigincludeCombwithtypecomb=Signal.t(** Create a wire for each field. If [named] is true then wires are given the RTL field
name. If [from] is provided the wire is attached to each given field in [from]. *)valwires:?named:bool(** default is [false]. *)->?from:t(** No default *)->unit->tvalassign:t->t->unitval(<==):t->t->unit(** [inputs t] is [wires () ~named:true]. *)valinputs:unit->t(** [outputs t] is [wires () ~from:t ~named:true]. *)valoutputs:t->tendendmoduletypeEmpty=sigtype'at=NoneincludeSwithtype'at:='atendmoduletypeInterface=sigmoduletypePre=PremoduletypeS=SmoduletypeAst=AstmoduletypeEmpty=EmptymoduleAst:AstmoduleEmpty:EmptymoduletypeS_with_ast=sigincludeSvalast:Ast.tend(** Type of functions representing the implementation of a circuit from an input to
output interface. *)moduleCreate_fn(I:S)(O:S):sigtype'at='aI.t->'aO.t[@@derivingsexp_of]endmoduleMake(X:Pre):Swithtype'at:='aX.tend