Make_comb.Combval sexp_of_t : t -> Ppx_sexp_conv_lib.Sexp.tinclude Base.Equal.S with type t := tval equal : t Base.Equal.equalval empty : tthe empty signal
val is_empty : t -> Base.Bool.tval (--) : t -> Base.String.t -> tnames a signal
let a = a -- "a" in ...
signals may have multiple names.
val width : t -> Base.Int.treturns the width (number of bits) of a signal.
let w = width s in ...
val address_bits_for : Base.Int.t -> Base.Int.taddess_bits_for num_elements returns the address width required to index num_elements.
It is the same as Int.ceil_log2, except it wll return a minimum value of 1 (since you cannot have 0 width vectors). Raises if num_elements is < 0.
val num_bits_to_represent : Base.Int.t -> Base.Int.tnum_bits_to_represent x returns the number of bits required to represent the number x, which should be >= 0.
val of_constant : Constant.t -> tval to_constant : t -> Constant.tval constb : Base.String.t -> tconvert binary string to constant
val of_bit_string : Base.String.t -> tval of_int : width:Base.Int.t -> Base.Int.t -> tconvert integer to constant
val of_int32 : width:Base.Int.t -> Base.Int32.t -> tval of_int64 : width:Base.Int.t -> Base.Int64.t -> tval of_hex :
?signedness:Constant.Signedness.t ->
width:Base.Int.t ->
Base.String.t ->
tconvert hex string to a constant. If the target width is greater than the hex length and signedness is Signed then the result is sign extended. Otherwise the result is zero padded.
val of_string : Base.String.t -> tconvert verilog style or binary string to constant
val of_bit_list : Base.Int.t Base.List.t -> tconvert IntbitsList to constant
val of_decimal_string : width:Base.Int.t -> Base.String.t -> tval of_char : Base.Char.t -> tconvert a char to an 8 bit constant
val constv : Base.String.t -> tval consti : width:Base.Int.t -> Base.Int.t -> tval consti32 : width:Base.Int.t -> Base.Int32.t -> tval consti64 : width:Base.Int.t -> Base.Int64.t -> tval constibl : Base.Int.t Base.List.t -> tval consthu : width:Base.Int.t -> Base.String.t -> tval consths : width:Base.Int.t -> Base.String.t -> tval const : Base.String.t -> tval constd : width:Base.Int.t -> Base.String.t -> tval concat_msb : t Base.List.t -> tconcat ts concatenates a list of signals - the msb of the head of the list will become the msb of the result.
let c = concat [ a; b; c ] in ...
concat raises if ts is empty or if any t in ts is empty.
val concat_lsb : t Base.List.t -> tSimilar to concat_msb except the lsb of the head of the list will become the lsb of the result.
val concat_msb_e : t Base.List.t -> tsame as concat_msb except empty signals are first filtered out
val concat_lsb_e : t Base.List.t -> tsame as concat_lsb except empty signals are first filtered out
val vdd : tlogic 1
val is_vdd : t -> Base.Bool.tval gnd : tlogic 0
val is_gnd : t -> Base.Bool.tval zero : Base.Int.t -> tzero w makes a the zero valued constant of width w
val ones : Base.Int.t -> tones w makes a constant of all ones of width w
val one : Base.Int.t -> tone w makes a one valued constant of width w
val select : t -> Base.Int.t -> Base.Int.t -> tselect t hi lo selects from t bits in the range hi...lo, inclusive. select raises unless hi and lo fall within 0 .. width t - 1 and hi >= lo.
val select_e : t -> Base.Int.t -> Base.Int.t -> tsame as select except invalid indices return empty
val bit : t -> Base.Int.t -> tselect a single bit
val drop_bottom : t -> Base.Int.t -> tdrop_bottom s n drop bottom n bits of s
val drop_top : t -> Base.Int.t -> tdrop_top s n drop top n bits of s
val sel_bottom : t -> Base.Int.t -> tsel_bottom s n select bottom n bits of s
val sel_top : t -> Base.Int.t -> tsel_top s n select top n bits of s
val (.:[]) : t -> (Base.Int.t * Base.Int.t) -> tx.:[hi, lo] == select x hi lo
val (.:+[]) : t -> (Base.Int.t * Base.Int.t Base.Option.t) -> tx.:+[lo, width] == select x (lo + width - 1) lo. If width is None it selects all remaining msbs of the vector ie x.:+[lo,None] == drop_bottom x lo
val (.:-[]) : t -> (Base.Int.t Base.Option.t * Base.Int.t) -> tx.:-[hi, width] == select x hi (hi - width + 1). If hi is None it defaults to the msb of the vector ie x.:-[None, width] == sel_top x width
val (.:()) : t -> Base.Int.t -> tx.(i) == bit x i
val insert : into:t -> t -> at_offset:Base.Int.t -> tinsert ~into:t x ~at_offset insert x into t at given offet
val mux : t -> t Base.List.t -> tmultiplexer.
let m = mux sel inputs in ...
Given l = List.length inputs and w = width sel the following conditions must hold.
l <= 2**w, l >= 2
If l < 2**w, the last input is repeated.
All inputs provided must have the same width, which will in turn be equal to the width of m.
mux2 c t f 2 input multiplexer. Selects t if c is high otherwise f.
t and f must have same width and c must be 1 bit.
Equivalent to mux c [f; t]
val mux_init : t -> Base.Int.t -> f:(Base.Int.t -> t) -> tval (&:.) : t -> Base.Int.t -> tval (|:.) : t -> Base.Int.t -> tval (^:.) : t -> Base.Int.t -> tval (+:.) : t -> Base.Int.t -> tval (-:.) : t -> Base.Int.t -> tval (==:.) : t -> Base.Int.t -> tval (<>:.) : t -> Base.Int.t -> tval (<:.) : t -> Base.Int.t -> tval (>:.) : t -> Base.Int.t -> tval (<=:.) : t -> Base.Int.t -> tval (>=:.) : t -> Base.Int.t -> tval (<+.) : t -> Base.Int.t -> tval (>+.) : t -> Base.Int.t -> tval (<=+.) : t -> Base.Int.t -> tval (>=+.) : t -> Base.Int.t -> tval to_string : t -> Base.String.tcreate string from signal
val to_int : t -> Base.Int.tto_int t treats t as unsigned and resizes it to fit exactly within an OCaml Int.t.
width t > Int.num_bits then the upper bits are truncated.width t >= Int.num_bits and bit t (Int.num_bits-1) = vdd (i.e. the msb of the resulting Int.t is set), then the result is negative.t is Signal.t and not a constant value, an exception is raised.val to_sint : t -> Base.Int.tto_sint t treats t as signed and resizes it to fit exactly within an OCaml Int.t.
width t > Int.num_bits then the upper bits are truncated.t is Signal.t and not a constant value, an exception is raised.val to_int32 : t -> Base.Int32.tval to_sint32 : t -> Base.Int32.tval to_int64 : t -> Base.Int64.tval to_sint64 : t -> Base.Int64.tval to_char : t -> Base.Char.tConvert signal to a char. The signal must be 8 bits wide.
val to_bstr : t -> Base.String.tcreate binary string from signal
val bits_msb : t -> t Base.List.tconvert signal to a list of bits with msb at head of list
val bits_lsb : t -> t Base.List.tconvert signal to a list of bits with lsb at head of list
val to_array : t -> t Base.Array.tto_array s convert signal s to array of bits with lsb at index 0
val of_array : t Base.Array.t -> tof_array a convert array a of bits to signal with lsb at index 0
val repeat : t -> Base.Int.t -> trepeat signal n times
split signal in half. The most significant bits will be in the left half of the returned tuple.
val split_lsb :
?exact:Base.Bool.t ->
part_width:Base.Int.t ->
t ->
t Base.List.tSplit signal into a list of signals with width equal to part_width. The least significant bits are at the head of the returned list. If exact is true the input signal width must be exactly divisable by part_width. When exact is false and the input signal width is not exactly divisible by part_width, the last element will contains residual bits.
eg:
split_lsb ~part_width:4 16b0001_0010_0011_0100 =
[ 4b0100; 4b0011; 4b0010; 4b0001 ]
split_lsb ~exact:false ~part_width:4 17b11_0001_0010_0011_0100 =
[ 4b0100; 4b0011; 4b0010; 4b0001; 2b11 ]val split_msb :
?exact:Base.Bool.t ->
part_width:Base.Int.t ->
t ->
t Base.List.tLike split_lsb except the most significant bits are at the head of the returned list. Residual bits when exact is false goes to the last element of the list, so in the general case split_lsb is not necessarily equivalent to split_msb |> List.rev.
val sll : t -> Base.Int.t -> tshift left logical
val srl : t -> Base.Int.t -> tshift right logical
val sra : t -> Base.Int.t -> tshift right arithmetic
val rotl : t -> Base.Int.t -> trotate left
val rotr : t -> Base.Int.t -> trotate right
val uresize : t -> Base.Int.t -> turesize t w returns the unsigned resize of t to width w. If w = width t, this is a no-op. If w < width t, this selects the w low bits of t. If w > width t, this extends t with zero (width t - w).
val sresize : t -> Base.Int.t -> tsresize t w returns the signed resize of t to width w. If w = width t, this is a no-op. If w < width t, this selects the w low bits of t. If w > width t, this extends t with width t - w copies of msb t.
val resize_list :
resize:(t -> Base.Int.t -> t) ->
t Base.List.t ->
t Base.List.tresize_list ?resize l finds the maximum width in l and applies resize el max to each element.
resize_op2 ~resize f a b applies resize x w to a and b where w is the maximum of their widths. It then returns f a b
val reduce : f:('a -> 'a -> 'a) -> 'a Base.List.t -> 'afold 'op' though list
val mod_counter : max:Base.Int.t -> t -> tmod_counter max t is if t = max then 0 else (t + 1), and can be used to count from 0 to (max-1) then from zero again. If max == 1<<n, then a comparator is not generated and overflow arithmetic used instead. If
val tree : arity:Base.Int.t -> f:('a Base.List.t -> 'a) -> 'a Base.List.t -> 'atree ~arity ~f input creates a tree of operations. The arity of the operator is configurable. tree raises if input = [].
val priority_select :
?branching_factor:Base.Int.t ->
t With_valid.t Base.List.t ->
t With_valid.tpriority_select cases returns the value associated with the first case whose valid signal is high. valid will be set low in the returned With_valid.t if no case is selected.
val priority_select_with_default :
?branching_factor:Base.Int.t ->
t With_valid.t Base.List.t ->
default:t ->
tSame as priority_select except returns default if no case matches.
val onehot_select :
?branching_factor:Base.Int.t ->
t With_valid.t Base.List.t ->
tSelect a case where one and only one valid signal is enabled. If more than one case is valid then the return value is undefined. If no cases are valid, 0 is returned by the current implementation, though this should not be relied upon.
val popcount : ?branching_factor:Base.Int.t -> t -> tpopcount t returns the number of bits set in t.
val is_pow2 : ?branching_factor:Base.Int.t -> t -> tis_pow2 t returns a bit to indicate if t is a power of 2.
val leading_ones : ?branching_factor:Base.Int.t -> t -> tleading_ones t returns the number of consecutive 1s from the most significant bit of t down.
val trailing_ones : ?branching_factor:Base.Int.t -> t -> ttrailing_ones t returns the number of consecutive 1s from the least significant bit of t up.
val leading_zeros : ?branching_factor:Base.Int.t -> t -> tleading_zeros t returns the number of consecutive 0s from the most significant bit of t down.
val trailing_zeros : ?branching_factor:Base.Int.t -> t -> ttrailing_zeros t returns the number of consecutive 0s from the least significant bit of t up.
val floor_log2 : ?branching_factor:Base.Int.t -> t -> t With_valid.tfloor_log2 x returns the floor of log-base-2 of x. x is treated as unsigned and an error is indicated by valid = gnd in the return value if x = 0.
val ceil_log2 : ?branching_factor:Base.Int.t -> t -> t With_valid.tceil_log2 x returns the ceiling of log-base-2 of x. x is treated as unsigned and an error is indicated by valid = gnd in the return value if x = 0.
val random : width:Base.Int.t -> tcreate random constant vector of given width
module type TypedMath = sig ... end