source: trunk/MultiChannelUSB/adc_fifo.v@ 69

Last change on this file since 69 was 64, checked in by demin, 15 years ago

switch eab on

File size: 2.9 KB
RevLine 
[27]1module adc_fifo
2 (
3 input wire adc_clk,
4 input wire [11:0] adc_data,
[62]5 input wire polarity,
[27]6
[58]7 input wire clk,
[44]8
9 output wire ready,
[27]10 output wire [11:0] raw_data,
11 output wire [13:0] uwt_data
12 );
13
14 wire [31:0] uwt_d1, uwt_a1, uwt_peak1;
15 wire [31:0] uwt_d2, uwt_a2, uwt_peak2;
16 wire [31:0] uwt_d3, uwt_a3, uwt_peak3;
17 wire [1:0] uwt_flag1, uwt_flag2, uwt_flag3;
18
[49]19 wire [11:0] int_raw_q;
20 wire [13:0] int_uwt_q;
21
22 reg [11:0] int_raw_data;
23 reg [13:0] int_uwt_data;
24
[27]25 wire [1:0] wrfull;
[44]26
27 reg state;
28 reg int_rdreq, int_ready;
29 wire int_rdempty;
[27]30
[53]31 wire [11:0] int_adc_data;
[62]32 assign int_adc_data = (polarity) ? (12'hfff - adc_data) : (adc_data);
[53]33
[27]34 uwt_bior31 #(.L(1)) uwt_1_unit (
35 .clk(adc_clk),
[53]36 .x({20'h00000, int_adc_data}),
[27]37 .d(uwt_d1),
38 .a(uwt_a1),
39 .peak(uwt_peak1),
40 .flag(uwt_flag1));
41
42 uwt_bior31 #(.L(2)) uwt_2_unit (
43 .clk(adc_clk),
44 .x(uwt_a1),
45 .d(uwt_d2),
46 .a(uwt_a2),
47 .peak(uwt_peak2),
48 .flag(uwt_flag2));
49
50 uwt_bior31 #(.L(3)) uwt_3_unit (
51 .clk(adc_clk),
52 .x(uwt_a2),
53 .d(uwt_d3),
54 .a(uwt_a3),
55 .peak(uwt_peak3),
56 .flag(uwt_flag3));
57
[45]58 dcfifo #(
59 .intended_device_family("Cyclone III"),
60 .lpm_numwords(16),
61 .lpm_showahead("ON"),
62 .lpm_type("dcfifo"),
63 .lpm_width(12),
64 .lpm_widthu(4),
65 .rdsync_delaypipe(4),
66 .wrsync_delaypipe(4),
67 .overflow_checking("ON"),
68 .underflow_checking("ON"),
[64]69 .use_eab("ON"),
[45]70 .write_aclr_synch("OFF")) fifo_raw (
[58]71 .aclr(1'b0),
[53]72 .data(int_adc_data),
[58]73 .rdclk(clk),
[49]74 .rdreq((~int_rdempty) & int_rdreq),
[27]75 .wrclk(adc_clk),
76 .wrreq(~wrfull[0]),
[49]77 .q(int_raw_q),
[44]78 .rdempty(int_rdempty),
[45]79 .wrfull(wrfull[0]),
80 .rdfull(),
81 .rdusedw(),
82 .wrempty(),
83 .wrusedw());
[27]84
[45]85 dcfifo #(
86 .intended_device_family("Cyclone III"),
87 .lpm_numwords(16),
88 .lpm_showahead("ON"),
89 .lpm_type("dcfifo"),
90 .lpm_width(14),
91 .lpm_widthu(4),
92 .rdsync_delaypipe(4),
93 .wrsync_delaypipe(4),
94 .overflow_checking("ON"),
95 .underflow_checking("ON"),
[64]96 .use_eab("ON"),
[45]97 .write_aclr_synch("OFF")) fifo_uwt (
[58]98 .aclr(1'b0),
[27]99 .data({uwt_flag3, uwt_peak3[11:0]}),
[58]100 .rdclk(clk),
[49]101 .rdreq((~int_rdempty) & int_rdreq),
[27]102 .wrclk(adc_clk),
103 .wrreq(~wrfull[1]),
[49]104 .q(int_uwt_q),
[27]105 .rdempty(),
[45]106 .wrfull(wrfull[1]),
107 .rdfull(),
108 .rdusedw(),
109 .wrempty(),
110 .wrusedw());
[27]111
[58]112 always @(posedge clk)
[44]113 begin
114 case (state)
115 1'b0:
116 begin
[49]117 int_rdreq <= 1'b1;
118 int_ready <= 1'b0;
119 state <= 1'b1;
120 end
121
122 1'b1:
123 begin
[44]124 if (~int_rdempty)
125 begin
[49]126 int_raw_data <= int_raw_q;
127 int_uwt_data <= int_uwt_q;
128 int_rdreq <= 1'b0;
[44]129 int_ready <= 1'b1;
[49]130 state <= 1'b0;
[44]131 end
132 end
133
134 default:
135 begin
[49]136 int_rdreq <= 1'b1;
[44]137 int_ready <= 1'b0;
[49]138 state <= 1'b1;
[44]139 end
140 endcase
141 end
142
143 assign ready = int_ready;
[49]144 assign raw_data = int_raw_data;
145 assign uwt_data = int_uwt_data;
[44]146
[27]147endmodule
Note: See TracBrowser for help on using the repository browser.