strgbaoffseti.v 11.8 KB

/**************************************************************************
 *                                                                        *
 *               Copyright (C) 1994, Silicon Graphics, Inc.               *
 *                                                                        *
 *  These coded instructions, statements, and computer programs  contain  *
 *  unpublished  proprietary  information of Silicon Graphics, Inc., and  *
 *  are protected by Federal copyright  law.  They  may not be disclosed  *
 *  to  third  parties  or copied or duplicated in any form, in whole or  *
 *  in part, without the prior written consent of Silicon Graphics, Inc.  *
 *                                                                        *
 *************************************************************************/
// $Id: strgbaoffseti.v,v 1.1 2002/03/28 00:26:13 berndt Exp $
/*      Project Reality
        MDP
        Created by Mike M. Cai  5/24/94
*/

module strgbaoffseti(  att_data_out,
                  att_data_in, dx, x_offset, 
                  dy, y_offset);
output [8:0]   att_data_out;  // 9 bits integer
input [10:0]   att_data_in;   //  10 bits integer, 2 bits fraction
input [12:0]   dx, dy;        // 10 bits integer,  bits fraction
input [1:0]     x_offset, y_offset;  // 2 bits of fractions

wire [12:0]    x_prod0, x_prod1, y_prod0, y_prod1;
wire [12:0]    add_prod1_s, add_prod1_co;
wire [12:0]    add_prod2_s, add_prod2_co;
wire [12:0]    add_prod3_s, add_prod3_co;
wire [12:0]    sum0, sum0_co, sum1, sum1_co;
wire [12:0]    sum;              // 10 bits integer, 4 bits fraction
wire [8:0]     att_data_out;


an02d1	 // dx partial product one
   x_prod0_0(.z(x_prod0[0]), .a1(dx[0]), .a2(x_offset[0])),
   x_prod0_1(.z(x_prod0[1]), .a1(dx[1]), .a2(x_offset[0])),
   x_prod0_2(.z(x_prod0[2]), .a1(dx[2]), .a2(x_offset[0])),
   x_prod0_3(.z(x_prod0[3]), .a1(dx[3]), .a2(x_offset[0])),
   x_prod0_4(.z(x_prod0[4]), .a1(dx[4]), .a2(x_offset[0])),
   x_prod0_5(.z(x_prod0[5]), .a1(dx[5]), .a2(x_offset[0])),
   x_prod0_6(.z(x_prod0[6]), .a1(dx[6]), .a2(x_offset[0])),
   x_prod0_7(.z(x_prod0[7]), .a1(dx[7]), .a2(x_offset[0])),
   x_prod0_8(.z(x_prod0[8]), .a1(dx[8]), .a2(x_offset[0])),
   x_prod0_9(.z(x_prod0[9]), .a1(dx[9]), .a2(x_offset[0])),
   x_prod0_10(.z(x_prod0[10]), .a1(dx[10]), .a2(x_offset[0])),
   x_prod0_11(.z(x_prod0[11]), .a1(dx[11]), .a2(x_offset[0])),
   x_prod0_12(.z(x_prod0[12]), .a1(dx[12]), .a2(x_offset[0])),
   // dx partial product two
   x_prod1_1(.z(x_prod1[1]), .a1(dx[0]), .a2(x_offset[1])),
   x_prod1_2(.z(x_prod1[2]), .a1(dx[1]), .a2(x_offset[1])),
   x_prod1_3(.z(x_prod1[3]), .a1(dx[2]), .a2(x_offset[1])),
   x_prod1_4(.z(x_prod1[4]), .a1(dx[3]), .a2(x_offset[1])),
   x_prod1_5(.z(x_prod1[5]), .a1(dx[4]), .a2(x_offset[1])),
   x_prod1_6(.z(x_prod1[6]), .a1(dx[5]), .a2(x_offset[1])),
   x_prod1_7(.z(x_prod1[7]), .a1(dx[6]), .a2(x_offset[1])),
   x_prod1_8(.z(x_prod1[8]), .a1(dx[7]), .a2(x_offset[1])),
   x_prod1_9(.z(x_prod1[9]), .a1(dx[8]), .a2(x_offset[1])),
   x_prod1_10(.z(x_prod1[10]), .a1(dx[9]), .a2(x_offset[1])),
   x_prod1_11(.z(x_prod1[11]), .a1(dx[10]), .a2(x_offset[1])),
   x_prod1_12(.z(x_prod1[12]), .a1(dx[11]), .a2(x_offset[1])),
   // dy partial product
   y_prod0_0(.z(y_prod0[0]), .a1(dy[0]), .a2(y_offset[0])),
   y_prod0_1(.z(y_prod0[1]), .a1(dy[1]), .a2(y_offset[0])),
   y_prod0_2(.z(y_prod0[2]), .a1(dy[2]), .a2(y_offset[0])),
   y_prod0_3(.z(y_prod0[3]), .a1(dy[3]), .a2(y_offset[0])),
   y_prod0_4(.z(y_prod0[4]), .a1(dy[4]), .a2(y_offset[0])),
   y_prod0_5(.z(y_prod0[5]), .a1(dy[5]), .a2(y_offset[0])),
   y_prod0_6(.z(y_prod0[6]), .a1(dy[6]), .a2(y_offset[0])),
   y_prod0_7(.z(y_prod0[7]), .a1(dy[7]), .a2(y_offset[0])),
   y_prod0_8(.z(y_prod0[8]), .a1(dy[8]), .a2(y_offset[0])),
   y_prod0_9(.z(y_prod0[9]), .a1(dy[9]), .a2(y_offset[0])),
   y_prod0_10(.z(y_prod0[10]), .a1(dy[10]), .a2(y_offset[0])),
   y_prod0_11(.z(y_prod0[11]), .a1(dy[11]), .a2(y_offset[0])),
   y_prod0_12(.z(y_prod0[12]), .a1(dy[12]), .a2(y_offset[0])),
   // dy partial product two
   y_prod1_1(.z(y_prod1[1]), .a1(dy[0]), .a2(y_offset[1])),
   y_prod1_2(.z(y_prod1[2]), .a1(dy[1]), .a2(y_offset[1])),
   y_prod1_3(.z(y_prod1[3]), .a1(dy[2]), .a2(y_offset[1])),
   y_prod1_4(.z(y_prod1[4]), .a1(dy[3]), .a2(y_offset[1])),
   y_prod1_5(.z(y_prod1[5]), .a1(dy[4]), .a2(y_offset[1])),
   y_prod1_6(.z(y_prod1[6]), .a1(dy[5]), .a2(y_offset[1])),
   y_prod1_7(.z(y_prod1[7]), .a1(dy[6]), .a2(y_offset[1])),
   y_prod1_8(.z(y_prod1[8]), .a1(dy[7]), .a2(y_offset[1])),
   y_prod1_9(.z(y_prod1[9]), .a1(dy[8]), .a2(y_offset[1])),
   y_prod1_10(.z(y_prod1[10]), .a1(dy[9]), .a2(y_offset[1])),
   y_prod1_11(.z(y_prod1[11]), .a1(dy[10]), .a2(y_offset[1])),
   y_prod1_12(.z(y_prod1[12]), .a1(dy[11]), .a2(y_offset[1]));


ad01d1
      // first stage adders
   add_prod1_0(.s(add_prod1_s[0]), .co(add_prod1_co[1]),
	.a(x_prod0[0]), .b(1'h0), .ci(y_prod0[0])),
   add_prod1_1(.s(add_prod1_s[1]), .co(add_prod1_co[2]),
	.a(x_prod0[1]), .b(x_prod1[1]), .ci(y_prod0[1])),
   add_prod1_2(.s(add_prod1_s[2]), .co(add_prod1_co[3]),
	.a(x_prod0[2]), .b(x_prod1[2]), .ci(y_prod0[2])),
   add_prod1_3(.s(add_prod1_s[3]), .co(add_prod1_co[4]),
	.a(x_prod0[3]), .b(x_prod1[3]), .ci(y_prod0[3])),
   add_prod1_4(.s(add_prod1_s[4]), .co(add_prod1_co[5]),
	.a(x_prod0[4]), .b(x_prod1[4]), .ci(y_prod0[4])),
   add_prod1_5(.s(add_prod1_s[5]), .co(add_prod1_co[6]),
	.a(x_prod0[5]), .b(x_prod1[5]), .ci(y_prod0[5])),
   add_prod1_6(.s(add_prod1_s[6]), .co(add_prod1_co[7]),
	.a(x_prod0[6]), .b(x_prod1[6]), .ci(y_prod0[6])),
   add_prod1_7(.s(add_prod1_s[7]), .co(add_prod1_co[8]),
	.a(x_prod0[7]), .b(x_prod1[7]), .ci(y_prod0[7])),
   add_prod1_8(.s(add_prod1_s[8]), .co(add_prod1_co[9]),
	.a(x_prod0[8]), .b(x_prod1[8]), .ci(y_prod0[8])),
   add_prod1_9(.s(add_prod1_s[9]), .co(add_prod1_co[10]),
	.a(x_prod0[9]), .b(x_prod1[9]), .ci(y_prod0[9])),
   add_prod1_10(.s(add_prod1_s[10]), .co(add_prod1_co[11]),
	.a(x_prod0[10]), .b(x_prod1[10]), .ci(y_prod0[10])),
   add_prod1_11(.s(add_prod1_s[11]), .co(add_prod1_co[12]),
	.a(x_prod0[11]), .b(x_prod1[11]), .ci(y_prod0[11])),
   add_prod1_12(.s(add_prod1_s[12]),/* .co(add_prod1_co[13]),*/
	.a(x_prod0[12]), .b(x_prod1[12]), .ci(y_prod0[12])),
   // second stage adder
//   add_prod2_0(.s(add_prod2_s[0]), .co(add_prod2_co[1]), 
//	.a(att_data_in[-2], .b(y_prod1[0]), .ci(add_prod1_co[0])),
   add_prod2_1(.s(add_prod2_s[1]), .co(add_prod2_co[2]), 
	.a(1'h0), .b(y_prod1[1]), .ci(add_prod1_co[1])),
   add_prod2_2(.s(add_prod2_s[2]), .co(add_prod2_co[3]), 
	.a(att_data_in[0]), .b(y_prod1[2]), .ci(add_prod1_co[2])),
   add_prod2_3(.s(add_prod2_s[3]), .co(add_prod2_co[4]), 
	.a(att_data_in[1]), .b(y_prod1[3]), .ci(add_prod1_co[3])),
   add_prod2_4(.s(add_prod2_s[4]), .co(add_prod2_co[5]), 
	.a(att_data_in[2]), .b(y_prod1[4]), .ci(add_prod1_co[4])),
   add_prod2_5(.s(add_prod2_s[5]), .co(add_prod2_co[6]), 
	.a(att_data_in[3]), .b(y_prod1[5]), .ci(add_prod1_co[5])),
   add_prod2_6(.s(add_prod2_s[6]), .co(add_prod2_co[7]), 
	.a(att_data_in[4]), .b(y_prod1[6]), .ci(add_prod1_co[6])),
   add_prod2_7(.s(add_prod2_s[7]), .co(add_prod2_co[8]), 
	.a(att_data_in[5]), .b(y_prod1[7]), .ci(add_prod1_co[7])),
   add_prod2_8(.s(add_prod2_s[8]), .co(add_prod2_co[9]), 
	.a(att_data_in[6]), .b(y_prod1[8]), .ci(add_prod1_co[8])),
   add_prod2_9(.s(add_prod2_s[9]), .co(add_prod2_co[10]), 
	.a(att_data_in[7]), .b(y_prod1[9]), .ci(add_prod1_co[9])),
   add_prod2_10(.s(add_prod2_s[10]), .co(add_prod2_co[11]), 
	.a(att_data_in[8]), .b(y_prod1[10]), .ci(add_prod1_co[10])),
   add_prod2_11(.s(add_prod2_s[11]), .co(add_prod2_co[12]), 
	.a(att_data_in[9]), .b(y_prod1[11]), .ci(add_prod1_co[11])),
   add_prod2_12(.s(add_prod2_s[12]), // .co(add_prod2_co[13]), 
	.a(att_data_in[10]), .b(y_prod1[12]), .ci(add_prod1_co[12]));
   // third stage adder
//   add_prod3_0(.s(add_prod3_s[0]), .co(add_prod3_co[1]), 
//	.a(add_prod2_co[0]), .b(add_prod1_s[0]), .ci(add_prod2_s[0])),
assign     add_prod3_s[0] = add_prod1_s[0];
assign     add_prod3_co[1] = 1'h0;
ad01d1
   add_prod3_1(.s(add_prod3_s[1]), .co(add_prod3_co[2]), 
	.a(1'h0), .b(add_prod1_s[1]), .ci(add_prod2_s[1])),
   add_prod3_2(.s(add_prod3_s[2]), .co(add_prod3_co[3]), 
	.a(add_prod2_co[2]), .b(add_prod1_s[2]), .ci(add_prod2_s[2])),
   add_prod3_3(.s(add_prod3_s[3]), .co(add_prod3_co[4]), 
	.a(add_prod2_co[3]), .b(add_prod1_s[3]), .ci(add_prod2_s[3])),
   add_prod3_4(.s(add_prod3_s[4]), .co(add_prod3_co[5]), 
	.a(add_prod2_co[4]), .b(add_prod1_s[4]), .ci(add_prod2_s[4])),
   add_prod3_5(.s(add_prod3_s[5]), .co(add_prod3_co[6]), 
	.a(add_prod2_co[5]), .b(add_prod1_s[5]), .ci(add_prod2_s[5])),
   add_prod3_6(.s(add_prod3_s[6]), .co(add_prod3_co[7]), 
	.a(add_prod2_co[6]), .b(add_prod1_s[6]), .ci(add_prod2_s[6])),
   add_prod3_7(.s(add_prod3_s[7]), .co(add_prod3_co[8]), 
	.a(add_prod2_co[7]), .b(add_prod1_s[7]), .ci(add_prod2_s[7])),
   add_prod3_8(.s(add_prod3_s[8]), .co(add_prod3_co[9]), 
	.a(add_prod2_co[8]), .b(add_prod1_s[8]), .ci(add_prod2_s[8])),
   add_prod3_9(.s(add_prod3_s[9]), .co(add_prod3_co[10]), 
	.a(add_prod2_co[9]), .b(add_prod1_s[9]), .ci(add_prod2_s[9])),
   add_prod3_10(.s(add_prod3_s[10]), .co(add_prod3_co[11]), 
	.a(add_prod2_co[10]), .b(add_prod1_s[10]), .ci(add_prod2_s[10])),
   add_prod3_11(.s(add_prod3_s[11]), .co(add_prod3_co[12]), 
	.a(add_prod2_co[11]), .b(add_prod1_s[11]), .ci(add_prod2_s[11])),
   add_prod3_12(.s(add_prod3_s[12]), //.co(add_prod3_co[13]), 
	.a(add_prod2_co[12]), .b(add_prod1_s[12]), .ci(add_prod2_s[12]));

// Carry select adder
assign  sum[0] = add_prod3_s[0];
assign  sum[1] = add_prod3_s[1];

ad01d1
   sum2(.s(sum[2]), .co(sum0_co[3]),
      	 .a(add_prod3_s[2]), .b(add_prod3_co[2]), .ci(1'h0)),
   sum3(.s(sum[3]), .co(sum0_co[4]),
      	 .a(add_prod3_s[3]), .b(add_prod3_co[3]), .ci(sum0_co[3])),
   sum4(.s(sum[4]), .co(sum0_co[5]),
      	 .a(add_prod3_s[4]), .b(add_prod3_co[4]), .ci(sum0_co[4])),
   sum5(.s(sum[5]), .co(sum0_co[6]),
      	 .a(add_prod3_s[5]), .b(add_prod3_co[5]), .ci(sum0_co[5])),
   sum6(.s(sum[6]), .co(sum0_co[7]),
      	 .a(add_prod3_s[6]), .b(add_prod3_co[6]), .ci(sum0_co[6]));

ni01d3
   carry_sel(.z(sel_carry), .i(sum0_co[7]));

ad01d1
   sum7_0(.s(sum0[7]), .co(sum0_co[8]),
      	    .a(add_prod3_s[7]), .b(add_prod3_co[7]), .ci(1'h0)),
   sum7_1(.s(sum1[7]), .co(sum1_co[8]),
      	    .a(add_prod3_s[7]), .b(add_prod3_co[7]), .ci(1'h1)),
   sum8_0(.s(sum0[8]), .co(sum0_co[9]),
      	    .a(add_prod3_s[8]), .b(add_prod3_co[8]), .ci(sum0_co[8])),
   sum8_1(.s(sum1[8]), .co(sum1_co[9]),
      	    .a(add_prod3_s[8]), .b(add_prod3_co[8]), .ci(sum1_co[8])),
   sum9_0(.s(sum0[9]), .co(sum0_co[10]),
      	    .a(add_prod3_s[9]), .b(add_prod3_co[9]), .ci(sum0_co[9])),
   sum9_1(.s(sum1[9]), .co(sum1_co[10]),
      	    .a(add_prod3_s[9]), .b(add_prod3_co[9]), .ci(sum1_co[9])),
   sum10_0(.s(sum0[10]), .co(sum0_co[11]),
      	    .a(add_prod3_s[10]), .b(add_prod3_co[10]), .ci(sum0_co[10])),
   sum10_1(.s(sum1[10]), .co(sum1_co[11]),
      	    .a(add_prod3_s[10]), .b(add_prod3_co[10]), .ci(sum1_co[10])),
   sum11_0(.s(sum0[11]), .co(sum0_co[12]),
      	    .a(add_prod3_s[11]), .b(add_prod3_co[11]), .ci(sum0_co[11])),
   sum11_1(.s(sum1[11]), .co(sum1_co[12]),
      	    .a(add_prod3_s[11]), .b(add_prod3_co[11]), .ci(sum1_co[11])),
   sum12_0(.s(sum0[12]), //.co(sum0_co[9]),
      	    .a(add_prod3_s[12]), .b(add_prod3_co[12]), .ci(sum0_co[12])),
   sum12_1(.s(sum1[12]), //.co(sum1_co[9]),
      	    .a(add_prod3_s[12]), .b(add_prod3_co[12]), .ci(sum1_co[12]));
 
mx21d1
   sum7(.z(sum[7]), .i0(sum0[7]), .i1(sum1[7]), .s(sel_carry)),
   sum8(.z(sum[8]), .i0(sum0[8]), .i1(sum1[8]), .s(sel_carry)),
   sum9(.z(sum[9]), .i0(sum0[9]), .i1(sum1[9]), .s(sel_carry)),
   sum10(.z(sum[10]), .i0(sum0[10]), .i1(sum1[10]), .s(sel_carry)),
   sum11(.z(sum[11]), .i0(sum0[11]), .i1(sum1[11]), .s(sel_carry)),
   sum12(.z(sum[12]), .i0(sum0[12]), .i1(sum1[12]), .s(sel_carry));

assign  att_data_out = sum[12:4];

endmodule  //  strgbaoffseti