OpenCores
URL https://opencores.org/ocsvn/alternascope/alternascope/trunk

Subversion Repositories alternascope

[/] [alternascope/] [branches/] [Alpha/] [AdcDriver/] [d_Driver_ADC.v] - Blame information for rev 30

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 smpickett
//==================================================================
2
// File:    d_Driver_ADC.v
3
// Version: 0.01
4
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
5
// Copyright Stephen Pickett
6
//   April 28, 2005
7
//------------------------------------------------------------------
8
// Revisions:
9
// Ver 0.01     Apr 28, 2005    Initial Release
10
//
11
//==================================================================
12
 
13
module Driver_ADC(
14
    CLK_64MHZ, MASTER_RST,
15 27 smpickett
    TIMESCALE,
16 21 smpickett
    CLK_ADC, ADC_DATA,
17 2 smpickett
    DATA_OUT
18
    );
19
 
20
//==================================================================//
21
// DEFINITIONS                                                      //
22
//==================================================================//
23 27 smpickett
parameter US1       = 4'd0;
24
parameter US2       = 4'd1;
25
parameter US4       = 4'd2;
26
parameter US8       = 4'd3;
27
parameter US16      = 4'd4;
28
parameter US32      = 4'd5;
29
parameter US64      = 4'd6;
30
parameter US128     = 4'd7;
31
parameter US512     = 4'd8;
32
parameter US1024    = 4'd9;
33
parameter US2048    = 4'd10;
34
parameter US4096    = 4'd11;
35
parameter US8192    = 4'd12;
36
parameter US16384   = 4'd13;
37
parameter US32768   = 4'd14;
38
parameter US65536   = 4'd15;
39
parameter US131072  = 4'd16;
40
parameter US262144  = 4'd17;
41
parameter US524288  = 4'd18;
42
parameter US1048576 = 4'd19;
43
parameter US2097152 = 4'd20;
44
parameter US4194304 = 4'd21;
45
parameter US8388608 = 4'd22;
46 2 smpickett
 
47
 
48
//==================================================================//
49
// VARIABLE DEFINITIONS                                             //
50
//==================================================================//
51
 
52
//----------------------//
53
// INPUTS / OUTPUTS     //
54
//----------------------//
55
input       CLK_64MHZ;          // Global System Clock
56
input       MASTER_RST;         // Global Asyncronous Reset
57 27 smpickett
input[3:0]  TIMESCALE;          // The selected V/Div
58 21 smpickett
input[8:0]  ADC_DATA;           // Data recieved from ADC
59
output      CLK_ADC;            // Clock out to the ADC
60
output[8:0] DATA_OUT;           // Data output (essentially buffered from ADC by one clk)
61 2 smpickett
 
62
//----------------------//
63
// WIRES / NODES        //
64
//----------------------//
65
wire CLK_64MHZ, MASTER_RST;
66 27 smpickett
wire[3:0] TIMESCALE;
67 21 smpickett
wire[8:0] ADC_DATA;
68 27 smpickett
reg  CLK_ADC;
69 21 smpickett
reg [8:0] DATA_OUT;
70 2 smpickett
 
71
//----------------------//
72
// VARIABLES            //
73
//----------------------//
74 21 smpickett
reg[15:0] Counter_CLK;
75
wire CLK_32MHZ, CLK_16MHZ, CLK_8MHZ, CLK_4MHZ, CLK_2MHZ, CLK_1MHZ, CLK_500KHZ, CLK_250KHZ, CLK_125KHZ,
76
     CLK_62KHZ, CLK_31KHZ, CLK_16KHZ, CLK_8KHZ, CLK_4KHZ, CLK_2KHZ, CLK_1KHZ;
77 2 smpickett
 
78
 
79
 
80
 
81
//==================================================================//
82
// FUNCTIONAL DEFINITIONS                                           //
83
//==================================================================//
84
 
85 21 smpickett
always @ (posedge CLK_ADC or posedge MASTER_RST) begin
86
    if(MASTER_RST)  DATA_OUT <= 9'b0;
87
    else            DATA_OUT <= ADC_DATA;
88
end
89 27 smpickett
/*
90 21 smpickett
assign CLK_ADC = CLK_62KHZ;
91 27 smpickett
*/
92 2 smpickett
 
93
//------------------------------------------------------------------//
94
// CLOCK GENERATION AND SELECTION                                   //
95
//------------------------------------------------------------------//
96
 
97
always @ (posedge CLK_64MHZ or posedge MASTER_RST) begin
98
    if(MASTER_RST == 1'b1) begin
99
        Counter_CLK <= 16'b0;
100
    end else begin
101
        Counter_CLK <= Counter_CLK + 1;
102
    end
103
end
104
 
105 21 smpickett
 
106 2 smpickett
assign CLK_32MHZ    = Counter_CLK[0];
107
assign CLK_16MHZ    = Counter_CLK[1];
108
assign CLK_8MHZ     = Counter_CLK[2];
109
assign CLK_4MHZ     = Counter_CLK[3];
110
assign CLK_2MHZ     = Counter_CLK[4];
111
assign CLK_1MHZ     = Counter_CLK[5];
112
assign CLK_500KHZ   = Counter_CLK[6];
113
assign CLK_250KHZ   = Counter_CLK[7];
114
assign CLK_125KHZ   = Counter_CLK[8];
115
assign CLK_62KHZ    = Counter_CLK[9];
116
assign CLK_31KHZ    = Counter_CLK[10];
117
assign CLK_16KHZ    = Counter_CLK[11];
118
assign CLK_8KHZ     = Counter_CLK[12];
119
assign CLK_4KHZ     = Counter_CLK[13];
120
assign CLK_2KHZ     = Counter_CLK[14];
121
assign CLK_1KHZ     = Counter_CLK[15];
122
//assign CLK_500HZ    = Counter_CLK[16];
123
 
124 27 smpickett
always @ (TIMESCALE or MASTER_RST or CLK_64MHZ or CLK_32MHZ or CLK_16MHZ or
125 2 smpickett
            CLK_8MHZ or CLK_4MHZ or CLK_2MHZ or CLK_1MHZ or CLK_500KHZ or CLK_250KHZ or
126
            CLK_125KHZ or CLK_62KHZ or CLK_31KHZ or CLK_16KHZ or CLK_8KHZ or CLK_4KHZ or
127
            CLK_2KHZ or CLK_1KHZ) begin
128
    if(MASTER_RST == 1'b1) begin
129 21 smpickett
        CLK_ADC = 1'b0;
130 27 smpickett
    end else if(TIMESCALE == 4'd0) begin    // 1us/Div, 1samp/pxl
131 21 smpickett
        CLK_ADC = CLK_64MHZ;
132 27 smpickett
    end else if(TIMESCALE == 4'd1) begin    // 2us/Div, 2samp/pxl
133 21 smpickett
        CLK_ADC = CLK_64MHZ;
134 27 smpickett
    end else if(TIMESCALE == 4'd2) begin    // 4us/Div, 2samp/pxl
135 21 smpickett
        CLK_ADC = CLK_32MHZ;
136 27 smpickett
    end else if(TIMESCALE == 4'd3) begin    // 8us/Div, 2samp/pxl
137 21 smpickett
        CLK_ADC = CLK_16MHZ;
138 27 smpickett
    end else if(TIMESCALE == 4'd4) begin    // 16us/Div, 2samp/pxl
139 21 smpickett
        CLK_ADC = CLK_8MHZ;
140 27 smpickett
    end else if(TIMESCALE == 4'd5) begin    // 32us/Div, 2samp/pxl
141 21 smpickett
        CLK_ADC = CLK_4MHZ;
142 27 smpickett
    end else if(TIMESCALE == 4'd6) begin    // 64us/Div, 2samp/pxl
143 21 smpickett
        CLK_ADC = CLK_2MHZ;
144 27 smpickett
    end else if(TIMESCALE == 4'd7) begin    // 128us/Div, 2samp/pxl
145 21 smpickett
        CLK_ADC = CLK_1MHZ;
146 27 smpickett
    end else if(TIMESCALE == 4'd8) begin    // 256us/Div, 2samp/pxl
147 21 smpickett
        CLK_ADC = CLK_500KHZ;
148 27 smpickett
    end else if(TIMESCALE == 4'd9) begin    // 512us/Div, 2samp/pxl
149 21 smpickett
        CLK_ADC = CLK_250KHZ;
150 27 smpickett
    end else if(TIMESCALE == 4'd10) begin   //      ...
151 21 smpickett
        CLK_ADC = CLK_125KHZ;
152 27 smpickett
    end else if(TIMESCALE == 4'd11) begin
153 21 smpickett
        CLK_ADC = CLK_62KHZ;
154 27 smpickett
    end else if(TIMESCALE == 4'd12) begin
155 21 smpickett
        CLK_ADC = CLK_31KHZ;
156 27 smpickett
    end else if(TIMESCALE == 4'd13) begin
157 21 smpickett
        CLK_ADC = CLK_16KHZ;
158 27 smpickett
    end else if(TIMESCALE == 4'd14) begin
159 21 smpickett
        CLK_ADC = CLK_8KHZ;
160 27 smpickett
    end else if(TIMESCALE == 4'd15) begin
161 21 smpickett
        CLK_ADC = CLK_4KHZ;
162 27 smpickett
/*
163
    end else if(TIMESCALE == 4'd16) begin
164 21 smpickett
        CLK_ADC = CLK_2KHZ;
165 27 smpickett
    end else if(TIMESCALE == 4'd17) begin
166 21 smpickett
        CLK_ADC = CLK_1KHZ;
167 27 smpickett
//    end else if(TIMESCALE == 4'd18) begin
168 21 smpickett
//        CLK_ADC = CLK_500HZ;
169 27 smpickett
    end else if(TIMESCALE == 4'd19) begin
170 21 smpickett
        CLK_ADC = CLK_US524288;
171 27 smpickett
    end else if(TIMESCALE == 4'd20) begin
172 21 smpickett
        CLK_ADC = CLK_US1048576;
173 27 smpickett
    end else if(TIMESCALE == 4'd21) begin
174 21 smpickett
        CLK_ADC = CLK_US2097152;
175 27 smpickett
    end else if(TIMESCALE == 4'd22) begin
176 21 smpickett
        CLK_ADC = CLK_US4194304;
177 27 smpickett
    end else if(TIMESCALE == 4'd23) begin
178 21 smpickett
        CLK_ADC = CLK_US8388608;
179 27 smpickett
*/
180 2 smpickett
    end else begin
181 21 smpickett
        CLK_ADC = 1'b0;
182 2 smpickett
    end
183
end
184 27 smpickett
  /*
185 2 smpickett
//------------------------------------------------------------------//
186
// ADC DATA READING                                                 //
187
//------------------------------------------------------------------//
188 21 smpickett
always @ (negedge CLK_ADC or posedge MASTER_RST) begin
189 2 smpickett
    if(MASTER_RST == 1'b1) begin
190
        DATA_OUT <= 8'b0;
191
    end else begin
192
        DATA_OUT <= ADC_DATA;
193
    end
194
end
195
 
196 17 smpickett
//assign DATA_OUT = ADC_DATA;
197 21 smpickett
*/
198 2 smpickett
endmodule
199
 
200
 
201
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.