basic_larger_than_zero (b2 -~ b1);;
+let basic_max : basic -> basic -> basic =
+ fun b1 ->
+ fun b2 ->
+ let compare = basic_larger_than_zero (b1 -~ b2) in
+ match compare with
+ | N i ->
+ if i = 1 then b1
+ else if i = 0 then b2
+ else raise (Basic_operation "compare result not bool.")
+ | Vec vec ->
+ let basics = Array.init vec#size vec#nth in
+ let sum = basic_to_int (Array.fold_left basic_add Zero basics) in
+ if sum = vec#size then b1
+ else if sum = 0 then b2
+ else Error
+ | Error -> Error
+ | _ -> raise (Basic_operation "compare result not bool.");;
+
+
+let basic_min : basic -> basic -> basic =
+ fun b1 ->
+ fun b2 ->
+ let compare = basic_larger_than_zero (b1 -~ b2) in
+ match compare with
+ | N i ->
+ if i = 1 then b2
+ else if i = 0 then b1
+ else raise (Basic_operation "compare result not bool.")
+ | Vec vec ->
+ let basics = Array.init vec#size vec#nth in
+ let sum = basic_to_int (Array.fold_left basic_add Zero basics) in
+ if sum = vec#size then b2
+ else if sum = 0 then b1
+ else Error
+ | Error -> Error
+ | _ -> raise (Basic_operation "compare result not bool.");;
| "serialize" { IDENT Serialize}
| ">" { IDENT Larger}
| "<" { IDENT Smaller}
+| "max" { IDENT Max}
+| "min" { IDENT Min}
| "prefix" { IDENT Prefix}
| "selecttwo" { IDENT Select2}
| "selectthree" { IDENT Select3}
((input#get.(0))#larger input#get.(1))
| Smaller -> self#beam_of_ident n
((input#get.(0))#smaller input#get.(1))
+ | Max -> self#beam_of_ident n
+ ((input#get.(0))#max input#get.(1))
+ | Min -> self#beam_of_ident n
+ ((input#get.(0))#min input#get.(1))
| Prefix -> self#beam_of_ident n
((input#get.(1))#prefix input#get.(0))
| Select2 -> self#beam_of_ident n
method _mod = self#prim2 (fun t -> (self#at t)#_mod)
method larger = self#prim2 (fun t -> (self#at t)#larger)
method smaller = self#prim2 (fun t -> (self#at t)#smaller)
+ method max = self#prim2 (fun t -> (self#at t)#max)
+ method min = self#prim2 (fun t -> (self#at t)#min)
method delay : signal_type -> signal_type =
fun (s : signal_type) ->
|Serialize -> (1, 1)
|Larger -> (2, 1)
|Smaller -> (2, 1)
+ |Max -> (2, 1)
+ |Min -> (2, 1)
|Prefix -> (2, 1)
|Select2 -> (3, 1)
|Select3 -> (4, 1);;
|Mod -> 0
|Larger -> 0
|Smaller -> 0
+ |Max -> 0
+ |Min -> 0
|Vectorize -> vectorize_memory_length
|Vconcat -> 0
|Vpick -> 0
|Mod -> "Mod"
|Larger -> "Larger"
|Smaller -> "Smaller"
+ |Max -> "Max"
+ |Min -> "Min"
|Vectorize -> "Vectorize"
|Vconcat -> "Vconcat"
|Vpick -> "Vpick"
method _mod : value_type -> value_type
method larger : value_type -> value_type
method smaller : value_type -> value_type
+ method max : value_type -> value_type
+ method min : value_type -> value_type
end;;
| Serialize
| Larger
| Smaller
+ | Max
+ | Min
| Prefix
| Select2
| Select3
method _mod : signal_type -> signal_type
method larger : signal_type -> signal_type
method smaller : signal_type -> signal_type
+ method max : signal_type -> signal_type
+ method min : signal_type -> signal_type
method rdtable : signal_type -> signal_type -> signal_type
method select2 : signal_type -> signal_type -> signal_type
method select3 : signal_type -> signal_type -> signal_type -> signal_type
method _mod = self#prim2 basic_mod
method larger = self#prim2 basic_larger
method smaller = self#prim2 basic_smaller
+ method max = self#prim2 basic_max
+ method min = self#prim2 basic_min
end;;