module adc_fifo
	(
		input	wire			adc_dr,
		input	wire			adc_or,
		input	wire	[11:0]	adc_data,

		input	wire			aclr,
		input	wire			rdclk,
		input	wire			rdreq,
		output	wire			rdempty,
		output	wire	[11:0]	raw_data,
		output	wire	[13:0]	uwt_data
	);

	wire 	[31:0]	uwt_d1, uwt_a1, uwt_peak1;
	wire 	[31:0]	uwt_d2, uwt_a2, uwt_peak2;
	wire 	[31:0]	uwt_d3, uwt_a3, uwt_peak3;
	wire 	[1:0]	uwt_flag1, uwt_flag2, uwt_flag3;

	wire	[1:0]	wrfull;

	uwt_bior31 #(.L(1)) uwt_1_unit (
		.clk(adc_dr),
		.x(adc_data),
		.d(uwt_d1),
		.a(uwt_a1),
		.peak(uwt_peak1),
		.flag(uwt_flag1));

	uwt_bior31 #(.L(2)) uwt_2_unit (
		.clk(adc_dr),
		.x(uwt_a1),
		.d(uwt_d2),
		.a(uwt_a2),
		.peak(uwt_peak2),
		.flag(uwt_flag2));

	uwt_bior31 #(.L(3)) uwt_3_unit (
		.clk(adc_dr),
		.x(uwt_a2),
		.d(uwt_d3),
		.a(uwt_a3),
		.peak(uwt_peak3),
		.flag(uwt_flag3));


	fifo32x12 fifo0 (
		.aclr(aclr),
		.data(adc_data),
		.rdclk(rdclk),
		.rdreq(rdreq),
		.wrclk(adc_dr),
		.wrreq(~wrfull[0]),
		.q(raw_data),
		.rdempty(rdempty),
		.wrfull(wrfull[0]));

	fifo32x14 fifo1 (
		.aclr(aclr),
		.data({uwt_flag3, uwt_peak3[11:0]}),
		.rdclk(rdclk),
		.rdreq(rdreq),
		.wrclk(adc_dr),
		.wrreq(~wrfull[1]),
		.q(uwt_data),
		.rdempty(),
		.wrfull(wrfull[1]));

endmodule
