Four bit adder: Difference between revisions

(Improved D code)
Line 1,603:
let n = Array.length v in
let w = Array.make (n*nbits) false in
Array.iteri (fun i x ->
for i=0 to n-1 do
Array.blit (bits_of_int nbits v.(i)x) 0 w (i*nbits) nbits
done) v;
w;;
Line 1,612:
let r = nv mod nbits and n = nv/nbits in
if r <> 0 then failwith "bad output size" else
let w = Array.makeinit n 0L(fun i in->
w.(i) <- int_of_bits nbits (Array.sub v (i*nbits) nbits)
for i=0 to n-1 do
w);;
w.(i) <- int_of_bits nbits (Array.sub v (i*nbits) nbits)
done;
w;;
 
(* We have a type for blocks, so we need operations on blocks.
Line 1,656 ⟶ 1,654:
map: map n input lines on length(v) output lines, using the links out(k)=v(in(k))
pass: n wires not connected (out(k) = in(k))
fork: a wire is developpeddeveloped into n wires having the same value
perm: permutation of wires
forget: n wires going nowhere
Anonymous user