bl_zcomp.v 6.75 KB
////////////////////////////////////////////////////////////////////////
//
// Project Reality
//
// module:	bl_zcomp
// description:	Z compares for blend unit. Note that old, new and delta
//		are all positive only, and the sum of old or new and
//		delta cannot overflow, so magnitude compares are OK.
//
// designer:	Phil Gossett
// date:	8/28/94
//
////////////////////////////////////////////////////////////////////////

module bl_zcomp (old, new, delta, farther, nearer, infront);

input [17:0] old;	// 0,15.3
input [17:0] new;	// 0,15.3
input [15:0] delta;	// 16.0 (power of 2)

output farther;		// (new + delta) >= old
output nearer;		// (old + delta) >= new
output infront;		//  old          >  new

wire [17:0] old_l;
wire [17:0] new_l;
wire [17:0] far_sum;
wire [17:0] far_cry;
wire [17:0] near_sum;
wire [17:0] near_cry;
wire p_farther;
wire p_nearer;

in01d4  ino0 (	.i(old[ 0]), .zn(old_l[ 0]));
in01d4  ino1 (	.i(old[ 1]), .zn(old_l[ 1]));
in01d4  ino2 (	.i(old[ 2]), .zn(old_l[ 2]));
in01d4  ino3 (	.i(old[ 3]), .zn(old_l[ 3]));
in01d4  ino4 (	.i(old[ 4]), .zn(old_l[ 4]));
in01d4  ino5 (	.i(old[ 5]), .zn(old_l[ 5]));
in01d4  ino6 (	.i(old[ 6]), .zn(old_l[ 6]));
in01d4  ino7 (	.i(old[ 7]), .zn(old_l[ 7]));
in01d4  ino8 (	.i(old[ 8]), .zn(old_l[ 8]));
in01d4  ino9 (	.i(old[ 9]), .zn(old_l[ 9]));
in01d4  inoa (	.i(old[10]), .zn(old_l[10]));
in01d4  inob (	.i(old[11]), .zn(old_l[11]));
in01d4  inoc (	.i(old[12]), .zn(old_l[12]));
in01d4  inod (	.i(old[13]), .zn(old_l[13]));
in01d4  inoe (	.i(old[14]), .zn(old_l[14]));
in01d4  inof (	.i(old[15]), .zn(old_l[15]));
in01d4  inog (	.i(old[16]), .zn(old_l[16]));
in01d4  inoh (	.i(old[17]), .zn(old_l[17]));

in01d4  inn0 (	.i(new[ 0]), .zn(new_l[ 0]));
in01d4  inn1 (	.i(new[ 1]), .zn(new_l[ 1]));
in01d4  inn2 (	.i(new[ 2]), .zn(new_l[ 2]));
in01d4  inn3 (	.i(new[ 3]), .zn(new_l[ 3]));
in01d4  inn4 (	.i(new[ 4]), .zn(new_l[ 4]));
in01d4  inn5 (	.i(new[ 5]), .zn(new_l[ 5]));
in01d4  inn6 (	.i(new[ 6]), .zn(new_l[ 6]));
in01d4  inn7 (	.i(new[ 7]), .zn(new_l[ 7]));
in01d4  inn8 (	.i(new[ 8]), .zn(new_l[ 8]));
in01d4  inn9 (	.i(new[ 9]), .zn(new_l[ 9]));
in01d4  inna (	.i(new[10]), .zn(new_l[10]));
in01d4  innb (	.i(new[11]), .zn(new_l[11]));
in01d4  innc (	.i(new[12]), .zn(new_l[12]));
in01d4  innd (	.i(new[13]), .zn(new_l[13]));
in01d4  inne (	.i(new[14]), .zn(new_l[14]));
in01d4  innf (	.i(new[15]), .zn(new_l[15]));
in01d4  inng (	.i(new[16]), .zn(new_l[16]));
in01d4  innh (	.i(new[17]), .zn(new_l[17]));

or02d2  afc0 (	.a1(   new[ 0]), .a2(  old_l[ 0]),
				  .z(far_cry[ 0]));
xo02d1h afs1 (	.a1(   new[ 1]), .a2(  old_l[ 1]),
		.z(far_sum[ 0]));
an02d1h afc1 (	.a1(   new[ 1]), .a2(  old_l[ 1]),
				  .z(far_cry[ 1]));
xo02d1h afs2 (	.a1(   new[ 2]), .a2(  old_l[ 2]),
		.z(far_sum[ 1]));
an02d1h afc2 (	.a1(   new[ 2]), .a2(  old_l[ 2]),
				  .z(far_cry[ 2]));
ad01d1h afs3 (	.a(    new[ 3]), .b(   old_l[ 3]), .ci(delta[ 0]),
		.s(far_sum[ 2]), .co(far_cry[ 3]));
ad01d1h afs4 (	.a(    new[ 4]), .b(   old_l[ 4]), .ci(delta[ 1]),
		.s(far_sum[ 3]), .co(far_cry[ 4]));
ad01d1h afs5 (	.a(    new[ 5]), .b(   old_l[ 5]), .ci(delta[ 2]),
		.s(far_sum[ 4]), .co(far_cry[ 5]));
ad01d1h afs6 (	.a(    new[ 6]), .b(   old_l[ 6]), .ci(delta[ 3]),
		.s(far_sum[ 5]), .co(far_cry[ 6]));
ad01d1h afs7 (	.a(    new[ 7]), .b(   old_l[ 7]), .ci(delta[ 4]),
		.s(far_sum[ 6]), .co(far_cry[ 7]));
ad01d1h afs8 (	.a(    new[ 8]), .b(   old_l[ 8]), .ci(delta[ 5]),
		.s(far_sum[ 7]), .co(far_cry[ 8]));
ad01d1h afs9 (	.a(    new[ 9]), .b(   old_l[ 9]), .ci(delta[ 6]),
		.s(far_sum[ 8]), .co(far_cry[ 9]));
ad01d1h afsa (	.a(    new[10]), .b(   old_l[10]), .ci(delta[ 7]),
		.s(far_sum[ 9]), .co(far_cry[10]));
ad01d1h afsb (	.a(    new[11]), .b(   old_l[11]), .ci(delta[ 8]),
		.s(far_sum[10]), .co(far_cry[11]));
ad01d1h afsc (	.a(    new[12]), .b(   old_l[12]), .ci(delta[ 9]),
		.s(far_sum[11]), .co(far_cry[12]));
ad01d1h afsd (	.a(    new[13]), .b(   old_l[13]), .ci(delta[10]),
		.s(far_sum[12]), .co(far_cry[13]));
ad01d1h afse (	.a(    new[14]), .b(   old_l[14]), .ci(delta[11]),
		.s(far_sum[13]), .co(far_cry[14]));
ad01d1h afsf (	.a(    new[15]), .b(   old_l[15]), .ci(delta[12]),
		.s(far_sum[14]), .co(far_cry[15]));
ad01d1h afsg (	.a(    new[16]), .b(   old_l[16]), .ci(delta[13]),
		.s(far_sum[15]), .co(far_cry[16]));
ad01d1h afsh (	.a(    new[17]), .b(   old_l[17]), .ci(delta[14]),
		.s(far_sum[16]), .co(far_cry[17]));
in01d4  afsi (					    .i(delta[15]),
	       .zn(far_sum[17]));

or02d2  anc0 (	.a1(    old[ 0]), .a2(   new_l[ 0]),
				   .z(near_cry[ 0]));
xo02d1h ans1 (	.a1(    old[ 1]), .a2(   new_l[ 1]),
		.z(near_sum[ 0]));
an02d1h anc1 (	.a1(    old[ 1]), .a2(   new_l[ 1]),
				  .z( near_cry[ 1]));
xo02d1h ans2 (	.a1(    old[ 2]), .a2(   new_l[ 2]),
		.z(near_sum[ 1]));
an02d1h anc2 (	.a1(    old[ 2]), .a2(   new_l[ 2]),
				  .z(near_cry[ 2]));
ad01d1h ans3 (	.a(     old[ 3]), .b(    new_l[ 3]), .ci(delta[ 0]),
		.s(near_sum[ 2]), .co(near_cry[ 3]));
ad01d1h ans4 (	.a(     old[ 4]), .b(    new_l[ 4]), .ci(delta[ 1]),
		.s(near_sum[ 3]), .co(near_cry[ 4]));
ad01d1h ans5 (	.a(     old[ 5]), .b(    new_l[ 5]), .ci(delta[ 2]),
		.s(near_sum[ 4]), .co(near_cry[ 5]));
ad01d1h ans6 (	.a(     old[ 6]), .b(    new_l[ 6]), .ci(delta[ 3]),
		.s(near_sum[ 5]), .co(near_cry[ 6]));
ad01d1h ans7 (	.a(     old[ 7]), .b(    new_l[ 7]), .ci(delta[ 4]),
		.s(near_sum[ 6]), .co(near_cry[ 7]));
ad01d1h ans8 (	.a(     old[ 8]), .b(    new_l[ 8]), .ci(delta[ 5]),
		.s(near_sum[ 7]), .co(near_cry[ 8]));
ad01d1h ans9 (	.a(     old[ 9]), .b(    new_l[ 9]), .ci(delta[ 6]),
		.s(near_sum[ 8]), .co(near_cry[ 9]));
ad01d1h ansa (	.a(     old[10]), .b(    new_l[10]), .ci(delta[ 7]),
		.s(near_sum[ 9]), .co(near_cry[10]));
ad01d1h ansb (	.a(     old[11]), .b(    new_l[11]), .ci(delta[ 8]),
		.s(near_sum[10]), .co(near_cry[11]));
ad01d1h ansc (	.a(     old[12]), .b(    new_l[12]), .ci(delta[ 9]),
		.s(near_sum[11]), .co(near_cry[12]));
ad01d1h ansd (	.a(     old[13]), .b(    new_l[13]), .ci(delta[10]),
		.s(near_sum[12]), .co(near_cry[13]));
ad01d1h anse (	.a(     old[14]), .b(    new_l[14]), .ci(delta[11]),
		.s(near_sum[13]), .co(near_cry[14]));
ad01d1h ansf (	.a(     old[15]), .b(    new_l[15]), .ci(delta[12]),
		.s(near_sum[14]), .co(near_cry[15]));
ad01d1h ansg (	.a(     old[16]), .b(    new_l[16]), .ci(delta[13]),
		.s(near_sum[15]), .co(near_cry[16]));
ad01d1h ansh (	.a(     old[17]), .b(    new_l[17]), .ci(delta[14]),
		.s(near_sum[16]), .co(near_cry[17]));
in01d4  ansi (					      .i(delta[15]),
	       .zn(near_sum[17]));

bl_zcomp_gt fzgt (.a( far_sum), .b( far_cry), .z(p_farther));
xo02d1h     fzxo (.a1(delta[15]),            .a2(p_farther), .z(farther));

bl_zcomp_gt nzgt (.a(near_sum), .b(near_cry), .z(p_nearer));
xo02d1h     nzxo (.a1(delta[15]),            .a2(p_nearer),  .z(nearer));

bl_zcomp_gt izgt (.a( old),     .b( new_l),                  .z(infront));

endmodule // bl_zcomp