Index: sandbox/MultiChannelUSB/deconv.v
===================================================================
--- sandbox/MultiChannelUSB/deconv.v	(revision 120)
+++ sandbox/MultiChannelUSB/deconv.v	(revision 123)
@@ -2,5 +2,7 @@
 	#(
 		parameter	size	=	1, // number of channels
-		parameter	width	=	24 // bit width of the input data
+		parameter	shift	=	24, // right shift of the result
+		parameter	width	=	27, // bit width of the input data
+		parameter	widthr	=	13 // bit width of the output data
 	)
 	(
@@ -9,5 +11,4 @@
 		input	wire	[3*size*8-1:0]		amp_data,
 		input	wire	[3*size*16-1:0]		tau_data,
-		input	wire	[3*size*6-1:0]		cls_data,
 		input	wire	[3*size*width-1:0]	inp_data,
 		output	wire	[3*size*widthr-1:0]	out_data
@@ -16,5 +17,5 @@
 	localparam	width1	=	width + 1;
 	localparam	width2	=	width + 6 + 1;
-	localparam	widthr	=	width + 16 + 3;
+	localparam	width3	=	width + 16 + 3;
 
 	reg							int_wren_reg, int_wren_next;
@@ -30,7 +31,7 @@
 	wire	[size*widthr-1:0]	out_data_wire;
 
-	wire	[size*widthr-1:0]	add_data_wire;
-
-	wire	[size*widthr-1:0]	mul_data_wire [1:0];
+	wire	[size*width3-1:0]	add_data_wire;
+
+	wire	[size*width3-1:0]	mul_data_wire [1:0];
 
 	reg		[size*width2-1:0]	acc_data_reg [3:0], acc_data_next [3:0];
@@ -47,7 +48,4 @@
 	reg		[size*16-1:0]		tau_data_reg, tau_data_next;
 	wire	[size*16-1:0]		tau_data_wire [2:0];
-
-	reg		[size*6-1:0]		cls_data_reg, cls_data_next;
-	wire	[size*6-1:0]		cls_data_wire [2:0];
 
 	integer i;
@@ -66,7 +64,4 @@
 			assign tau_data_wire[1][j*16+16-1:j*16] = tau_data[(3*j+1)*16+16-1:(3*j+1)*16];
 			assign tau_data_wire[2][j*16+16-1:j*16] = tau_data[(3*j+2)*16+16-1:(3*j+2)*16];
-			assign cls_data_wire[0][j*6+6-1:j*6] = cls_data[(3*j+0)*6+6-1:(3*j+0)*6];
-			assign cls_data_wire[1][j*6+6-1:j*6] = cls_data[(3*j+1)*6+6-1:(3*j+1)*6];
-			assign cls_data_wire[2][j*6+6-1:j*6] = cls_data[(3*j+2)*6+6-1:(3*j+2)*6];
                                                                                          
 			lpm_mux #(
@@ -119,10 +114,10 @@
 				.lpm_widtha(width1),
 				.lpm_widthb(17),
-				.lpm_widthp(widthr)) mult_unit_1 (
+				.lpm_widthp(width3)) mult_unit_1 (
 				.clock(clock),
 				.clken(int_wren_reg),
 				.dataa(sub_data_wire[j*width1+width1-1:j*width1]),
 				.datab({1'b0, tau_data_reg[j*16+16-1:j*16]}),
-				.result(mul_data_wire[0][j*widthr+widthr-1:j*widthr]));
+				.result(mul_data_wire[0][j*width3+width3-1:j*width3]));
 
 			lpm_mult #(
@@ -133,10 +128,10 @@
 				.lpm_widtha(width2),
 				.lpm_widthb(8),
-				.lpm_widthp(widthr)) mult_unit_2 (
+				.lpm_widthp(width3)) mult_unit_2 (
 				.clock(clock),
 				.clken(int_wren_reg),
 				.dataa(acc_data_reg[0][j*width2+width2-1:j*width2]),
 				.datab(amp_data_reg[j*8+8-1:j*8]),
-				.result(mul_data_wire[1][j*widthr+widthr-1:j*widthr]));
+				.result(mul_data_wire[1][j*width3+width3-1:j*width3]));
 
 			lpm_add_sub	#(
@@ -145,18 +140,18 @@
 				.lpm_representation("SIGNED"),
 				.lpm_type("LPM_ADD_SUB"),
-				.lpm_width(widthr)) add_unit_2 (
-				.dataa(mul_data_wire[0][j*widthr+widthr-1:j*widthr]),
-				.datab(mul_data_wire[1][j*widthr+widthr-1:j*widthr]),
-				.result(add_data_wire[j*widthr+widthr-1:j*widthr]));
-
-
-			lpm_clshift	#(
-				.lpm_shifttype("LOGICAL"),
-				.lpm_type("LPM_CLSHIFT"),
-				.lpm_width(widthr),
-				.lpm_widthdist(6)) shift_unit_1 (
-				.distance(cls_data_reg[j*6+6-1:j*6]),
-				.direction(1'b1),
-				.data(add_data_wire[j*widthr+widthr-1:j*widthr]),
+				.lpm_width(width3)) add_unit_2 (
+				.dataa(mul_data_wire[0][j*width3+width3-1:j*width3]),
+				.datab(mul_data_wire[1][j*width3+width3-1:j*width3]),
+				.result(add_data_wire[j*width3+width3-1:j*width3]));
+
+
+			lpm_add_sub	#(
+				.lpm_direction("ADD"),
+				.lpm_hint("ONE_INPUT_IS_CONSTANT=NO,CIN_USED=NO"),
+				.lpm_representation("UNSIGNED"),
+				.lpm_type("LPM_ADD_SUB"),
+				.lpm_width(widthr)) add_unit_3 (
+				.dataa(add_data_wire[j*width3+shift+widthr-1:j*width3+shift]),
+				.datab({{(widthr-1){1'b0}}, add_data_wire[j*width3+shift-1]}),
 				.result(out_data_wire[j*widthr+widthr-1:j*widthr]));
 
@@ -220,5 +215,4 @@
 			amp_data_reg <= 8'd0;
 			tau_data_reg <= 16'd0;
-			cls_data_reg <= 6'd0;
 			for(i = 0; i <= 2; i = i + 1)
 			begin
@@ -240,5 +234,4 @@
 			amp_data_reg <= amp_data_next;
 			tau_data_reg <= tau_data_next;
-			cls_data_reg <= cls_data_next;
 			for(i = 0; i <= 2; i = i + 1)
 			begin
@@ -262,5 +255,4 @@
 		amp_data_next = amp_data_reg;
 		tau_data_next = tau_data_reg;
-		cls_data_next = cls_data_reg;
 		for(i = 0; i <= 2; i = i + 1)
 		begin
@@ -282,5 +274,4 @@
 				amp_data_next = 8'd0;
 				tau_data_next = 16'd0;
-				cls_data_next = 6'd0;
 				for(i = 0; i <= 2; i = i + 1)
 				begin
@@ -327,5 +318,4 @@
 					tau_data_next = tau_data_wire[0];
 					amp_data_next = amp_data_wire[0];
-					cls_data_next = cls_data_wire[0];
 					
 					int_case_next = 3'd3;
@@ -346,5 +336,4 @@
 				tau_data_next = tau_data_wire[1];
 				amp_data_next = amp_data_wire[1];
-				cls_data_next = cls_data_wire[1];
 
 				// register 1st sum
@@ -364,5 +353,4 @@
 				tau_data_next = tau_data_wire[2];
 				amp_data_next = amp_data_wire[2];
-				cls_data_next = cls_data_wire[2];
 				
 				// register 2nd sum
