I'm trying to design an area-minimal circuit that computes the minimum of 8
values. This is the smallest I've come up with so far. Any suggestions on
making it smaller?
module min8(a, b, c, d, e, f, g, h, out);
parameter W = 12+3;
parameter OUT_W = 12;
input [W-1:0] a, b, c, d, e, f, g, h;
output [OUT_W-1:0] out;
integer i;
reg [0:7] sel, v, w;
always @(a, b, c, d, e, f, g, h) begin
v = {a[W-1], b[W-1], c[W-1], d[W-1], e[W-1], f[W-1], g[W-1],
h[W-1]};
sel = ~v;
for (i=W-2; i>=0; i=i-1) begin
v = {a[i], b[i], c[i], d[i], e[i], f[i], g[i], h[i]};
w = v & sel; // Subset of values still candidates
if (w != 0 && w != sel) begin
sel = sel & ~v; // If it has a 1, it's not min
end
end
end
wire [W-1:0] A, B, C, D, E, F, G, H;
assign A = a & {W{sel[0]}};
assign B = b & {W{sel[1]}};
assign C = c & {W{sel[2]}};
assign D = d & {W{sel[3]}};
assign E = e & {W{sel[4]}};
assign F = f & {W{sel[5]}};
assign G = g & {W{sel[6]}};
assign H = h & {W{sel[7]}};
assign out = A | B | C | D | E | F | G | H;
endmodule
--
Timothy Normand Miller, PhD
Assistant Professor of Computer Science, Binghamton University
http://www.cs.binghamton.edu/~millerti/
Open Graphics Project
_______________________________________________
Open-graphics mailing list
[email protected]
http://lists.duskglow.com/mailman/listinfo/open-graphics
List service provided by Duskglow Consulting, LLC (www.duskglow.com)