source: trunk/MultiChannelUSB/adc_fifo.v@ 92

Last change on this file since 92 was 90, checked in by demin, 15 years ago

full rewrite

File size: 1.3 KB
RevLine 
[27]1module adc_fifo
[86]2 #(
3 parameter W = 48 // fifo width
4 )
[27]5 (
6 input wire adc_clk,
[86]7 input wire [W-1:0] adc_data,
[27]8
[90]9 input wire sys_clk,
10 output wire sys_good,
11 output wire [W-1:0] sys_data
[27]12 );
13
[86]14 wire [W-1:0] int_q;
15 reg [W-1:0] int_data;
[44]16
[90]17 reg state, int_rdreq, int_good;
[72]18 wire int_wrfull, int_rdempty;
[27]19
[45]20 dcfifo #(
21 .intended_device_family("Cyclone III"),
22 .lpm_numwords(16),
23 .lpm_showahead("ON"),
24 .lpm_type("dcfifo"),
[86]25 .lpm_width(W),
[45]26 .lpm_widthu(4),
27 .rdsync_delaypipe(4),
28 .wrsync_delaypipe(4),
29 .overflow_checking("ON"),
30 .underflow_checking("ON"),
[84]31 .use_eab("ON"),
[72]32 .write_aclr_synch("OFF")) fifo_unit (
[58]33 .aclr(1'b0),
[72]34 .data(adc_data),
[90]35 .rdclk(sys_clk),
[49]36 .rdreq((~int_rdempty) & int_rdreq),
[27]37 .wrclk(adc_clk),
[72]38 .wrreq(~int_wrfull),
39 .q(int_q),
[44]40 .rdempty(int_rdempty),
[72]41 .wrfull(int_wrfull),
[45]42 .rdfull(),
43 .rdusedw(),
44 .wrempty(),
45 .wrusedw());
[27]46
[90]47 always @(posedge sys_clk)
[44]48 begin
49 case (state)
[86]50 1'b0:
[44]51 begin
[49]52 int_rdreq <= 1'b1;
[90]53 int_good <= 1'b0;
[86]54 state <= 1'b1;
[49]55 end
56
[86]57 1'b1:
[49]58 begin
[44]59 if (~int_rdempty)
60 begin
[72]61 int_data <= int_q;
[49]62 int_rdreq <= 1'b0;
[90]63 int_good <= 1'b1;
[86]64 state <= 1'b0;
[44]65 end
66 end
67 endcase
68 end
69
[90]70 assign sys_good = int_good;
71 assign sys_data = int_data;
[44]72
[27]73endmodule
Note: See TracBrowser for help on using the repository browser.