OpenCores
URL https://opencores.org/ocsvn/fpga-cf/fpga-cf/trunk

Subversion Repositories fpga-cf

[/] [fpga-cf/] [trunk/] [hdl/] [topv5_clkcntrl.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 peteralieb
// Top Module
2
 
3
module top
4
(
5
   // SGMII Interface - EMAC0
6
   TXP_0,
7
   TXN_0,
8
   RXP_0,
9
   RXN_0,
10
 
11
   // SGMII MGT Clock buffer inputs 
12
   MGTCLK_N,
13
   MGTCLK_P,
14
 
15
   // reset for ethernet phy
16
   PHY_RESET_0,
17
 
18
   // GTP link status
19
   GTP_READY,
20
 
21
   // Asynchronous Reset
22
   RESET,
23
 
24
        // LED Status
25
        LEDS,
26
 
27
        // DIP Switch
28
        DIP,
29
 
30
        // CPU RESET
31
        RESET_CPU
32
);
33
 
34
//-----------------------------------------------------------------------------
35
// Port Declarations 
36
//-----------------------------------------------------------------------------
37
 
38
   // SGMII Interface - EMAC0
39
   output          TXP_0;
40
   output          TXN_0;
41
   input           RXP_0;
42
   input           RXN_0;
43
 
44
   // SGMII MGT Clock buffer inputs 
45
   input           MGTCLK_N;
46
   input           MGTCLK_P;
47
 
48
   // reset for ethernet phy
49
   output          PHY_RESET_0;
50
 
51
   // GTP link status
52
   output          GTP_READY;
53
 
54
   // Asynchronous Reset
55
   input           RESET;
56
 
57
        // LED Status
58
        output  [7:0]            LEDS;
59
 
60
        // DIP Switches
61
        input   [7:0]            DIP;
62
 
63
        // CPU RESET
64
        input                           RESET_CPU;
65
 
66
//-----------------------------------------------------------------------------
67
 
68
 
69
//-------------------------------------------------------------------------------------
70
//-------------------------------------------------------------------------------------
71
//                                                       User Signals
72
//-------------------------------------------------------------------------------------
73
//-------------------------------------------------------------------------------------
74
 
75
reg [7:0] DIP_r;
76
wire reset_cpu_p;
77
wire reset_cpu_i;
78
 
79
 
80
//-----------------------------------------------------------------------------
81
// Ethernet Platform Instance
82
//-----------------------------------------------------------------------------
83
 
84
wire in_src_rdy_usr;
85
wire out_dst_rdy_usr;
86
wire [7:0] in_data_usr;
87
wire in_sof_usr;
88
wire in_eof_usr;
89
wire in_dst_rdy_usr;
90
wire out_src_rdy_usr;
91
wire [7:0] out_data_usr;
92
wire out_sof_usr;
93
wire out_eof_usr;
94
wire [3:0] outport_usr;
95
wire [3:0] inport_usr;
96
wire clk_local;
97
 
98
 
99
enetplatform enet_inst
100
(
101
   .TXP_0(TXP_0),
102
   .TXN_0(TXN_0),
103
   .RXP_0(RXP_0),
104
   .RXN_0(RXN_0),
105
   .MGTCLK_N(MGTCLK_N),
106
   .MGTCLK_P(MGTCLK_P),
107
   .PHY_RESET_0(PHY_RESET_0),
108
   .GTP_READY(GTP_READY),
109
   .RESET(RESET),
110
        .RESET_CPU(reset_cpu_p),
111
        .in_src_rdy_usr(in_src_rdy_usr),
112
        .out_dst_rdy_usr(out_dst_rdy_usr),
113
        .in_data_usr(in_data_usr),
114
        .in_sof_usr(in_sof_usr),
115
        .in_eof_usr(in_eof_usr),
116
        .in_dst_rdy_usr(in_dst_rdy_usr),
117
        .out_src_rdy_usr(out_src_rdy_usr),
118
        .out_data_usr(out_data_usr),
119
        .out_sof_usr(out_sof_usr),
120
        .out_eof_usr(out_eof_usr),
121
        .outport_usr(outport_usr),
122
        .inport_usr(inport_usr),
123
        .clk_local(clk_local)
124
);
125
 
126
//-------------------------------------------------------------------------------------
127
//-------------------------------------------------------------------------------------
128
 
129
 
130
//-------------------------------------------------------------------------------------
131
//-------------------------------------------------------------------------------------
132
//                                                       ICAP Logic
133
//-------------------------------------------------------------------------------------
134
//-------------------------------------------------------------------------------------
135
 
136
wire icap_en_wr;
137
wire icap_en_rd;
138
wire icap_out_src_rdy;
139
wire icap_out_dst_rdy;
140
wire icap_in_src_rdy;
141
wire icap_in_dst_rdy;
142
wire icap_out_sof;
143
wire icap_out_eof;
144
wire icap_in_sof;
145
wire icap_in_eof;
146
wire [7:0] icap_dataout;
147
wire [7:0] icap_datain;
148
 
149
port_icap_buf the_picap
150
(
151
        .clk(clk_local),
152
        .rst(rst),
153
        .en_wr(icap_en_wr),
154
        .en_rd(icap_en_rd),
155
        .in_data(icap_datain),
156
        .in_sof(icap_in_sof),
157
        .in_eof(icap_in_eof),
158
        .in_src_rdy(icap_in_src_rdy),
159
        .out_dst_rdy(icap_out_dst_rdy),
160
        .out_data(icap_dataout),
161
        .out_sof(icap_out_sof),
162
        .out_eof(icap_out_eof),
163
        .out_src_rdy(icap_out_src_rdy),
164
        .in_dst_rdy(icap_in_dst_rdy)
165
);
166
 
167
assign icap_en_wr = ((outport_usr == 3 && out_src_rdy_usr == 1) || (inport_usr == 3 && in_dst_rdy_usr == 1)) ? 1 : 0;
168
assign icap_en_rd = ((outport_usr == 4 && out_src_rdy_usr == 1) || (inport_usr == 4 && in_dst_rdy_usr == 1)) ? 1 : 0;
169
//assign in_src_rdy_usr =       (inport_usr == 3 || inport_usr == 4) ? icap_out_src_rdy : 1;
170
//assign out_dst_rdy_usr = (outport_usr == 3 || outport_usr == 4) ? icap_in_dst_rdy : 1;
171
//assign in_sof_usr = (inport_usr == 3 || inport_usr == 4) ? icap_sofout : 1;
172
//assign in_eof_usr = (inport_usr == 3 || inport_usr == 4) ? icap_eofout : 1;
173
//assign in_data_usr = (inport_usr == 3 || inport_usr == 4) ? icap_dataout : DIP_r;
174
 
175
 
176
//-------------------------------------------------------------------------------------
177
//-------------------------------------------------------------------------------------
178
//                                                       Channel Routing
179
//-------------------------------------------------------------------------------------
180
//-------------------------------------------------------------------------------------
181
 
182
wire ch1_in_sof;
183
wire ch1_in_eof;
184
wire ch1_in_src_rdy;
185
wire ch1_in_dst_rdy;
186
wire [7:0] ch1_in_data;
187
wire ch1_out_sof;
188
wire ch1_out_eof;
189
wire ch1_out_src_rdy;
190
wire ch1_out_dst_rdy;
191
wire [7:0] ch1_out_data;
192
wire ch1_wen;
193
wire ch1_ren;
194
 
195
wire ch2_in_sof;
196
wire ch2_in_eof;
197
wire ch2_in_src_rdy;
198
wire ch2_in_dst_rdy;
199
wire [7:0] ch2_in_data;
200
wire ch2_out_sof;
201
wire ch2_out_eof;
202
wire ch2_out_src_rdy;
203
wire ch2_out_dst_rdy;
204
wire [7:0] ch2_out_data;
205
wire ch2_wen;
206
wire ch2_ren;
207
 
208
wire ch3_in_sof;
209
wire ch3_in_eof;
210
wire ch3_in_src_rdy;
211
wire ch3_in_dst_rdy;
212
wire [7:0] ch3_in_data;
213
wire ch3_out_sof;
214
wire ch3_out_eof;
215
wire ch3_out_src_rdy;
216
wire ch3_out_dst_rdy;
217
wire [7:0] ch3_out_data;
218
wire ch3_wen;
219
wire ch3_ren;
220
 
221
wire ch4_in_sof;
222
wire ch4_in_eof;
223
wire ch4_in_src_rdy;
224
wire ch4_in_dst_rdy;
225
wire [7:0] ch4_in_data;
226
wire ch4_out_sof;
227
wire ch4_out_eof;
228
wire ch4_out_src_rdy;
229
wire ch4_out_dst_rdy;
230
wire [7:0] ch4_out_data;
231
wire ch4_wen;
232
wire ch4_ren;
233
 
234
channelif4 channelif_inst
235
(
236
        .in_sof(out_sof_usr),
237
        .in_eof(out_eof_usr),
238
        .in_src_rdy(out_src_rdy_usr),
239
        .in_dst_rdy(out_dst_rdy_usr),
240
        .in_data(out_data_usr),
241
        .inport_addr(outport_usr),
242
        .out_sof(in_sof_usr),
243
        .out_eof(in_eof_usr),
244
        .out_src_rdy(in_src_rdy_usr),
245
        .out_dst_rdy(in_dst_rdy_usr),
246
        .out_data(in_data_usr),
247
        .outport_addr(inport_usr),
248
        .wenables(),
249
        .renables(),
250
 
251
        .ch1_in_sof(ch1_in_sof),
252
        .ch1_in_eof(ch1_in_eof),
253
        .ch1_in_src_rdy(ch1_in_src_rdy),
254
        .ch1_in_dst_rdy(ch1_in_dst_rdy),
255
        .ch1_in_data(ch1_in_data),
256
        .ch1_out_sof(ch1_out_sof),
257
        .ch1_out_eof(ch1_out_eof),
258
        .ch1_out_src_rdy(ch1_out_src_rdy),
259
        .ch1_out_dst_rdy(ch1_out_dst_rdy),
260
        .ch1_out_data(ch1_out_data),
261
        .ch1_wen(ch1_wen),
262
        .ch1_ren(ch1_ren),
263
 
264
        .ch2_in_sof(ch2_in_sof),
265
        .ch2_in_eof(ch2_in_eof),
266
        .ch2_in_src_rdy(ch2_in_src_rdy),
267
        .ch2_in_dst_rdy(ch2_in_dst_rdy),
268
        .ch2_in_data(ch2_in_data),
269
        .ch2_out_sof(ch2_out_sof),
270
        .ch2_out_eof(ch2_out_eof),
271
        .ch2_out_src_rdy(ch2_out_src_rdy),
272
        .ch2_out_dst_rdy(ch2_out_dst_rdy),
273
        .ch2_out_data(ch2_out_data),
274
        .ch2_wen(ch2_wen),
275
        .ch2_ren(ch2_ren),
276
 
277
        .ch3_in_sof(ch3_in_sof),
278
        .ch3_in_eof(ch3_in_eof),
279
        .ch3_in_src_rdy(ch3_in_src_rdy),
280
        .ch3_in_dst_rdy(ch3_in_dst_rdy),
281
        .ch3_in_data(ch3_in_data),
282
        .ch3_out_sof(ch3_out_sof),
283
        .ch3_out_eof(ch3_out_eof),
284
        .ch3_out_src_rdy(ch3_out_src_rdy),
285
        .ch3_out_dst_rdy(ch3_out_dst_rdy),
286
        .ch3_out_data(ch3_out_data),
287
        .ch3_wen(ch3_wen),
288
        .ch3_ren(ch3_ren),
289
 
290
        .ch4_in_sof(ch4_in_sof),
291
        .ch4_in_eof(ch4_in_eof),
292
        .ch4_in_src_rdy(ch4_in_src_rdy),
293
        .ch4_in_dst_rdy(ch4_in_dst_rdy),
294
        .ch4_in_data(ch4_in_data),
295
        .ch4_out_sof(ch4_out_sof),
296
        .ch4_out_eof(ch4_out_eof),
297
        .ch4_out_src_rdy(ch4_out_src_rdy),
298
        .ch4_out_dst_rdy(ch4_out_dst_rdy),
299
        .ch4_out_data(ch4_out_data),
300
        .ch4_wen(ch4_wen),
301
        .ch4_ren(ch4_ren)
302
);
303
 
304
 
305
//-------------------------------------------------------------------------------------
306
//-------------------------------------------------------------------------------------
307
//                                                       User Logic
308
//-------------------------------------------------------------------------------------
309
//-------------------------------------------------------------------------------------
310
 
311
IBUF cpu_reset_ibuf (.I(RESET_CPU), .O(reset_cpu_i));
312
 
313
wire clk_controlled;
314
 
315
assign reset_cpu_p = ~reset_cpu_i;
316
 
317
always @(posedge clk_local)
318
begin
319
        DIP_r <= DIP;
320
end
321
 
322
// Moving LED
323
counting_led cled (
324
        .clk(clk_controlled),
325
        .rst(rst),
326
        .leds(LEDS)
327
);
328
 
329
// Clock Control
330
port_clkcntl clkcontrol (
331
        .clk(clk_local),
332
        .rst(rst),
333
        .en(ch2_wen),
334
        .in_data(ch2_out_data),
335
        .in_sof(ch2_out_sof),
336
        .in_eof(ch2_out_eof),
337
        .in_src_rdy(ch2_out_src_rdy),
338
        .out_dst_rdy(ch2_in_dst_rdy),
339
        .usr_clk_in(clk_local),
340
        .out_data(),
341
        .out_sof(),
342
        .out_eof(),
343
        .out_src_rdy(),
344
        .in_dst_rdy(ch2_out_dst_rdy),
345
        .usr_clk_out(clk_controlled)
346
);
347
 
348
assign ch3_in_sof = icap_out_sof;
349
assign ch3_in_eof = icap_out_eof;
350
assign ch3_in_src_rdy = icap_out_src_rdy;
351
assign ch3_in_data = icap_dataout;
352
assign ch3_out_dst_rdy = icap_in_dst_rdy;
353
assign icap_datain = ch3_out_data | ch4_out_data;
354
assign icap_out_dst_rdy = ch3_in_dst_rdy | ch4_in_dst_rdy;
355
assign icap_in_src_rdy = ch3_out_src_rdy | ch4_out_src_rdy;
356
assign icap_in_sof = ch3_out_sof | ch4_out_sof;
357
assign icap_in_eof = ch3_out_eof | ch4_out_eof;
358
 
359
assign ch4_in_sof = icap_out_sof;
360
assign ch4_in_eof = icap_out_eof;
361
assign ch4_in_src_rdy = icap_out_src_rdy;
362
assign ch4_in_data = icap_dataout;
363
assign ch4_out_dst_rdy = icap_in_dst_rdy;
364
 
365
assign ch1_in_sof = 1;
366
assign ch1_in_eof = 1;
367
assign ch1_in_src_rdy = 1;
368
assign ch1_out_dst_rdy = 1;
369
assign ch1_in_data = DIP_r;
370
 
371
assign ch2_in_sof = 1;
372
assign ch2_in_eof = 1;
373
assign ch2_in_src_rdy = 1;
374
assign ch2_in_data = 8'hCC;
375
 
376
 
377
 
378
endmodule

powered by: WebSVN 2.1.0

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