Module Hardcaml.Fifo

Synchronous FIFO implementions with optional showahead functionality and pipelining stages.

include Hardcaml__.Fifo_intf.S
include module type of Hardcaml__.Fifo_intf.T with type 'a T.t = 'a Hardcaml__.Fifo_intf.T.t
type 'a t = 'a Hardcaml__.Fifo_intf.T.t = {
q : 'a;
full : 'a;
empty : 'a;
nearly_full : 'a;
nearly_empty : 'a;
used : 'a;
}
val sexp_of_t : ('a -> Ppx_sexp_conv_lib.Sexp.t) -> 'a t -> Ppx_sexp_conv_lib.Sexp.t
val iter : 'a t -> f:('a -> Hardcaml__.Import.unit) -> Hardcaml__.Import.unit
val iter2 : 'a t -> 'b t -> f:('a -> 'b -> Hardcaml__.Import.unit) -> Hardcaml__.Import.unit
val map : 'a t -> f:('a -> 'b) -> 'b t
val map2 : 'a t -> 'b t -> f:('a -> 'b -> 'c) -> 'c t
val to_list : 'a t -> 'a Hardcaml__.Import.list
val t : (Hardcaml__.Import.string * Hardcaml__.Import.int) t
val equal : 'a Hardcaml__.Import.Equal.equal -> 'a t Hardcaml__.Import.Equal.equal
val port_names : Hardcaml__.Import.string t
val port_widths : Hardcaml__.Import.int t
val to_alist : 'a t -> (Hardcaml__.Import.string * 'a) Hardcaml__.Import.list
val of_alist : (Hardcaml__.Import.string * 'a) Hardcaml__.Import.list -> 'a t
val zip : 'a t -> 'b t -> ('a * 'b) t
val zip3 : 'a t -> 'b t -> 'c t -> ('a * 'b * 'c) t
val zip4 : 'a t -> 'b t -> 'c t -> 'd t -> ('a * 'b * 'c * 'd) t
val zip5 : 'a t -> 'b t -> 'c t -> 'd t -> 'e t -> ('a * 'b * 'c * 'd * 'e) t
val map3 : 'a t -> 'b t -> 'c t -> f:('a -> 'b -> 'c -> 'd) -> 'd t
val map4 : 'a t -> 'b t -> 'c t -> 'd t -> f:('a -> 'b -> 'c -> 'd -> 'e) -> 'e t
val map5 : 'a t -> 'b t -> 'c t -> 'd t -> 'e t -> f:('a -> 'b -> 'c -> 'd -> 'e -> 'f) -> 'f t
val iter3 : 'a t -> 'b t -> 'c t -> f:('a -> 'b -> 'c -> Hardcaml__.Import.unit) -> Hardcaml__.Import.unit
val iter4 : 'a t -> 'b t -> 'c t -> 'd t -> f:('a -> 'b -> 'c -> 'd -> Hardcaml__.Import.unit) -> Hardcaml__.Import.unit
val iter5 : 'a t -> 'b t -> 'c t -> 'd t -> 'e t -> f:('a -> 'b -> 'c -> 'd -> 'e -> Hardcaml__.Import.unit) -> Hardcaml__.Import.unit
val fold : 'a t -> init:'acc -> f:('acc -> 'a -> 'acc) -> 'acc
val fold2 : 'a t -> 'b t -> init:'acc -> f:('acc -> 'a -> 'b -> 'acc) -> 'acc
val scan : 'a t -> init:'acc -> f:('acc -> 'a -> 'acc * 'b) -> 'b t
val scan2 : 'a t -> 'b t -> init:'acc -> f:('acc -> 'a -> 'b -> 'acc * 'c) -> 'c t
val offsets : ?⁠rev:Hardcaml__.Import.bool -> Hardcaml__.Import.unit -> Hardcaml__.Import.int t
val of_interface_list : 'a t Hardcaml__.Import.list -> 'a Hardcaml__.Import.list t
val to_interface_list : 'a Hardcaml__.Import.list t -> 'a t Hardcaml__.Import.list
module type Comb = sig ... end
module Make_comb : functor (Comb : Comb.S) -> sig ... end
module Of_bits : sig ... end
module Of_signal : sig ... end
type 'a create_params = ?⁠nearly_empty:Hardcaml__.Import.int -> ?⁠nearly_full:Hardcaml__.Import.int -> ?⁠overflow_check:Hardcaml__.Import.bool -> ?⁠reset:Signal.t -> ?⁠underflow_check:Hardcaml__.Import.bool -> ?⁠ram_attributes:Rtl_attribute.t Hardcaml__.Import.list -> ?⁠scope:Scope.t -> 'a
type create_fifo = (Hardcaml__.Import.unit -> capacity:Hardcaml__.Import.int -> clock:Signal.t -> clear:Signal.t -> wr:Signal.t -> d:Signal.t -> rd:Signal.t -> Signal.t t) create_params
Base RTL FIFO
val create : ?⁠showahead:Hardcaml__.Import.bool -> Hardcaml__.Fifo_intf.T.create_fifo

create ~clock ~clear ~wr ~d ~rd capacity builds a FIFO with capacity elements which is written with d when wr is high and read when rd is high.

The default reset configuration is to use a synchronous clr signal. An asynchronous rst may be optionally provided. One of clr or rst must be non-empty.

Optional overflow and underflow checking may be used. Data will not be written(/read) when the fifo is full(/empty) regardles or the wr/(rd) signals.

nearly_emtpy and nearly_full may be programmed to go high when the fifo is nearing an underflow or overflow state.

The showahead mode changes the read behaviour of the FIFO. When showahead is false read data is available 1 cycle after rd is high. With showahead true the data is available on the same cycle as rd is high. To support showahead behaviour the timing of the full/empty flag also changes (although they still correctly indicate when it is safe to read or write to the FIFO). showahead mode has some extra cost in terms of extra logic. The implementation ensures the output is registered and timing performance is good - nearly as fast as the underlying RAM allows..

Note; showahead is sometimes referred to as "first word fall through". It uses the write-before-read ram mode which is problematic in synthesis so we include special logic that performs collision detection.

The used output indicates the number of elements currently in the FIFO.

Functions to derive fifo architectures from other architecetures.

val showahead_fifo_of_classic_fifo : Kinded_fifo.create_classic -> Kinded_fifo.create_showahead Hardcaml__.Import.Staged.t

Derived FIFO architectures.

val create_classic_with_extra_reg : Hardcaml__.Fifo_intf.T.create_fifo

Adds an extra output register to the non-showahead fifo. This delays the output, but ensures there is no logic data on the fifo output. Adds an extra cycle of latency (2 cycles from write to empty low).

val create_showahead_from_classic : create_fifo

Constructs a showahead fifo from a non-showahead fifo. Only modifies the control flags. Has 2 cycles of latency.

val create_showahead_with_extra_reg : create_fifo

Constructs a fifo similarly to create_showahead_from_classic and ensures the output data is registered. Has 3 cycles of latency, but is slightly faster than create ~showahead:true - it seems to only be limited by the underlying RAM frequency.

module With_interface : functor (Config : Config) -> sig ... end

Create FIFO using interfaces.