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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [rtl/] [verilog/] [orpsoc_top/] [orpsoc_top.v] - Blame information for rev 360

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 44 julius
//////////////////////////////////////////////////////////////////////
2 360 julius
///                                                               //// 
3
/// ORPSoC top level                                              ////
4
///                                                               ////
5
/// Define I/O ports, instantiate modules                         ////
6
///                                                               ////
7
/// Julius Baxter, julius@opencores.org                           ////
8
///                                                               ////
9 44 julius
//////////////////////////////////////////////////////////////////////
10
////                                                              ////
11 360 julius
//// Copyright (C) 2009, 2010 Authors and OPENCORES.ORG           ////
12 44 julius
////                                                              ////
13
//// This source file may be used and distributed without         ////
14
//// restriction provided that this copyright statement is not    ////
15
//// removed from the file and that any derivative work contains  ////
16
//// the original copyright notice and the associated disclaimer. ////
17
////                                                              ////
18
//// This source file is free software; you can redistribute it   ////
19
//// and/or modify it under the terms of the GNU Lesser General   ////
20
//// Public License as published by the Free Software Foundation; ////
21
//// either version 2.1 of the License, or (at your option) any   ////
22
//// later version.                                               ////
23
////                                                              ////
24
//// This source is distributed in the hope that it will be       ////
25
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
26
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
27
//// PURPOSE.  See the GNU Lesser General Public License for more ////
28
//// details.                                                     ////
29
////                                                              ////
30
//// You should have received a copy of the GNU Lesser General    ////
31
//// Public License along with this source; if not, download it   ////
32
//// from http://www.opencores.org/lgpl.shtml                     ////
33
////                                                              ////
34
//////////////////////////////////////////////////////////////////////
35
 
36 360 julius
`include "orpsoc-defines.v"
37 44 julius
 
38 6 julius
module orpsoc_top
39 360 julius
  (
40
`ifdef JTAG_DEBUG
41
    tdo_pad_o, tms_pad_i, tck_pad_i, tdi_pad_i,
42
`endif
43
`ifdef UART0
44
    uart0_srx_pad_i, uart0_stx_pad_o,
45 6 julius
`endif
46 360 julius
    clk_pad_i,
47
    rst_n_pad_i
48
    );
49 54 julius
 
50 360 julius
`include "orpsoc-params.v"
51 54 julius
 
52 360 julius
   input clk_pad_i;
53
   input rst_n_pad_i;
54
 
55
`ifdef JTAG_DEBUG
56
   output tdo_pad_o;
57
   input  tms_pad_i;
58
   input  tck_pad_i;
59
   input  tdi_pad_i;
60
`endif
61
`ifdef UART0
62
   input  uart0_srx_pad_i;
63
   output uart0_stx_pad_o;
64
`endif
65
 
66
   ////////////////////////////////////////////////////////////////////////
67
   //
68
   // Clock and reset generation module
69
   // 
70
   ////////////////////////////////////////////////////////////////////////
71 54 julius
 
72 360 julius
   //
73
   // Wires
74
   //
75
   wire                       wb_clk, wb_rst;
76
   wire                       dbg_tck;
77 54 julius
 
78 360 julius
 
79
   clkgen clkgen0
80
     (
81
 
82
      .clk_pad_i             (clk_pad_i),
83 54 julius
 
84 360 julius
      .wb_clk_o                  (wb_clk),
85
      .wb_rst_o                  (wb_rst),
86 54 julius
 
87 360 julius
`ifdef JTAG_DEBUG
88
      .tck_pad_i                 (tck_pad_i),
89
      .dbg_tck_o                 (dbg_tck),
90
`endif
91 54 julius
 
92 360 julius
      // Asynchronous active low reset
93
      .rst_n_pad_i               (rst_n_pad_i)
94
      );
95 54 julius
 
96 360 julius
 
97
   ////////////////////////////////////////////////////////////////////////
98
   //
99
   // Arbiter
100
   // 
101
   ////////////////////////////////////////////////////////////////////////
102
 
103
   // Wire naming convention:
104
   // First: wishbone master or slave (wbm/wbs)
105
   // Second: Which bus it's on instruction or data (i/d)
106
   // Third: Between which module and the arbiter the wires are
107
   // Fourth: Signal name
108
   // Fifth: Direction relative to module (not bus/arbiter!)
109
   //        ie. wbm_d_or12_adr_o is address OUT from the or1200
110 54 julius
 
111 360 julius
   // OR1200 instruction bus wires
112
   wire [wb_aw-1:0]            wbm_i_or12_adr_o;
113
   wire [wb_dw-1:0]            wbm_i_or12_dat_o;
114
   wire [3:0]                  wbm_i_or12_sel_o;
115
   wire                       wbm_i_or12_we_o;
116
   wire                       wbm_i_or12_cyc_o;
117
   wire                       wbm_i_or12_stb_o;
118
   wire [2:0]                  wbm_i_or12_cti_o;
119
   wire [1:0]                  wbm_i_or12_bte_o;
120
 
121
   wire [wb_dw-1:0]            wbm_i_or12_dat_i;
122
   wire                       wbm_i_or12_ack_i;
123
   wire                       wbm_i_or12_err_i;
124
   wire                       wbm_i_or12_rty_i;
125 54 julius
 
126 360 julius
   // OR1200 data bus wires   
127
   wire [wb_aw-1:0]            wbm_d_or12_adr_o;
128
   wire [wb_dw-1:0]            wbm_d_or12_dat_o;
129
   wire [3:0]                  wbm_d_or12_sel_o;
130
   wire                       wbm_d_or12_we_o;
131
   wire                       wbm_d_or12_cyc_o;
132
   wire                       wbm_d_or12_stb_o;
133
   wire [2:0]                  wbm_d_or12_cti_o;
134
   wire [1:0]                  wbm_d_or12_bte_o;
135
 
136
   wire [wb_dw-1:0]            wbm_d_or12_dat_i;
137
   wire                       wbm_d_or12_ack_i;
138
   wire                       wbm_d_or12_err_i;
139
   wire                       wbm_d_or12_rty_i;
140 54 julius
 
141 360 julius
   // Debug interface bus wires   
142
   wire [wb_aw-1:0]            wbm_d_dbg_adr_o;
143
   wire [wb_dw-1:0]            wbm_d_dbg_dat_o;
144
   wire [3:0]                  wbm_d_dbg_sel_o;
145
   wire                       wbm_d_dbg_we_o;
146
   wire                       wbm_d_dbg_cyc_o;
147
   wire                       wbm_d_dbg_stb_o;
148
   wire [2:0]                  wbm_d_dbg_cti_o;
149
   wire [1:0]                  wbm_d_dbg_bte_o;
150
 
151
   wire [wb_dw-1:0]            wbm_d_dbg_dat_i;
152
   wire                       wbm_d_dbg_ack_i;
153
   wire                       wbm_d_dbg_err_i;
154
   wire                       wbm_d_dbg_rty_i;
155 54 julius
 
156 360 julius
   // Byte bus bridge master signals
157
   wire [wb_aw-1:0]            wbm_b_d_adr_o;
158
   wire [wb_dw-1:0]            wbm_b_d_dat_o;
159
   wire [3:0]                  wbm_b_d_sel_o;
160
   wire                       wbm_b_d_we_o;
161
   wire                       wbm_b_d_cyc_o;
162
   wire                       wbm_b_d_stb_o;
163
   wire [2:0]                  wbm_b_d_cti_o;
164
   wire [1:0]                  wbm_b_d_bte_o;
165
 
166
   wire [wb_dw-1:0]            wbm_b_d_dat_i;
167
   wire                       wbm_b_d_ack_i;
168
   wire                       wbm_b_d_err_i;
169
   wire                       wbm_b_d_rty_i;
170 54 julius
 
171 360 julius
   // Instruction bus slave wires //
172
 
173
   // rom0 instruction bus wires
174
   wire [31:0]                 wbs_i_rom0_adr_i;
175
   wire [wbs_i_rom0_data_width-1:0] wbs_i_rom0_dat_i;
176
   wire [3:0]                        wbs_i_rom0_sel_i;
177
   wire                             wbs_i_rom0_we_i;
178
   wire                             wbs_i_rom0_cyc_i;
179
   wire                             wbs_i_rom0_stb_i;
180
   wire [2:0]                        wbs_i_rom0_cti_i;
181
   wire [1:0]                        wbs_i_rom0_bte_i;
182
   wire [wbs_i_rom0_data_width-1:0] wbs_i_rom0_dat_o;
183
   wire                             wbs_i_rom0_ack_o;
184
   wire                             wbs_i_rom0_err_o;
185
   wire                             wbs_i_rom0_rty_o;
186 54 julius
 
187 360 julius
   // mc0 instruction bus wires
188
   wire [31:0]                       wbs_i_mc0_adr_i;
189
   wire [31:0]                       wbs_i_mc0_dat_i;
190
   wire [3:0]                        wbs_i_mc0_sel_i;
191
   wire                             wbs_i_mc0_we_i;
192
   wire                             wbs_i_mc0_cyc_i;
193
   wire                             wbs_i_mc0_stb_i;
194
   wire [2:0]                        wbs_i_mc0_cti_i;
195
   wire [1:0]                        wbs_i_mc0_bte_i;
196
   wire [31:0]                       wbs_i_mc0_dat_o;
197
   wire                             wbs_i_mc0_ack_o;
198
   wire                             wbs_i_mc0_err_o;
199
   wire                             wbs_i_mc0_rty_o;
200
 
201
   // Data bus slave wires //
202
 
203
   // mc0 data bus wires
204
   wire [31:0]                       wbs_d_mc0_adr_i;
205
   wire [31:0]                       wbs_d_mc0_dat_i;
206
   wire [3:0]                        wbs_d_mc0_sel_i;
207
   wire                             wbs_d_mc0_we_i;
208
   wire                             wbs_d_mc0_cyc_i;
209
   wire                             wbs_d_mc0_stb_i;
210
   wire [2:0]                        wbs_d_mc0_cti_i;
211
   wire [1:0]                        wbs_d_mc0_bte_i;
212
   wire [31:0]                       wbs_d_mc0_dat_o;
213
   wire                             wbs_d_mc0_ack_o;
214
   wire                             wbs_d_mc0_err_o;
215
   wire                             wbs_d_mc0_rty_o;
216
 
217
   // uart0 wires
218
   wire [31:0]                        wbs_d_uart0_adr_i;
219
   wire [wbs_d_uart0_data_width-1:0] wbs_d_uart0_dat_i;
220
   wire [3:0]                         wbs_d_uart0_sel_i;
221
   wire                              wbs_d_uart0_we_i;
222
   wire                              wbs_d_uart0_cyc_i;
223
   wire                              wbs_d_uart0_stb_i;
224
   wire [2:0]                         wbs_d_uart0_cti_i;
225
   wire [1:0]                         wbs_d_uart0_bte_i;
226
   wire [wbs_d_uart0_data_width-1:0] wbs_d_uart0_dat_o;
227
   wire                              wbs_d_uart0_ack_o;
228
   wire                              wbs_d_uart0_err_o;
229
   wire                              wbs_d_uart0_rty_o;
230 54 julius
 
231
 
232 360 julius
   //
233
   // Wishbone instruction bus arbiter
234
   //
235 351 julius
 
236 360 julius
   arbiter_ibus arbiter_ibus0
237 351 julius
     (
238 360 julius
      // Instruction Bus Master
239
      // Inputs to arbiter from master
240
      .wbm_adr_o                        (wbm_i_or12_adr_o),
241
      .wbm_dat_o                        (wbm_i_or12_dat_o),
242
      .wbm_sel_o                        (wbm_i_or12_sel_o),
243
      .wbm_we_o                         (wbm_i_or12_we_o),
244
      .wbm_cyc_o                        (wbm_i_or12_cyc_o),
245
      .wbm_stb_o                        (wbm_i_or12_stb_o),
246
      .wbm_cti_o                        (wbm_i_or12_cti_o),
247
      .wbm_bte_o                        (wbm_i_or12_bte_o),
248
      // Outputs to master from arbiter
249
      .wbm_dat_i                        (wbm_i_or12_dat_i),
250
      .wbm_ack_i                        (wbm_i_or12_ack_i),
251
      .wbm_err_i                        (wbm_i_or12_err_i),
252
      .wbm_rty_i                        (wbm_i_or12_rty_i),
253 351 julius
 
254 360 julius
      // Slave 0
255
      // Inputs to slave from arbiter
256
      .wbs0_adr_i                       (wbs_i_rom0_adr_i),
257
      .wbs0_dat_i                       (wbs_i_rom0_dat_i),
258
      .wbs0_sel_i                       (wbs_i_rom0_sel_i),
259
      .wbs0_we_i                        (wbs_i_rom0_we_i),
260
      .wbs0_cyc_i                       (wbs_i_rom0_cyc_i),
261
      .wbs0_stb_i                       (wbs_i_rom0_stb_i),
262
      .wbs0_cti_i                       (wbs_i_rom0_cti_i),
263
      .wbs0_bte_i                       (wbs_i_rom0_bte_i),
264
      // Outputs from slave to arbiter      
265
      .wbs0_dat_o                       (wbs_i_rom0_dat_o),
266
      .wbs0_ack_o                       (wbs_i_rom0_ack_o),
267
      .wbs0_err_o                       (wbs_i_rom0_err_o),
268
      .wbs0_rty_o                       (wbs_i_rom0_rty_o),
269 351 julius
 
270 360 julius
      // Slave 1
271
      // Inputs to slave from arbiter
272
      .wbs1_adr_i                       (wbs_i_mc0_adr_i),
273
      .wbs1_dat_i                       (wbs_i_mc0_dat_i),
274
      .wbs1_sel_i                       (wbs_i_mc0_sel_i),
275
      .wbs1_we_i                        (wbs_i_mc0_we_i),
276
      .wbs1_cyc_i                       (wbs_i_mc0_cyc_i),
277
      .wbs1_stb_i                       (wbs_i_mc0_stb_i),
278
      .wbs1_cti_i                       (wbs_i_mc0_cti_i),
279
      .wbs1_bte_i                       (wbs_i_mc0_bte_i),
280
      // Outputs from slave to arbiter
281
      .wbs1_dat_o                       (wbs_i_mc0_dat_o),
282
      .wbs1_ack_o                       (wbs_i_mc0_ack_o),
283
      .wbs1_err_o                       (wbs_i_mc0_err_o),
284
      .wbs1_rty_o                       (wbs_i_mc0_rty_o),
285 351 julius
 
286 360 julius
      // Clock, reset inputs
287
      .wb_clk                           (wb_clk),
288
      .wb_rst                           (wb_rst));
289 351 julius
 
290 360 julius
   defparam arbiter_ibus0.wb_addr_match_width = ibus_arb_addr_match_width;
291 351 julius
 
292 360 julius
   defparam arbiter_ibus0.slave0_adr = ibus_arb_slave0_adr; // ROM
293
   defparam arbiter_ibus0.slave1_adr = ibus_arb_slave1_adr; // Main memory
294 351 julius
 
295 360 julius
   //
296
   // Wishbone data bus arbiter
297
   //
298
 
299
   arbiter_dbus arbiter_dbus0
300
     (
301
      // Master 0
302
      // Inputs to arbiter from master
303
      .wbm0_adr_o                       (wbm_d_or12_adr_o),
304
      .wbm0_dat_o                       (wbm_d_or12_dat_o),
305
      .wbm0_sel_o                       (wbm_d_or12_sel_o),
306
      .wbm0_we_o                        (wbm_d_or12_we_o),
307
      .wbm0_cyc_o                       (wbm_d_or12_cyc_o),
308
      .wbm0_stb_o                       (wbm_d_or12_stb_o),
309
      .wbm0_cti_o                       (wbm_d_or12_cti_o),
310
      .wbm0_bte_o                       (wbm_d_or12_bte_o),
311
      // Outputs to master from arbiter
312
      .wbm0_dat_i                       (wbm_d_or12_dat_i),
313
      .wbm0_ack_i                       (wbm_d_or12_ack_i),
314
      .wbm0_err_i                       (wbm_d_or12_err_i),
315
      .wbm0_rty_i                       (wbm_d_or12_rty_i),
316 351 julius
 
317 360 julius
      // Master 0
318
      // Inputs to arbiter from master
319
      .wbm1_adr_o                       (wbm_d_dbg_adr_o),
320
      .wbm1_dat_o                       (wbm_d_dbg_dat_o),
321
      .wbm1_we_o                        (wbm_d_dbg_we_o),
322
      .wbm1_cyc_o                       (wbm_d_dbg_cyc_o),
323
      .wbm1_sel_o                       (wbm_d_dbg_sel_o),
324
      .wbm1_stb_o                       (wbm_d_dbg_stb_o),
325
      .wbm1_cti_o                       (wbm_d_dbg_cti_o),
326
      .wbm1_bte_o                       (wbm_d_dbg_bte_o),
327
      // Outputs to master from arbiter      
328
      .wbm1_dat_i                       (wbm_d_dbg_dat_i),
329
      .wbm1_ack_i                       (wbm_d_dbg_ack_i),
330
      .wbm1_err_i                       (wbm_d_dbg_err_i),
331
      .wbm1_rty_i                       (wbm_d_dbg_rty_i),
332 351 julius
 
333 360 julius
      // Slaves
334 351 julius
 
335 360 julius
      .wbs0_adr_i                       (wbs_d_mc0_adr_i),
336
      .wbs0_dat_i                       (wbs_d_mc0_dat_i),
337
      .wbs0_sel_i                       (wbs_d_mc0_sel_i),
338
      .wbs0_we_i                        (wbs_d_mc0_we_i),
339
      .wbs0_cyc_i                       (wbs_d_mc0_cyc_i),
340
      .wbs0_stb_i                       (wbs_d_mc0_stb_i),
341
      .wbs0_cti_i                       (wbs_d_mc0_cti_i),
342
      .wbs0_bte_i                       (wbs_d_mc0_bte_i),
343
      .wbs0_dat_o                       (wbs_d_mc0_dat_o),
344
      .wbs0_ack_o                       (wbs_d_mc0_ack_o),
345
      .wbs0_err_o                       (wbs_d_mc0_err_o),
346
      .wbs0_rty_o                       (wbs_d_mc0_rty_o),
347
 
348
      .wbs1_adr_i                       (wbm_b_d_adr_o),
349
      .wbs1_dat_i                       (wbm_b_d_dat_o),
350
      .wbs1_sel_i                       (wbm_b_d_sel_o),
351
      .wbs1_we_i                        (wbm_b_d_we_o),
352
      .wbs1_cyc_i                       (wbm_b_d_cyc_o),
353
      .wbs1_stb_i                       (wbm_b_d_stb_o),
354
      .wbs1_cti_i                       (wbm_b_d_cti_o),
355
      .wbs1_bte_i                       (wbm_b_d_bte_o),
356
      .wbs1_dat_o                       (wbm_b_d_dat_i),
357
      .wbs1_ack_o                       (wbm_b_d_ack_i),
358
      .wbs1_err_o                       (wbm_b_d_err_i),
359
      .wbs1_rty_o                       (wbm_b_d_rty_i),
360
 
361
      // Clock, reset inputs
362 351 julius
      .wb_clk                   (wb_clk),
363
      .wb_rst                   (wb_rst));
364 360 julius
 
365
   // These settings are from top level params file
366
   defparam arbiter_dbus0.wb_addr_match_width = dbus_arb_wb_addr_match_width;
367
   defparam arbiter_dbus0.wb_num_slaves = dbus_arb_wb_num_slaves;
368
   defparam arbiter_dbus0.slave0_adr = dbus_arb_slave0_adr;
369
   defparam arbiter_dbus0.slave1_adr = dbus_arb_slave1_adr;
370
 
371
   //
372
   // Wishbone byte-wide bus arbiter
373
   //   
374 351 julius
 
375 360 julius
   arbiter_bytebus arbiter_bytebus0
376
     (
377 351 julius
 
378 360 julius
      // Master 0
379
      // Inputs to arbiter from master
380
      .wbm0_adr_o                       (wbm_b_d_adr_o),
381
      .wbm0_dat_o                       (wbm_b_d_dat_o),
382
      .wbm0_sel_o                       (wbm_b_d_sel_o),
383
      .wbm0_we_o                        (wbm_b_d_we_o),
384
      .wbm0_cyc_o                       (wbm_b_d_cyc_o),
385
      .wbm0_stb_o                       (wbm_b_d_stb_o),
386
      .wbm0_cti_o                       (wbm_b_d_cti_o),
387
      .wbm0_bte_o                       (wbm_b_d_bte_o),
388
      // Outputs to master from arbiter
389
      .wbm0_dat_i                       (wbm_b_d_dat_i),
390
      .wbm0_ack_i                       (wbm_b_d_ack_i),
391
      .wbm0_err_i                       (wbm_b_d_err_i),
392
      .wbm0_rty_i                       (wbm_b_d_rty_i),
393
 
394
      // Byte bus slaves
395
 
396
      .wbs0_adr_i                       (wbs_d_uart0_adr_i),
397
      .wbs0_dat_i                       (wbs_d_uart0_dat_i),
398
      .wbs0_we_i                        (wbs_d_uart0_we_i),
399
      .wbs0_cyc_i                       (wbs_d_uart0_cyc_i),
400
      .wbs0_stb_i                       (wbs_d_uart0_stb_i),
401
      .wbs0_cti_i                       (wbs_d_uart0_cti_i),
402
      .wbs0_bte_i                       (wbs_d_uart0_bte_i),
403
      .wbs0_dat_o                       (wbs_d_uart0_dat_o),
404
      .wbs0_ack_o                       (wbs_d_uart0_ack_o),
405
      .wbs0_err_o                       (wbs_d_uart0_err_o),
406
      .wbs0_rty_o                       (wbs_d_uart0_rty_o),
407
 
408
      // Clock, reset inputs
409
      .wb_clk                   (wb_clk),
410
      .wb_rst                   (wb_rst));
411
 
412
   defparam arbiter_bytebus0.wb_addr_match_width = bbus_arb_wb_addr_match_width;
413
   defparam arbiter_bytebus0.wb_num_slaves = bbus_arb_wb_num_slaves;
414
 
415
   defparam arbiter_bytebus0.slave0_adr = bbus_arb_slave0_adr;
416
   defparam arbiter_bytebus0.slave1_adr = bbus_arb_slave1_adr;
417
 
418
`ifdef JTAG_DEBUG
419
   ////////////////////////////////////////////////////////////////////////
420
   //
421
   // JTAG TAP
422
   // 
423
   ////////////////////////////////////////////////////////////////////////
424
 
425
   //
426
   // Wires
427
   //
428
   wire                                   dbg_if_select;
429
   wire                                   dbg_if_tdo;
430
   wire                                   jtag_tap_tdo;
431
   wire                                   jtag_tap_shift_dr, jtag_tap_pause_dr,
432
                                          jtag_tap_upate_dr, jtag_tap_capture_dr;
433
   //
434
   // Instantiation
435
   //
436
 
437
   jtag_tap jtag_tap0
438 6 julius
     (
439 360 julius
      // Ports to pads
440
      .tdo_pad_o                        (tdo_pad_o),
441
      .tms_pad_i                        (tms_pad_i),
442
      .tck_pad_i                        (dbg_tck),
443
      .trst_pad_i                       (async_rst),
444
      .tdi_pad_i                        (tdi_pad_i),
445
 
446
      .tdo_padoe_o                      (tdo_padoe_o),
447
 
448
      .tdo_o                            (jtag_tap_tdo),
449 6 julius
 
450 360 julius
      .shift_dr_o                       (jtag_tap_shift_dr),
451
      .pause_dr_o                       (jtag_tap_pause_dr),
452
      .update_dr_o                      (jtag_tap_update_dr),
453
      .capture_dr_o                     (jtag_tap_capture_dr),
454
 
455
      .extest_select_o                  (),
456
      .sample_preload_select_o          (),
457
      .mbist_select_o                   (),
458
      .debug_select_o                   (dbg_if_select),
459 6 julius
 
460 360 julius
 
461
      .bs_chain_tdi_i                   (1'b0),
462
      .mbist_tdi_i                      (1'b0),
463
      .debug_tdi_i                      (dbg_if_tdo)
464
 
465 54 julius
      );
466 360 julius
 
467
   ////////////////////////////////////////////////////////////////////////
468
`endif //  `ifdef JTAG_DEBUG
469 6 julius
 
470 360 julius
   ////////////////////////////////////////////////////////////////////////
471
   //
472
   // OpenRISC processor
473
   // 
474
   ////////////////////////////////////////////////////////////////////////
475
 
476
   // 
477
   // Wires
478
   // 
479 6 julius
 
480 360 julius
   wire [19:0]                             or1200_pic_ints;
481 351 julius
 
482 360 julius
   wire [31:0]                             or1200_dbg_dat_i;
483
   wire [31:0]                             or1200_dbg_adr_i;
484
   wire                                   or1200_dbg_we_i;
485
   wire                                   or1200_dbg_stb_i;
486
   wire                                   or1200_dbg_ack_o;
487
   wire [31:0]                             or1200_dbg_dat_o;
488
 
489
   wire                                   or1200_dbg_stall_i;
490
   wire                                   or1200_dbg_ewt_i;
491
   wire [3:0]                              or1200_dbg_lss_o;
492
   wire [1:0]                              or1200_dbg_is_o;
493
   wire [10:0]                             or1200_dbg_wp_o;
494
   wire                                   or1200_dbg_bp_o;
495
   wire                                   or1200_dbg_rst;
496
 
497
   wire                                   or1200_clk, or1200_rst;
498
   wire                                   sig_tick;
499
 
500
   //
501
   // Assigns
502
   //
503
   assign or1200_clk = wb_clk;
504
   assign or1200_rst = wb_rst | or1200_dbg_rst;
505 351 julius
 
506 360 julius
   // 
507
   // Instantiation
508
   //    
509
   or1200_top or1200_top
510
       (
511
        // Instruction bus, clocks, reset
512
        .iwb_clk_i                      (wb_clk),
513
        .iwb_rst_i                      (wb_rst),
514
        .iwb_ack_i                      (wbm_i_or12_ack_i),
515
        .iwb_err_i                      (wbm_i_or12_err_i),
516
        .iwb_rty_i                      (wbm_i_or12_rty_i),
517
        .iwb_dat_i                      (wbm_i_or12_dat_i),
518
 
519
        .iwb_cyc_o                      (wbm_i_or12_cyc_o),
520
        .iwb_adr_o                      (wbm_i_or12_adr_o),
521
        .iwb_stb_o                      (wbm_i_or12_stb_o),
522
        .iwb_we_o                       (wbm_i_or12_we_o),
523
        .iwb_sel_o                      (wbm_i_or12_sel_o),
524
        .iwb_dat_o                      (wbm_i_or12_dat_o),
525
        .iwb_cti_o                      (wbm_i_or12_cti_o),
526
        .iwb_bte_o                      (wbm_i_or12_bte_o),
527
 
528
        // Data bus, clocks, reset            
529
        .dwb_clk_i                      (wb_clk),
530
        .dwb_rst_i                      (wb_rst),
531
        .dwb_ack_i                      (wbm_d_or12_ack_i),
532
        .dwb_err_i                      (wbm_d_or12_err_i),
533
        .dwb_rty_i                      (wbm_d_or12_rty_i),
534
        .dwb_dat_i                      (wbm_d_or12_dat_i),
535 6 julius
 
536 360 julius
        .dwb_cyc_o                      (wbm_d_or12_cyc_o),
537
        .dwb_adr_o                      (wbm_d_or12_adr_o),
538
        .dwb_stb_o                      (wbm_d_or12_stb_o),
539
        .dwb_we_o                       (wbm_d_or12_we_o),
540
        .dwb_sel_o                      (wbm_d_or12_sel_o),
541
        .dwb_dat_o                      (wbm_d_or12_dat_o),
542
        .dwb_cti_o                      (wbm_d_or12_cti_o),
543
        .dwb_bte_o                      (wbm_d_or12_bte_o),
544
 
545
        // Debug interface ports
546
        .dbg_stall_i                    (or1200_dbg_stall_i),
547
        //.dbg_ewt_i                    (or1200_dbg_ewt_i),
548
        .dbg_ewt_i                      (1'b0),
549
        .dbg_lss_o                      (or1200_dbg_lss_o),
550
        .dbg_is_o                       (or1200_dbg_is_o),
551
        .dbg_wp_o                       (or1200_dbg_wp_o),
552
        .dbg_bp_o                       (or1200_dbg_bp_o),
553 351 julius
 
554 360 julius
        .dbg_adr_i                      (or1200_dbg_adr_i),
555
        .dbg_we_i                       (or1200_dbg_we_i ),
556
        .dbg_stb_i                      (or1200_dbg_stb_i),
557
        .dbg_dat_i                      (or1200_dbg_dat_i),
558
        .dbg_dat_o                      (or1200_dbg_dat_o),
559
        .dbg_ack_o                      (or1200_dbg_ack_o),
560
 
561
        .pm_clksd_o                     (),
562
        .pm_dc_gate_o                   (),
563
        .pm_ic_gate_o                   (),
564
        .pm_dmmu_gate_o                 (),
565
        .pm_immu_gate_o                 (),
566
        .pm_tt_gate_o                   (),
567
        .pm_cpu_gate_o                  (),
568
        .pm_wakeup_o                    (),
569
        .pm_lvolt_o                     (),
570
 
571
        // Core clocks, resets
572
        .clk_i                          (or1200_clk),
573
        .rst_i                          (or1200_rst),
574
 
575
        .clmode_i                       (2'b00),
576
        // Interrupts      
577
        .pic_ints_i                     (or1200_pic_ints),
578
        .sig_tick(sig_tick),
579
        /*
580
         .mbist_so_o                    (),
581
         .mbist_si_i                    (0),
582
         .mbist_ctrl_i                  (0),
583
         */
584
 
585
        .pm_cpustall_i                  (1'b0)
586
 
587
        );
588 351 julius
 
589 360 julius
   ////////////////////////////////////////////////////////////////////////
590 6 julius
 
591
 
592 360 julius
`ifdef JTAG_DEBUG
593
   ////////////////////////////////////////////////////////////////////////
594
   //
595
   // OR1200 Debug Interface
596
   // 
597
   ////////////////////////////////////////////////////////////////////////
598
 
599
   dbg_if dbg_if0
600 6 julius
     (
601 360 julius
      // OR1200 interface
602
      .cpu0_clk_i                       (or1200_clk),
603
      .cpu0_rst_o                       (or1200_dbg_rst),
604
      .cpu0_addr_o                      (or1200_dbg_adr_i),
605
      .cpu0_data_o                      (or1200_dbg_dat_i),
606
      .cpu0_stb_o                       (or1200_dbg_stb_i),
607
      .cpu0_we_o                        (or1200_dbg_we_i),
608
      .cpu0_data_i                      (or1200_dbg_dat_o),
609
      .cpu0_ack_i                       (or1200_dbg_ack_o),
610 6 julius
 
611 44 julius
 
612 360 julius
      .cpu0_stall_o                     (or1200_dbg_stall_i),
613
      .cpu0_bp_i                        (or1200_dbg_bp_o),
614
 
615
      // TAP interface
616
      .tck_i                            (dbg_tck),
617
      .tdi_i                            (jtag_tap_tdo),
618
      .tdo_o                            (dbg_if_tdo),
619
      .rst_i                            (wb_rst),
620
      .shift_dr_i                       (jtag_tap_shift_dr),
621
      .pause_dr_i                       (jtag_tap_pause_dr),
622
      .update_dr_i                      (jtag_tap_update_dr),
623
      .debug_select_i                   (dbg_if_select),
624
 
625
      // Wishbone debug master
626
      .wb_clk_i                         (wb_clk),
627
      .wb_dat_i                         (wbm_d_dbg_dat_i),
628
      .wb_ack_i                         (wbm_d_dbg_ack_i),
629
      .wb_err_i                         (wbm_d_dbg_err_i),
630
      .wb_adr_o                         (wbm_d_dbg_adr_o),
631
      .wb_dat_o                         (wbm_d_dbg_dat_o),
632
      .wb_cyc_o                         (wbm_d_dbg_cyc_o),
633
      .wb_stb_o                         (wbm_d_dbg_stb_o),
634
      .wb_sel_o                         (wbm_d_dbg_sel_o),
635
      .wb_we_o                          (wbm_d_dbg_we_o ),
636
      .wb_cti_o                         (wbm_d_dbg_cti_o),
637
      .wb_cab_o                         (/*   UNUSED  */),
638
      .wb_bte_o                         (wbm_d_dbg_bte_o)
639 54 julius
      );
640 360 julius
 
641
   ////////////////////////////////////////////////////////////////////////   
642
`else // !`ifdef JTAG_DEBUG
643 44 julius
 
644 360 julius
   assign wbm_d_dbg_adr_o = 0;
645
   assign wbm_d_dbg_dat_o = 0;
646
   assign wbm_d_dbg_cyc_o = 0;
647
   assign wbm_d_dbg_stb_o = 0;
648
   assign wbm_d_dbg_sel_o = 0;
649
   assign wbm_d_dbg_we_o  = 0;
650
   assign wbm_d_dbg_cti_o = 0;
651
   assign wbm_d_dbg_bte_o = 0;
652
 
653
   assign or1200_dbg_adr_i = 0;
654
   assign or1200_dbg_dat_i = 0;
655
   assign or1200_dbg_stb_i = 0;
656
   assign or1200_dbg_we_i = 0;
657
   assign or1200_dbg_stall_i = 0;
658
 
659
   ////////////////////////////////////////////////////////////////////////   
660
`endif // !`ifdef JTAG_DEBUG
661
 
662
 
663
   ////////////////////////////////////////////////////////////////////////
664
   //
665
   // ROM
666
   // 
667
   ////////////////////////////////////////////////////////////////////////
668
 
669
   rom rom0
670 54 julius
     (
671 360 julius
      .wb_dat_o                         (wbs_i_rom0_dat_o),
672
      .wb_ack_o                         (wbs_i_rom0_ack_o),
673
      .wb_adr_i                         (wbs_i_rom0_adr_i[(wbs_i_rom0_addr_width+2)-1:2]),
674
      .wb_stb_i                         (wbs_i_rom0_stb_i),
675
      .wb_cyc_i                         (wbs_i_rom0_cyc_i),
676
      .wb_cti_i                         (wbs_i_rom0_cti_i),
677
      .wb_bte_i                         (wbs_i_rom0_bte_i),
678
      .wb_clk                           (wb_clk),
679
      .wb_rst                           (wb_rst));
680 44 julius
 
681 360 julius
   defparam rom0.addr_width = wbs_i_rom0_addr_width;
682
 
683
   assign wbs_i_rom0_err_o = 0;
684
   assign wbs_i_rom0_rty_o = 0;
685 6 julius
 
686 360 julius
   ////////////////////////////////////////////////////////////////////////
687
 
688
   ////////////////////////////////////////////////////////////////////////
689
   //
690
   // Generic main RAM
691
   // 
692
   ////////////////////////////////////////////////////////////////////////
693
 
694
   parameter wb_ram_dat_width = 32;
695
   parameter wb_ram_adr_width = 25;
696
   //parameter ram_wb_mem_size  = 2097152; // 8MB
697
   parameter wb_ram_mem_size  = 8388608; // 32MB -- for linux test
698
 
699 6 julius
 
700 360 julius
   // Arbiter logic for sharing the RAM between 2 masters
701
   // This should probably not be in the top-level module!
702
 
703
   // Bus to WB B3 RAM
704
   wire [wb_ram_adr_width-1:0]             wb_ram_adr_i;
705
   wire [1:0]                              wb_ram_bte_i;
706
   wire [2:0]                              wb_ram_cti_i;
707
   wire                                   wb_ram_cyc_i;
708
   wire [wb_ram_dat_width-1:0]             wb_ram_dat_i;
709
   wire [3:0]                              wb_ram_sel_i;
710
   wire                                   wb_ram_stb_i;
711
   wire                                   wb_ram_we_i;
712
   wire                                   wb_ram_ack_o;
713
   wire                                   wb_ram_err_o;
714
   wire                                   wb_ram_rty_o;
715
   wire [wb_ram_dat_width-1:0]             wb_ram_dat_o;
716
 
717
   reg [1:0]                               wb_ram_mast_select;
718
   reg [1:0]                               wb_ram_last_selected;
719
   wire                                   wb_ram_arb_for_dbus,
720
                                          wb_ram_arb_for_ibus;
721
 
722
   // Wires allowing selection of new input
723
   assign wb_ram_arb_for_dbus = (wb_ram_last_selected[1] | !wbs_i_mc0_cyc_i) &
724
                                !(|wb_ram_mast_select);
725
   assign wb_ram_arb_for_ibus = (wb_ram_last_selected[0] | !wbs_d_mc0_cyc_i) &
726
                                !(|wb_ram_mast_select);
727
 
728
   // Master select logic
729
   always @(posedge wb_rst or posedge wb_clk)
730
     if (wb_rst)
731
       wb_ram_mast_select <= 0;
732
     else if ((wb_ram_mast_select[0] & !wbs_d_mc0_cyc_i) |
733
              (wb_ram_mast_select[1] & !wbs_i_mc0_cyc_i))
734
       wb_ram_mast_select <= 0;
735
     else if (!(&wb_ram_mast_select) & wbs_d_mc0_cyc_i & wb_ram_arb_for_dbus)
736
       wb_ram_mast_select <= 2'b01;
737
     else if (!(&wb_ram_mast_select) & wbs_i_mc0_cyc_i & wb_ram_arb_for_ibus)
738
       wb_ram_mast_select <= 2'b10;
739
 
740
   always @(posedge wb_rst or posedge wb_clk)
741
     if (wb_rst)
742
       wb_ram_last_selected <= 0;
743
     else if (!(&wb_ram_mast_select) & wbs_d_mc0_cyc_i & wb_ram_arb_for_dbus)
744
       wb_ram_last_selected <= 2'b01;
745
     else if (!(&wb_ram_mast_select) & wbs_i_mc0_cyc_i & wb_ram_arb_for_ibus)
746
       wb_ram_last_selected <= 2'b10;
747
 
748
   // Mux input signals to RAM (default to wbs_d_mc0)
749
   assign wb_ram_adr_i = (wb_ram_mast_select[1]) ? wbs_i_mc0_adr_i :
750
                         (wb_ram_mast_select[0]) ? wbs_d_mc0_adr_i : 0;
751
   assign wb_ram_bte_i = (wb_ram_mast_select[1]) ? wbs_i_mc0_bte_i :
752
                         (wb_ram_mast_select[0]) ? wbs_d_mc0_bte_i : 0;
753
   assign wb_ram_cti_i = (wb_ram_mast_select[1]) ? wbs_i_mc0_cti_i :
754
                         (wb_ram_mast_select[0]) ? wbs_d_mc0_cti_i : 0;
755
   assign wb_ram_cyc_i = (wb_ram_mast_select[1]) ? wbs_i_mc0_cyc_i :
756
                         (wb_ram_mast_select[0]) ? wbs_d_mc0_cyc_i : 0;
757
   assign wb_ram_dat_i = (wb_ram_mast_select[1]) ? wbs_i_mc0_dat_i :
758
                         (wb_ram_mast_select[0]) ? wbs_d_mc0_dat_i : 0;
759
   assign wb_ram_sel_i = (wb_ram_mast_select[1]) ? wbs_i_mc0_sel_i :
760
                         (wb_ram_mast_select[0]) ? wbs_d_mc0_sel_i : 0;
761
   assign wb_ram_stb_i = (wb_ram_mast_select[1]) ? wbs_i_mc0_stb_i :
762
                         (wb_ram_mast_select[0]) ? wbs_d_mc0_stb_i : 0;
763
   assign wb_ram_we_i  = (wb_ram_mast_select[1]) ? wbs_i_mc0_we_i  :
764
                         (wb_ram_mast_select[0]) ? wbs_d_mc0_we_i : 0;
765
 
766
   // Output from RAM, gate the ACK, ERR, RTY signals appropriately
767
   assign wbs_d_mc0_dat_o = wb_ram_dat_o;
768
   assign wbs_d_mc0_ack_o = wb_ram_ack_o & wb_ram_mast_select[0];
769
   assign wbs_d_mc0_err_o = wb_ram_err_o & wb_ram_mast_select[0];
770
   assign wbs_d_mc0_rty_o = wb_ram_rty_o & wb_ram_mast_select[0];
771
 
772
   assign wbs_i_mc0_dat_o = wb_ram_dat_o;
773
   assign wbs_i_mc0_ack_o = wb_ram_ack_o & wb_ram_mast_select[1];
774
   assign wbs_i_mc0_err_o = wb_ram_err_o & wb_ram_mast_select[1];
775
   assign wbs_i_mc0_rty_o = wb_ram_rty_o & wb_ram_mast_select[1];
776
 
777
 
778
   // Wishbone B3 RAM
779
   wb_ram_b3
780
     #(
781
       .dw(wb_ram_dat_width),
782
       .aw(wb_ram_adr_width),
783
       .mem_size(wb_ram_mem_size)
784
       )
785
   wb_ram_b3_0
786 6 julius
     (
787 55 julius
      // Outputs
788 360 julius
      .wb_ack_o                         (wb_ram_ack_o),
789
      .wb_err_o                         (wb_ram_err_o),
790
      .wb_rty_o                         (wb_ram_rty_o),
791
      .wb_dat_o                         (wb_ram_dat_o),
792 55 julius
      // Inputs
793 360 julius
      .wb_adr_i                         (wb_ram_adr_i),
794
      .wb_bte_i                         (wb_ram_bte_i),
795
      .wb_cti_i                         (wb_ram_cti_i),
796
      .wb_cyc_i                         (wb_ram_cyc_i),
797
      .wb_dat_i                         (wb_ram_dat_i),
798
      .wb_sel_i                         (wb_ram_sel_i),
799
      .wb_stb_i                         (wb_ram_stb_i),
800
      .wb_we_i                          (wb_ram_we_i),
801
      .wb_clk_i                         (wb_clk),
802
      .wb_rst_i                         (wb_rst));
803 6 julius
 
804 360 julius
   ////////////////////////////////////////////////////////////////////////
805
 
806
`ifdef UART0
807
   ////////////////////////////////////////////////////////////////////////
808
   //
809
   // UART0
810
   // 
811
   ////////////////////////////////////////////////////////////////////////
812 55 julius
 
813 360 julius
   //
814
   // Wires
815
   //
816
   wire        uart0_irq;
817
 
818
   //
819
   // Assigns
820
   //
821
   assign wbs_d_uart0_err_o = 0;
822
   assign wbs_d_uart0_rty_o = 0;
823
 
824
   uart16550 uart16550_0
825
     (
826
      // Wishbone slave interface
827
      .wb_clk_i                         (wb_clk),
828
      .wb_rst_i                         (wb_rst),
829
      .wb_adr_i                         (wbs_d_uart0_adr_i[uart0_addr_width-1:0]),
830
      .wb_dat_i                         (wbs_d_uart0_dat_i),
831
      .wb_we_i                          (wbs_d_uart0_we_i),
832
      .wb_stb_i                         (wbs_d_uart0_stb_i),
833
      .wb_cyc_i                         (wbs_d_uart0_cyc_i),
834
      //.wb_sel_i                               (),
835
      .wb_dat_o                         (wbs_d_uart0_dat_o),
836
      .wb_ack_o                         (wbs_d_uart0_ack_o),
837
 
838
      .int_o                            (uart0_irq),
839
      .stx_pad_o                        (uart0_stx_pad_o),
840
      .rts_pad_o                        (),
841
      .dtr_pad_o                        (),
842
      //      .baud_o                           (),
843
      // Inputs
844
      .srx_pad_i                        (uart0_srx_pad_i),
845
      .cts_pad_i                        (1'b0),
846
      .dsr_pad_i                        (1'b0),
847
      .ri_pad_i                         (1'b0),
848
      .dcd_pad_i                        (1'b0));
849
 
850
   ////////////////////////////////////////////////////////////////////////          
851
`else // !`ifdef UART0
852
 
853
   //
854
   // Assigns
855
   //
856
   assign wbs_d_uart0_err_o = 0;
857
   assign wbs_d_uart0_rty_o = 0;
858
   assign wbs_d_uart0_ack_o = 0;
859
   assign wbs_d_uart0_dat_o = 0;
860
 
861
   ////////////////////////////////////////////////////////////////////////       
862
`endif // !`ifdef UART0
863
 
864
   ////////////////////////////////////////////////////////////////////////
865
   //
866
   // OR1200 Interrupt assignment
867
   // 
868
   ////////////////////////////////////////////////////////////////////////
869
 
870
   assign or1200_pic_ints[0] = 0; // Non-maskable inside OR1200
871
   assign or1200_pic_ints[1] = 0; // Non-maskable inside OR1200
872
`ifdef UART0
873
   assign or1200_pic_ints[2] = uart0_irq;
874
`else
875
   assign or1200_pic_ints[2] = 0;
876 55 julius
`endif
877 360 julius
   assign or1200_pic_ints[3] = 0;
878
   assign or1200_pic_ints[4] = 0;
879
   assign or1200_pic_ints[5] = 0;
880
`ifdef SPI0
881
   assign or1200_pic_ints[6] = spi0_irq;
882
`else
883
   assign or1200_pic_ints[6] = 0;
884
`endif
885
   assign or1200_pic_ints[7] = 0;
886
   assign or1200_pic_ints[8] = 0;
887
   assign or1200_pic_ints[9] = 0;
888
   assign or1200_pic_ints[10] = 0;
889
   assign or1200_pic_ints[11] = 0;
890
   assign or1200_pic_ints[12] = 0;
891
   assign or1200_pic_ints[13] = 0;
892
   assign or1200_pic_ints[14] = 0;
893
   assign or1200_pic_ints[15] = 0;
894
   assign or1200_pic_ints[16] = 0;
895
   assign or1200_pic_ints[17] = 0;
896
   assign or1200_pic_ints[18] = 0;
897
   assign or1200_pic_ints[19] = 0;
898 6 julius
 
899 360 julius
endmodule // top
900
 
901
// Local Variables:
902
// verilog-library-directories:("." "../arbiter" "../uart16550" "../or1200" "../dbg_if" "../jtag_tap" "../rom" "../simple_spi" )
903
// verilog-library-files:()
904
// verilog-library-extensions:(".v" ".h")
905
// End:
906
 

powered by: WebSVN 2.1.0

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