OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

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

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

powered by: WebSVN 2.1.0

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