Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file interface_intf.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292open!ImportmoduletypePre_partial=sigtype'at[@@derivingsexp_of]valiter:'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->'alistendmoduletypePre=sigincludePre_partialvalt:(string*int)tendmoduletypeAst=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(** Raise if the widths of [t] do not match those specified in the interface. *)valassert_widths:t->unit(** Each field is set to the constant integer value provided. *)valof_int:int->t(** [consts c] sets each field to the integer value in [c] using the declared field bit
width. *)valof_ints:intinterface->tvalconst:int->t[@@deprecated"[since 2019-11] interface const"]valconsts:intinterface->t[@@deprecated"[since 2019-11] interface consts"](** 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->tvalpriority_select:((comb,t)With_valid.t2list->(comb,t)With_valid.t2)Comb.optional_branching_factorvalpriority_select_with_default:((comb,t)With_valid.t2list->default:t->t)Comb.optional_branching_factorvalonehot_select:((comb,t)With_valid.t2list->t)Comb.optional_branching_factorendmoduletypeS=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:'acc->f:('acc->'a->'acc)->'accvalfold2:'at->'bt->init:'acc->f:('acc->'a->'b->'acc)->'accvalscan:'at->init:'acc->f:('acc->'a->'acc*'b)->'btvalscan2:'at->'bt->init:'acc->f:('acc->'a->'b->'acc*'c)->'ct(** 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->t(** Apply name to field of the interface. Add [prefix] and [suffix] if specified. *)valapply_names:?prefix:string(** Default is [""] *)->?suffix:string(** Default is [""] *)->?naming_op:(comb->string->comb)(** Default is [Signal.(--)] *)->t->tendendmoduletypeEmpty=sigtype'at=NoneincludeSwithtype'at:='atend(** An enumerated type (generally a variant type with no arguments) which should derive
[compare, enumerate, sexp_of, variants]. *)moduletypeEnum=sigtypet[@@derivingcompare,enumerate,sexp_of]moduleVariants:sigvalto_rank:t->intendend(** Functions to project an [Enum] type into and out of hardcaml bit vectors representated
as an interface. *)moduletypeS_enum=sigmoduleEnum:EnumincludeSvalof_enum:(moduleComb.Swithtypet='a)->Enum.t->'atvalto_enum:Bits.tt->Enum.tvalmux:(moduleComb.Swithtypet='a)->default:'a->'at->(Enum.t*'a)list->'amoduleFor_testing:sigvalset:Bits.treft->Enum.t->unitvalget:Bits.treft->Enum.tendend(** Binary and onehot selectors for [Enums]. *)moduletypeS_enums=sigmoduleEnum:EnummoduleBinary:S_enumwithmoduleEnum:=EnummoduleOne_hot:S_enumwithmoduleEnum:=EnumendmoduletypeInterface=sigmoduletypePre_partial=Pre_partialmoduletypePre=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.tmoduletypeS_enum=S_enummoduletypeS_enums=S_enums(** Constructs a hardcaml interface which represents hardware for the given [Enum] as an
absstract [Interface]. *)moduleMake_enums(Enum:Enum):S_enumswithmoduleEnum:=Enumend