if (a) b = c; d = b + e; if (q) d = 22;
b <= (a) ? c : b; d <= q ? 22 : ((a) ? c : b) + e;
v <= (a) ? 0: (v>>1)
v <= (a|a) ? 0: v; v <= (a|a) ? 0: v; v <= 0;
The following ML fragment will make a ripple carry adder from lsb-first lists of nets:
fun add c (nil, nil) = [c] | add c (a::at, b::bt) = let val s = gen_xor(a, b) val c1 = gen_and(a, b) val c2 = gen_and(s, c) in (gen_xor(s, c))::(add (gen_or(c2, c1)) (at, bt)) end
Can division be bit-blasted ? Yes, and for some constants it is quite simple.
For instance, division by a constant value of 8 needs no gates - you just need wiring!
For dynamic shifts make a barrel shifter using a succession of broadside multiplexors, each operated by a different bit of the shifting expression.
See link »Barrel Shifter, ML fragment.
To divide by a constant 10 you can use that 8/10 is 0.11001100 recurring, so if n and q are 32 bit unsigned registers, the following computes n/10:
q = (n >> 1) + (n >> 2); q += (q >> 4); q += (q >> 8); q += (q >> 16); return q>>3;
There are three ML fragments on the course web site that demonstrate each step of this recipe: ~ 1: »pure conversion~ 2: »bit-blasting~ 3: »gate building (The details of the algorithms and being able to reproduce them is not examinable but being able to draw the gate-level circuit for a few lines of RTL is examinable).
|20: (C) 2008-13, DJ Greaves, University of Cambridge, Computer Laboratory.||Flash Player Upgrade Needed READY|