Statistics
| Branch: | Tag: | Revision:

root / usrp2 / top / u2_rev3 / u2_rev3.v @ 9fa6105a

History | View | Annotate | Download (12.4 kB)

1
`timescale 1ns / 1ps
2
//////////////////////////////////////////////////////////////////////////////////
3

    
4
module u2_rev3
5
  (
6
   // Misc, debug
7
   output [5:0] leds,
8
   output [31:0] debug,
9
   output [1:0] debug_clk,
10
   output uart_tx_o,
11
   input uart_rx_i,
12
   
13
   // Expansion
14
   input exp_pps_in_p, // Diff
15
   input exp_pps_in_n, // Diff
16
   output exp_pps_out_p, // Diff 
17
   output exp_pps_out_n, // Diff 
18
   
19
   // GMII
20
   //   GMII-CTRL
21
   input GMII_COL,
22
   input GMII_CRS,
23

    
24
   //   GMII-TX
25
   output reg [7:0] GMII_TXD,
26
   output reg GMII_TX_EN,
27
   output reg GMII_TX_ER,
28
   output GMII_GTX_CLK,
29
   input GMII_TX_CLK,  // 100mbps clk
30

    
31
   //   GMII-RX
32
   input [7:0] GMII_RXD,
33
   input GMII_RX_CLK,
34
   input GMII_RX_DV,
35
   input GMII_RX_ER,
36

    
37
   //   GMII-Management
38
   inout MDIO,
39
   output MDC,
40
   input PHY_INTn,   // open drain
41
   output PHY_RESETn,
42
   input PHY_CLK,   // possibly use on-board osc
43

    
44
   // RAM
45
   inout [17:0] RAM_D,
46
   output [18:0] RAM_A,
47
   output RAM_CE1n,
48
   output RAM_CENn,
49
   output RAM_CLK,
50
   output RAM_WEn,
51
   output RAM_OEn,
52
   output RAM_LDn,
53
   
54
   // SERDES
55
   output ser_enable,
56
   output ser_prbsen,
57
   output ser_loopen,
58
   output ser_rx_en,
59
   
60
   output ser_tx_clk,
61
   output reg [15:0] ser_t,
62
   output reg ser_tklsb,
63
   output reg ser_tkmsb,
64

    
65
   input ser_rx_clk,
66
   input [15:0] ser_r,
67
   input ser_rklsb,
68
   input ser_rkmsb,
69
   
70
   // CPLD interface
71
   output cpld_start,  // AA9
72
   output cpld_mode,   // U12
73
   output cpld_done,   // V12
74
   input cpld_din,     // AA14 Now shared with CFG_Din
75
   input cpld_clk,     // AB14 serial clock
76
   input cpld_detached,// V11 unused
77
   output cpld_init_b,  // W12 unused dual purpose
78
   output cpld_misc,  // Y12 
79

    
80
   // Watchdog interface
81
   input POR,
82
   output WDI,
83
   
84
   // ADC
85
   input [13:0] adc_a,
86
   input adc_ovf_a,
87
   output adc_oen_a,
88
   output adc_pdn_a,
89
   
90
   input [13:0] adc_b,
91
   input adc_ovf_b,
92
   output adc_oen_b,
93
   output adc_pdn_b,
94
   
95
   // DAC
96
   output reg [15:0] dac_a,
97
   output reg [15:0] dac_b,
98
   input dac_lock,     // unused for now
99
   
100
   // I2C
101
   inout SCL,
102
   inout SDA,
103

    
104
   // Clock Gen Control
105
   output [1:0] clk_en,
106
   output [1:0] clk_sel,
107
   input clk_func,        // FIXME is an input to control the 9510
108
   input clk_status,
109

    
110
   // Clocks
111
   input clk_fpga_p,  // Diff
112
   input clk_fpga_n,  // Diff
113
   input clk_to_mac,
114
   input pps_in,
115
   
116
   // Generic SPI
117
   output sclk,
118
   output sen_clk,
119
   output sen_dac,
120
   output sdi,
121
   input sdo,
122
   
123
   // TX DBoard
124
   output sen_tx_db,
125
   output sclk_tx_db,
126
   input sdo_tx_db,
127
   output sdi_tx_db,
128

    
129
   output sen_tx_adc,
130
   output sclk_tx_adc,
131
   input sdo_tx_adc,
132
   output sdi_tx_adc,
133

    
134
   output sen_tx_dac,
135
   output sclk_tx_dac,
136
   output sdi_tx_dac,
137

    
138
   inout [15:0] io_tx,
139

    
140
   // RX DBoard
141
   output sen_rx_db,
142
   output sclk_rx_db,
143
   input sdo_rx_db,
144
   output sdi_rx_db,
145

    
146
   output sen_rx_adc,
147
   output sclk_rx_adc,
148
   input sdo_rx_adc,
149
   output sdi_rx_adc,
150

    
151
   output sen_rx_dac,
152
   output sclk_rx_dac,
153
   output sdi_rx_dac,
154
   
155
   inout [15:0] io_rx   
156
   );
157

    
158
   assign 	cpld_init_b = 0;
159
   // FPGA-specific pins connections
160
   wire 	clk_fpga, dsp_clk, clk_div, dcm_out, wb_clk, clock_ready;
161
   wire 	clk90, clk180, clk270;
162

    
163
   // reset the watchdog continuously
164
   reg [15:0] 	wd;
165
   wire 	config_success;
166
   
167
   always @(posedge wb_clk)
168
     if(~config_success)
169
       wd <= 0;
170
     else
171
       wd <= wd + 1;
172
   assign 	WDI = wd[15];
173
   
174
   wire 	clk_fpga_unbuf;
175

    
176
   IBUFGDS clk_fpga_pin (.O(clk_fpga_unbuf),.I(clk_fpga_p),.IB(clk_fpga_n));
177
   BUFG clk_fpga_BUF (.O(clk_fpga),.I(clk_fpga_unbuf));
178

    
179
   defparam 	clk_fpga_pin.IOSTANDARD = "LVPECL_25";
180

    
181
   wire 	cpld_clock_buf;
182
   BUFG cpld_clock_BUF (.O(cpld_clock_buf),.I(cpld_clock));
183
   
184
   wire 	exp_pps_in;
185
   IBUFDS exp_pps_in_pin (.O(exp_pps_in),.I(exp_pps_in_p),.IB(exp_pps_in_n));
186
   defparam 	exp_pps_in_pin.IOSTANDARD = "LVDS_25";
187
   
188
   wire 	exp_pps_out;
189
   OBUFDS exp_pps_out_pin (.O(exp_pps_out_p),.OB(exp_pps_out_n),.I(exp_pps_out));
190
   defparam 	exp_pps_out_pin.IOSTANDARD = "LVDS_25";
191

    
192
   reg [5:0] 	clock_ready_d;
193
   always @(posedge clk_fpga)
194
     clock_ready_d[5:0] <= {clock_ready_d[4:0],clock_ready};
195
   wire 	dcm_rst = ~&clock_ready_d & |clock_ready_d;
196
   
197
   wire 	adc_on_a, adc_on_b, adc_oe_a, adc_oe_b;
198
   assign 	adc_oen_a = ~adc_oe_a;
199
   assign 	adc_oen_b = ~adc_oe_b;
200
   assign 	adc_pdn_a = ~adc_on_a; 	
201
   assign 	adc_pdn_b = ~adc_on_b; 	
202

    
203
   reg [13:0] 	 adc_a_reg1, adc_b_reg1, adc_a_reg2, adc_b_reg2;
204
   reg 		 adc_ovf_a_reg1, adc_ovf_a_reg2, adc_ovf_b_reg1, adc_ovf_b_reg2;
205

    
206
    // ADC A and B are swapped in schematic to facilitate clean layout
207
   always @(posedge dsp_clk)
208
     begin
209
	adc_a_reg1 <= adc_b;
210
	adc_b_reg1 <= adc_a;
211
	adc_ovf_a_reg1 <= adc_ovf_b;
212
	adc_ovf_b_reg1 <= adc_ovf_a;
213
     end
214
   
215
   always @(posedge dsp_clk)
216
     begin
217
	adc_a_reg2 <= adc_a_reg1;
218
	adc_b_reg2 <= adc_b_reg1;
219
	adc_ovf_a_reg2 <= adc_ovf_a_reg1;
220
	adc_ovf_b_reg2 <= adc_ovf_b_reg1;
221
     end // always @ (posedge dsp_clk)
222

    
223
   // Handle Clocks
224
   DCM DCM_INST (.CLKFB(dsp_clk), 
225
                 .CLKIN(clk_fpga), 
226
                 .DSSEN(0), 
227
                 .PSCLK(0), 
228
                 .PSEN(0), 
229
                 .PSINCDEC(0), 
230
                 .RST(dcm_rst), 
231
                 .CLKDV(clk_div), 
232
                 .CLKFX(), 
233
                 .CLKFX180(), 
234
                 .CLK0(dcm_out), 
235
                 .CLK2X(), 
236
                 .CLK2X180(), 
237
                 .CLK90(clk90), 
238
                 .CLK180(clk180), 
239
                 .CLK270(clk270), 
240
                 .LOCKED(LOCKED_OUT), 
241
                 .PSDONE(), 
242
                 .STATUS());
243
   defparam DCM_INST.CLK_FEEDBACK = "1X";
244
   defparam DCM_INST.CLKDV_DIVIDE = 2.0;
245
   defparam DCM_INST.CLKFX_DIVIDE = 1;
246
   defparam DCM_INST.CLKFX_MULTIPLY = 4;
247
   defparam DCM_INST.CLKIN_DIVIDE_BY_2 = "FALSE";
248
   defparam DCM_INST.CLKIN_PERIOD = 10.000;
249
   defparam DCM_INST.CLKOUT_PHASE_SHIFT = "NONE";
250
   defparam DCM_INST.DESKEW_ADJUST = "SYSTEM_SYNCHRONOUS";
251
   defparam DCM_INST.DFS_FREQUENCY_MODE = "LOW";
252
   defparam DCM_INST.DLL_FREQUENCY_MODE = "LOW";
253
   defparam DCM_INST.DUTY_CYCLE_CORRECTION = "TRUE";
254
   defparam DCM_INST.FACTORY_JF = 16'h8080;
255
   defparam DCM_INST.PHASE_SHIFT = 0;
256
   defparam DCM_INST.STARTUP_WAIT = "FALSE";
257

    
258
   BUFG dspclk_BUFG (.I(dcm_out), .O(dsp_clk));
259
   BUFG wbclk_BUFG (.I(clk_div), .O(wb_clk));
260

    
261
   // I2C -- Don't use external transistors for open drain, the FPGA implements this
262
   IOBUF scl_pin(.O(scl_pad_i), .IO(SCL), .I(scl_pad_o), .T(scl_pad_oen_o));
263
   IOBUF sda_pin(.O(sda_pad_i), .IO(SDA), .I(sda_pad_o), .T(sda_pad_oen_o));
264

    
265
   // LEDs are active low outputs
266
   wire [5:0] leds_int;
267
   assign     leds = 6'b011111 ^ leds_int;  // all except eth are active-low
268
   
269
   // SPI
270
   wire 	miso, mosi, sclk_int;
271
   assign 	{sclk,sdi} = (~sen_clk | ~sen_dac) ? {sclk_int,mosi} : 2'b0;
272
   assign 	{sclk_tx_db,sdi_tx_db} = ~sen_tx_db ? {sclk_int,mosi} : 2'b0;
273
   assign 	{sclk_tx_dac,sdi_tx_dac} = ~sen_tx_dac ? {sclk_int,mosi} : 2'b0;
274
   assign 	{sclk_tx_adc,sdi_tx_adc} = ~sen_tx_adc ? {sclk_int,mosi} : 2'b0;
275
   assign 	{sclk_rx_db,sdi_rx_db} = ~sen_rx_db ? {sclk_int,mosi} : 2'b0;
276
   assign 	{sclk_rx_dac,sdi_rx_dac} = ~sen_rx_dac ? {sclk_int,mosi} : 2'b0;
277
   assign 	{sclk_rx_adc,sdi_rx_adc} = ~sen_rx_adc ? {sclk_int,mosi} : 2'b0;
278
   
279
   assign 	miso = (~sen_clk & sdo) | (~sen_dac & sdo) | 
280
		(~sen_tx_db & sdo_tx_db) | (~sen_tx_adc & sdo_tx_adc) |
281
		(~sen_rx_db & sdo_rx_db) | (~sen_rx_adc & sdo_rx_adc);
282

    
283
   wire 	GMII_TX_EN_unreg, GMII_TX_ER_unreg;
284
   wire [7:0] 	GMII_TXD_unreg;
285
   wire 	GMII_GTX_CLK_int;
286
   
287
   always @(posedge GMII_GTX_CLK_int)
288
     begin
289
	GMII_TX_EN <= GMII_TX_EN_unreg;
290
	GMII_TX_ER <= GMII_TX_ER_unreg;
291
	GMII_TXD <= GMII_TXD_unreg;
292
     end
293

    
294
   OFDDRRSE OFDDRRSE_gmii_inst 
295
     (.Q(GMII_GTX_CLK),      // Data output (connect directly to top-level port)
296
      .C0(GMII_GTX_CLK_int),    // 0 degree clock input
297
      .C1(~GMII_GTX_CLK_int),    // 180 degree clock input
298
      .CE(1),    // Clock enable input
299
      .D0(0),    // Posedge data input
300
      .D1(1),    // Negedge data input
301
      .R(0),      // Synchronous reset input
302
      .S(0)       // Synchronous preset input
303
      );
304
   
305
   wire ser_tklsb_unreg, ser_tkmsb_unreg;
306
   wire [15:0] ser_t_unreg;
307
   wire        ser_tx_clk_int;
308
   
309
   always @(posedge ser_tx_clk_int)
310
     begin
311
	ser_tklsb <= ser_tklsb_unreg;
312
	ser_tkmsb <= ser_tkmsb_unreg;
313
	ser_t <= ser_t_unreg;
314
     end
315

    
316
   assign ser_tx_clk = clk_fpga;
317

    
318
   reg [15:0] ser_r_int;
319
   reg 	      ser_rklsb_int, ser_rkmsb_int;
320

    
321
   wire       ser_rx_clk_buf;
322
   BUFG ser_rx_clk_BUF (.O(ser_rx_clk_buf),.I(ser_rx_clk));
323
   always @(posedge ser_rx_clk_buf)
324
     begin
325
	ser_r_int <= ser_r;
326
	ser_rklsb_int <= ser_rklsb;
327
	ser_rkmsb_int <= ser_rkmsb;
328
     end
329

    
330
   wire [15:0] dac_a_int, dac_b_int;
331
   // DAC A and B are swapped in schematic to facilitate clean layout
332
   // DAC A is also inverted in schematic to facilitate clean layout
333
   always @(negedge dsp_clk) dac_a <= ~dac_b_int;
334
   always @(negedge dsp_clk) dac_b <= dac_a_int;
335

    
336
   /*
337
   OFDDRRSE OFDDRRSE_serdes_inst 
338
     (.Q(ser_tx_clk),      // Data output (connect directly to top-level port)
339
      .C0(ser_tx_clk_int),    // 0 degree clock input
340
      .C1(~ser_tx_clk_int),    // 180 degree clock input
341
      .CE(1),    // Clock enable input
342
      .D0(0),    // Posedge data input
343
      .D1(1),    // Negedge data input
344
      .R(0),      // Synchronous reset input
345
      .S(0)       // Synchronous preset input
346
      );
347
   */
348
   u2_core #(.RAM_SIZE(32768))
349
	u2_core(.dsp_clk           (dsp_clk),
350
		     .wb_clk            (wb_clk),
351
		     .clock_ready       (clock_ready),
352
		     .clk_to_mac	(clk_to_mac),
353
		     .pps_in		(pps_in),
354
		     .leds		(leds_int),
355
		     .debug		(debug[31:0]),
356
		     .debug_clk		(debug_clk[1:0]),
357
		     .exp_pps_in	(exp_pps_in),
358
		     .exp_pps_out	(exp_pps_out),
359
		     .GMII_COL		(GMII_COL),
360
		     .GMII_CRS		(GMII_CRS),
361
		     .GMII_TXD		(GMII_TXD_unreg[7:0]),
362
		     .GMII_TX_EN	(GMII_TX_EN_unreg),
363
		     .GMII_TX_ER	(GMII_TX_ER_unreg),
364
		     .GMII_GTX_CLK	(GMII_GTX_CLK_int),
365
		     .GMII_TX_CLK	(GMII_TX_CLK),
366
		     .GMII_RXD		(GMII_RXD[7:0]),
367
		     .GMII_RX_CLK	(GMII_RX_CLK),
368
		     .GMII_RX_DV	(GMII_RX_DV),
369
		     .GMII_RX_ER	(GMII_RX_ER),
370
		     .MDIO		(MDIO),
371
		     .MDC		(MDC),
372
		     .PHY_INTn		(PHY_INTn),
373
		     .PHY_RESETn	(PHY_RESETn),
374
		     .ser_enable	(ser_enable),
375
		     .ser_prbsen	(ser_prbsen),
376
		     .ser_loopen	(ser_loopen),
377
		     .ser_rx_en		(ser_rx_en),
378
		     .ser_tx_clk	(ser_tx_clk_int),
379
		     .ser_t		(ser_t_unreg[15:0]),
380
		     .ser_tklsb		(ser_tklsb_unreg),
381
		     .ser_tkmsb		(ser_tkmsb_unreg),
382
		     .ser_rx_clk	(ser_rx_clk_buf),
383
		     .ser_r		(ser_r_int[15:0]),
384
		     .ser_rklsb		(ser_rklsb_int),
385
		     .ser_rkmsb		(ser_rkmsb_int),
386
		     .cpld_start        (cpld_start),
387
		     .cpld_mode         (cpld_mode),
388
		     .cpld_done         (cpld_done),
389
		     .cpld_din          (cpld_din),
390
		     .cpld_clk          (cpld_clk),
391
		     .cpld_detached     (cpld_detached),
392
		     .cpld_misc         (cpld_misc),
393
		     .cpld_init_b       (cpld_init_b),
394
		     .por               (~POR),
395
		     .config_success    (config_success),
396
		     .adc_a		(adc_a_reg2),
397
		     .adc_ovf_a		(adc_ovf_a_reg2),
398
		     .adc_on_a		(adc_on_a),
399
		     .adc_oe_a		(adc_oe_a),
400
		     .adc_b		(adc_b_reg2),
401
		     .adc_ovf_b		(adc_ovf_b_reg2),
402
		     .adc_on_b		(adc_on_b),
403
		     .adc_oe_b		(adc_oe_b),
404
		     .dac_a		(dac_a_int),
405
		     .dac_b		(dac_b_int),
406
		     .scl_pad_i		(scl_pad_i),
407
		     .scl_pad_o		(scl_pad_o),
408
		     .scl_pad_oen_o	(scl_pad_oen_o),
409
		     .sda_pad_i		(sda_pad_i),
410
		     .sda_pad_o		(sda_pad_o),
411
		     .sda_pad_oen_o	(sda_pad_oen_o),
412
		     .clk_en		(clk_en[1:0]),
413
		     .clk_sel		(clk_sel[1:0]),
414
		     .clk_func		(clk_func),
415
		     .clk_status	(clk_status),
416
		     .sclk		(sclk_int),
417
		     .mosi		(mosi),
418
		     .miso		(miso),
419
		     .sen_clk		(sen_clk),
420
		     .sen_dac		(sen_dac),
421
		     .sen_tx_db		(sen_tx_db),
422
		     .sen_tx_adc	(sen_tx_adc),
423
		     .sen_tx_dac	(sen_tx_dac),
424
		     .sen_rx_db		(sen_rx_db),
425
		     .sen_rx_adc	(sen_rx_adc),
426
		     .sen_rx_dac	(sen_rx_dac),
427
		     .io_tx		(io_tx[15:0]),
428
		     .io_rx		(io_rx[15:0]),
429
		     .RAM_D             (RAM_D),
430
		     .RAM_A             (RAM_A),
431
		     .RAM_CE1n          (RAM_CE1n),
432
		     .RAM_CENn          (RAM_CENn),
433
		     .RAM_CLK           (RAM_CLK),
434
		     .RAM_WEn           (RAM_WEn),
435
		     .RAM_OEn           (RAM_OEn),
436
		     .RAM_LDn           (RAM_LDn), 
437
		     .uart_tx_o         (uart_tx_o),
438
		     .uart_rx_i         (uart_rx_i),
439
		     .uart_baud_o       (),
440
		     .sim_mode          (1'b0),
441
		     .clock_divider     (2)
442
		     );
443
   
444
endmodule // u2_rev2