|
发表于 2012-4-16 22:48:35
|
显示全部楼层
回复 1# lyz5432
基于二分法的vongy的代码已经很接近了
- input [63:0] data_in;
- output [5:0] data_out;
- wire [31:0] Temp_32bits;
- wire [15:0] Temp_16bits;
- wire [7:0] Temp_8bits;
- wire [3:0] Temp_4bits;
- wire [1:0] Temp_2bits;
- wire W32_n, W16_n, W8_n, W4_n, W2_n, W1_n; // negtive of weigh bit of output
- wire RA_32, RA_16, RA_8, RA_4, RA_2, RA_1; // reduction and of down half bits of each bisection operation
- wire G32, G16, G8, G4, G2, G1; //
- wire AT_4, AT_3, AT_2, AT_1, AT_0; // And tree
- assign RA_32 = & data_in[31:0];
- assign RA_16 = & Temp_32bits[15:0];
- assign RA_8 = & Temp_16bits[7:0];
- assign RA_4 = & Temp_8bits[3:0];
- assign RA_2 = & Temp_4bits[1:0];
- assign RA_1 = Temp_2bits[0];
- assign W32_n = | data_in[63:32];
- assign W16_n = | Temp_32bits[31:16];
- assign W8_n = | Temp_16bits[15:8];
- assign W4_n = | Temp_8bits[7:4];
- assign W2_n = | Temp_4bits[3:2];
- assign W1_n = Temp_2bits[1];
- assign Temp_32bits = W32_n ? data_in[63:32] : data_in[31:0];
- assign G32 = W32_n ? RA_32 : 1'b1;
- assign Temp_16bits = W16_n ? Temp_32bits[31:16] : Temp_32bits[15:0];
- assign G16 = W16_n ? RA_16 : 1'b1;
- assign Temp_8bits = W8_n ? Temp_16bits[15:8] : Temp_16bits[7:0];
- assign G8 = W8_n ? RA_8 : 1'b1;
- assign Temp_4bits = W4_n ? Temp_8bits[7:4] : Temp_8bits[3:0];
- assign G4 = W4_n ? RA_4 : 1'b1;
- assign Temp_2bits = W2_n ? Temp_4bits[3:2] : Temp_4bits[1:0];
- assign G2 = W2_n ? RA_2 : 1'b1;
- assign G1 = RA_1;
- assign AT_4 = G32 & G16;
- assign AT_3 = AT_4 & G8;
- assign AT_2 = AT_3 & G4;
- assign AT_1 = AT_2 & G2;
- assign AT_0 = AT_1 & G1;
- assign data_out[5] = (~W32_n) & AT_0;
- assign data_out[4] = (~W16_n) & AT_0;
- assign data_out[3] = (~W8_n) & AT_0;
- assign data_out[2] = (~W4_n) & AT_0;
- assign data_out[1] = (~W2_n) & AT_0;
- assign data_out[0] = (~W1_n) & AT_0;
复制代码 |
|