123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960(** A simple vector structure with insert and delete operations at arbitrary positions. *)openBaseopenHardcamlmoduletypeArg=sig(** Interface representing the data held in the vec. *)moduleInterface:Interface.S(** Construct a register spec for each field in the interface based on index. *)valspec:index:int->Reg_spec.t->Reg_spec.tInterface.tendmoduletypeS=sigtypettypedata(** Operation performed on the [vec] circuit. *)typeop={slot:Signal.t(** Slot to perform operation at *);op:Signal.t(** Operation type (insert, remove or nothing) *);insert_data:data(** Data to insert into the vec *);delete_data:data(** Data written to the emptied slot in the vec *)}(** Create the vec with the given size.
[next] defines a function which can set the register when not performing an insert
or delete operation. *)valcreate:Reg_spec.t->vec_size:int->next:(index:int->data->data)->op->t(** Get the value at the given index. *)valget:t->index:int->data(** Create a read multiplexer *)valread_mux:t->index:Signal.t->data(** Size of vec *)valvec_size:t->intendmoduletypeVec=sigmoduletypeArg=ArgmoduletypeS=S(** {2 operations} *)(** no op *)valnoop:(moduleComb.Swithtypet='a)->'a(** insert at index *)valinsert:(moduleComb.Swithtypet='a)->'a(** remove at index *)valremove:(moduleComb.Swithtypet='a)->'a(** {2 Construction of vec circuits with given size} *)moduleMake(Arg:Arg):Swithtypedata:=Signal.tArg.Interface.tend