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

Subversion Repositories oms8051mini

[/] [oms8051mini/] [trunk/] [rtl/] [core/] [digital_core.v] - Blame information for rev 11

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

Line No. Rev Author Line
1 2 dinesha
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3 11 dinesha
////  OMS 8051 Digital core Module                                ////
4 2 dinesha
////                                                              ////
5
////  This file is part of the OMS 8051 cores project             ////
6
////  http://www.opencores.org/cores/oms8051mini/                 ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  OMS 8051 definitions.                                       ////
10
////                                                              ////
11
////  To Do:                                                      ////
12
////    nothing                                                   ////
13
////                                                              ////
14
////  Author(s):                                                  ////
15
////      - Dinesh Annayya, dinesha@opencores.org                 ////
16
////                                                              ////
17
////  Revision : Nov 26, 2016                                     //// 
18
////                                                              ////
19
//////////////////////////////////////////////////////////////////////
20 10 dinesha
//     v0.0 - Dinesh A, 26th Nov 2016
21 2 dinesha
//          1. MAC related logic are remved
22 10 dinesha
//     v0.1 - Dinesh A, 1st Dec 2016
23
//          1. RAM and ROM are internally connected to interconnect
24
//          2. Memory Map Change
25
//          3. Remove the External ROM Option & Enabled Internal ROM
26 11 dinesha
//     v0.2 - Dinesh A, 9st Dec 2016
27
//          1. Bus interface is changed from 32 bit to 8 bit
28 2 dinesha
//////////////////////////////////////////////////////////////////////
29
////                                                              ////
30
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
31
////                                                              ////
32
//// This source file may be used and distributed without         ////
33
//// restriction provided that this copyright statement is not    ////
34
//// removed from the file and that any derivative work contains  ////
35
//// the original copyright notice and the associated disclaimer. ////
36
////                                                              ////
37
//// This source file is free software; you can redistribute it   ////
38
//// and/or modify it under the terms of the GNU Lesser General   ////
39
//// Public License as published by the Free Software Foundation; ////
40
//// either version 2.1 of the License, or (at your option) any   ////
41
//// later version.                                               ////
42
////                                                              ////
43
//// This source is distributed in the hope that it will be       ////
44
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
45
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
46
//// PURPOSE.  See the GNU Lesser General Public License for more ////
47
//// details.                                                     ////
48
////                                                              ////
49
//// You should have received a copy of the GNU Lesser General    ////
50
//// Public License along with this source; if not, download it   ////
51
//// from http://www.opencores.org/lgpl.shtml                     ////
52
////                                                              ////
53
//////////////////////////////////////////////////////////////////////
54
 
55
`include "top_defines.v"
56
module digital_core  (
57
 
58
             reset_n                ,
59
             scan_mode              ,
60
             scan_enable             ,
61
             fastsim_mode           ,
62
             mastermode             ,
63
             xtal_clk               ,
64
             clkout                 ,
65
             reset_out_n            ,
66 10 dinesha
             ea_in                  ,
67 2 dinesha
 
68
        // Reg Bus Interface Signal
69
             ext_reg_cs             ,
70
             ext_reg_tid            ,
71
             ext_reg_wr             ,
72
             ext_reg_addr           ,
73
             ext_reg_wdata          ,
74
 
75
            // Outputs
76
             ext_reg_rdata          ,
77
             ext_reg_ack            ,
78
 
79
 
80
 
81
       // UART Line Interface
82
             si                     ,
83
             so                     ,
84
 
85
 
86
             spi_sck                ,
87
             spi_so                 ,
88
             spi_si                 ,
89 10 dinesha
             spi_cs_n
90 2 dinesha
 
91
 
92
 
93
 
94
 
95
        );
96
 
97
 
98
//----------------------------------------
99
// Global Clock Defination
100
//----------------------------------------
101
input            reset_n               ; // Active Low Reset           
102
input            scan_mode             ; // scan mode
103
input            scan_enable           ; // scan enable
104
input            fastsim_mode          ; // Fast Sim Mode
105
input            mastermode            ; // 1 : Risc master mode
106 10 dinesha
input            ea_in                  ; // input for external access (ea signal)
107
                                          // ea=0 program is in external rom
108
                                          // ea=1 program is in internal rom
109 2 dinesha
 
110
input            xtal_clk              ; // xtal clock 25Mhz
111
output           clkout                ; // clock output
112
output           reset_out_n           ; // clock output
113
 
114
//---------------------------------
115
// Reg Bus Interface Signal
116
//---------------------------------
117
input            ext_reg_cs            ;
118
input            ext_reg_wr            ;
119
input [3:0]      ext_reg_tid           ;
120
input [14:0]     ext_reg_addr          ;
121 11 dinesha
input [7:0]      ext_reg_wdata         ;
122 2 dinesha
 
123
// Outputs
124 11 dinesha
output [7:0]     ext_reg_rdata         ;
125 2 dinesha
output           ext_reg_ack           ;
126
 
127
 
128
 
129
//----------------------------------------
130
// UART Line Interface
131
//----------------------------------------
132
input            si                     ; // serial in
133
output           so                     ; // serial out
134
 
135
//----------------------------------------
136
// SPI Line Interface
137
//----------------------------------------
138
 
139
output           spi_sck                ; // clock
140
output           spi_so                 ; // data out
141
input            spi_si                 ; // data in
142
output  [3:0]    spi_cs_n               ; // chip select
143
 
144
 
145
//----------------------------------------
146
// 8051 core RAM related signals
147
//---------------------------------------
148 10 dinesha
wire [15:0]      wb_xram_adr            ; // data-ram address
149
wire             wb_xram_ack            ; // data-ram acknowlage
150
wire             wb_xram_err            ; // data-ram error
151
wire             wb_xram_wr             ; // data-ram error
152 11 dinesha
wire [7:0]       wb_xram_rdata          ; // ram data input
153
wire [7:0]       wb_xram_wdata          ; // ram data input
154 2 dinesha
 
155 10 dinesha
wire             wb_xram_stb            ; // data-ram strobe
156
wire             wb_xram_cyc            ; // data-ram cycle
157 2 dinesha
 
158
 
159
//---------------------------------------------
160
// 8051 Instruction ROM interface
161
//---------------------------------------------
162
wire    [15:0]   wbi_risc_adr;
163 11 dinesha
wire    [7:0]    wbi_risc_rdata;
164 2 dinesha
 
165
 
166
//-----------------------------
167
// wire Decleration
168
//-----------------------------
169
wire             gen_resetn             ;
170
 
171
 
172
//---------------------------------------------
173
// 8051 Instruction RAM interface
174
//---------------------------------------------
175
wire    [15:0]   wbd_risc_adr           ;
176
wire    [7:0]    wbd_risc_rdata         ;
177
wire    [7:0]    wbd_risc_wdata         ;
178
 
179
 
180
wire    [14:0]   reg_uart_addr          ;
181 11 dinesha
wire    [7:0]    reg_uart_wdata         ;
182
wire    [7:0]    reg_uart_rdata         ;
183 2 dinesha
wire             reg_uart_ack           ;
184
 
185
wire    [14:0]   reg_spi_addr           ;
186 11 dinesha
wire    [7:0]    reg_spi_wdata          ;
187
wire    [7:0]    reg_spi_rdata          ;
188 2 dinesha
wire             reg_spi_ack            ;
189
 
190
 
191
wire    [7:0]    p0              ;
192
wire    [7:0]    p1              ;
193
wire    [7:0]    p2              ;
194
wire    [7:0]    p3              ;
195
 
196
 
197 11 dinesha
wire [7:0] reg_rdata = (reg_uart_ack) ? reg_uart_rdata :
198 2 dinesha
                        (reg_spi_ack)  ? reg_spi_rdata : 'h0;
199
 
200
wire reg_ack = reg_uart_ack | reg_spi_ack;
201
 
202
 
203
assign reset_out_n = gen_resetn;
204
 
205
assign wb_xram_adr[15]    = 0;
206
 
207
//-------------------------------------------
208
// clock-gen  instantiation
209
//-------------------------------------------
210
clkgen u_clkgen (
211
               . reset_n                (reset_n               ),
212
               . fastsim_mode           (fastsim_mode          ),
213
               . mastermode             (mastermode            ),
214
               . xtal_clk               (xtal_clk              ),
215
               . clkout                 (clkout                ),
216
               . gen_resetn             (gen_resetn            ),
217
               . risc_reset             (risc_reset            ),
218
               . app_clk                (app_clk               ),
219
               . uart_ref_clk           (uart_clk_16x          )
220
 
221
              );
222
 
223
 
224
 
225 11 dinesha
wire [7:0] wb_master2_rdata;
226 2 dinesha
 
227 11 dinesha
assign     wbd_risc_rdata = wb_master2_rdata[7:0];
228 2 dinesha
 
229
//------------------------------
230
// 8051 Data Memory Map
231
// 0x0000 to 0x7FFFF  - Data Memory
232
// 0x8000 to 0x8FFF   - SPI 
233
// 0x9000 to 0x9FFF   - UART
234
//--------------------------------------------------------------
235
// Target ID Mapping
236 10 dinesha
// 4'b0010 -- UART
237
// 4'b0001 -- SPI core
238
// 4'b0000 -- External RAM
239 2 dinesha
//--------------------------------------------------------------
240
// 
241 10 dinesha
wire [3:0] wbd_tar_id     = (wbd_risc_adr[15]    == 1'b0 ) ? 4'b0000 :
242
                            (wbd_risc_adr[15:12] == 4'b1000 ) ? 4'b0001 :
243
                            (wbd_risc_adr[15:12] == 4'b1001 ) ? 4'b0010 : 4'b0000;
244 2 dinesha
 
245
wb_crossbar #(.WB_MASTER(3),
246 10 dinesha
              .WB_SLAVE(3),
247 11 dinesha
              .D_WD(8),
248
              .BE_WD(1),
249
              .ADR_WD(15),
250 2 dinesha
              .TAR_WD(4))
251
              u_wb_crossbar (
252
 
253
              .rst_n                    (gen_resetn           ),
254
              .clk                      (app_clk              ),
255
 
256
 
257
    // Master Interface Signal
258
              .wbd_taddr_master         ({4'b0000,
259
                                          wbd_tar_id,
260
                                          ext_reg_tid }),
261
 
262 11 dinesha
              .wbd_din_master           ({8'h0 ,
263 2 dinesha
                                          wbd_risc_wdata[7:0],
264
                                          ext_reg_wdata }
265
                                         ),
266
 
267
              .wbd_dout_master          ({wbi_risc_rdata,
268
                                          wb_master2_rdata,
269
                                          ext_reg_rdata}),
270
 
271 11 dinesha
              .wbd_adr_master           ({wbi_risc_adr[14:0],
272
                                          wbd_risc_adr[14:0],
273
                                          ext_reg_addr[14:0]}),
274 2 dinesha
 
275 11 dinesha
              .wbd_be_master            ({1'b1,1'b1,1'b1}),
276 2 dinesha
 
277
              .wbd_we_master            ({1'b0,wbd_risc_we,ext_reg_wr }   ),
278
 
279
              .wbd_ack_master           ({wbi_risc_ack,
280
                                          wbd_risc_ack,
281
                                          ext_reg_ack } ),
282
 
283 10 dinesha
              .wbd_stb_master           ({1'b0,
284 2 dinesha
                                          wbd_risc_stb,
285
                                          ext_reg_cs} ),
286
 
287 10 dinesha
              .wbd_cyc_master           ({1'b0,
288 2 dinesha
                                          wbd_risc_stb|wbd_risc_ack,
289
                                          ext_reg_cs|ext_reg_ack }),
290
 
291
              .wbd_err_master           (),
292
              .wbd_rty_master           (),
293
 
294
    // Slave Interface Signal
295
              .wbd_din_slave            ({reg_uart_wdata,
296
                                          reg_spi_wdata,
297 10 dinesha
                                          wb_xram_wdata
298 2 dinesha
                                          }),
299
 
300
              .wbd_dout_slave           ({reg_uart_rdata,
301
                                          reg_spi_rdata,
302 11 dinesha
                                          wb_xram_rdata
303 2 dinesha
                                         }),
304
 
305 11 dinesha
              .wbd_adr_slave            ({reg_uart_addr[14:0],
306
                                          reg_spi_addr[14:0],
307
                                          wb_xram_adr[14:0]}
308 2 dinesha
                                        ),
309
 
310 11 dinesha
              .wbd_be_slave             (),
311 2 dinesha
 
312
              .wbd_we_slave             ({reg_uart_wr,
313
                                          reg_spi_wr,
314 10 dinesha
                                          wb_xram_wr
315 2 dinesha
                                          }),
316
 
317
              .wbd_ack_slave            ({reg_uart_ack,
318
                                          reg_spi_ack,
319 10 dinesha
                                          wb_xram_ack
320 2 dinesha
                                         }),
321
              .wbd_stb_slave            ({reg_uart_cs,
322
                                          reg_spi_cs,
323 10 dinesha
                                          wb_xram_stb
324 2 dinesha
                                         }),
325
 
326
              .wbd_cyc_slave            (),
327
              .wbd_err_slave            (),
328
              .wbd_rty_slave            ()
329
         );
330
 
331
 
332
 
333
//-------------------------------------
334
// UART core instantiation
335
//-------------------------------------
336
 
337
uart_core  u_uart_core
338
 
339
     (
340
          . app_reset_n                 (gen_resetn            ),
341
          . app_clk                     (app_clk               ),
342
 
343
 
344
        // Reg Bus Interface Signal
345
          . reg_cs                      (reg_uart_cs           ),
346
          . reg_wr                      (reg_uart_wr           ),
347 11 dinesha
          . reg_addr                    (reg_uart_addr[3:0]    ),
348 2 dinesha
          . reg_wdata                   (reg_uart_wdata        ),
349 11 dinesha
          . reg_be                      (1'b1                  ),
350 2 dinesha
 
351
            // Outputs
352
          . reg_rdata                   (reg_uart_rdata        ),
353
          . reg_ack                     (reg_uart_ack          ),
354
 
355
 
356
 
357
       // Line Interface
358
          . si                          (si                    ),
359
          . so                          (so                    )
360
 
361
     );
362
 
363
 
364
//--------------------------------
365
// SPI core instantiation
366
//--------------------------------
367
 
368
 
369
spi_core u_spi_core (
370
 
371
          . clk                         (app_clk               ),
372
          . reset_n                     (gen_resetn            ),
373
 
374
        // Reg Bus Interface Signal
375
          . reg_cs                      (reg_spi_cs            ),
376
          . reg_wr                      (reg_spi_wr            ),
377 11 dinesha
          . reg_addr                    (reg_spi_addr[3:0]     ),
378 2 dinesha
          . reg_wdata                   (reg_spi_wdata         ),
379 11 dinesha
          . reg_be                      (1'b1                  ),
380 2 dinesha
 
381
            // Outputs
382
          . reg_rdata                   (reg_spi_rdata         ),
383
          . reg_ack                     (reg_spi_ack           ),
384
 
385
 
386
          . sck                         (spi_sck               ),
387
          . so                          (spi_so                ),
388
          . si                          (spi_si                ),
389
          . cs_n                        (spi_cs_n              )
390
 
391
           );
392
 
393
 
394
 
395
oc8051_top u_8051_core (
396
          . wb_rst_i                    (risc_reset            ),
397
          . wb_clk_i                    (app_clk               ),
398
 
399
//interface to data ram
400
          . wbd_dat_i                   (wbd_risc_rdata        ),
401
          . wbd_dat_o                   (wbd_risc_wdata        ),
402
          . wbd_adr_o                   (wbd_risc_adr          ),
403
          . wbd_we_o                    (wbd_risc_we           ),
404
          . wbd_ack_i                   (wbd_risc_ack          ),
405
          . wbd_stb_o                   (wbd_risc_stb          ),
406
          . wbd_cyc_o                   (wbd_risc_cyc          ),
407
          . wbd_err_i                   (wbd_risc_err          ),
408
 
409
// interrupt interface
410
          . int0_i                      (                      ),
411
          . int1_i                      (                      ),
412
 
413
 
414
// port interface
415
  `ifdef OC8051_PORTS
416
        `ifdef OC8051_PORT0
417
          .p0_i                         ( p0                    ),
418
          .p0_o                         ( p0                    ),
419
        `endif
420
 
421
        `ifdef OC8051_PORT1
422
           .p1_i                        ( p1                    ),
423
           .p1_o                        ( p1                    ),
424
        `endif
425
 
426
        `ifdef OC8051_PORT2
427
           .p2_i                        ( p2                    ),
428
           .p2_o                        ( p2                    ),
429
        `endif
430
 
431
        `ifdef OC8051_PORT3
432
           .p3_i                        ( p3                    ),
433
           .p3_o                        ( p3                    ),
434
        `endif
435
  `endif
436
 
437
// serial interface
438
        `ifdef OC8051_UART
439
           .rxd_i                       (                      ),
440
           .txd_o                       (                      ),
441
        `endif
442
 
443
// counter interface
444
        `ifdef OC8051_TC01
445
           .t0_i                        (                      ),
446
           .t1_i                        (                      ),
447
        `endif
448
 
449
        `ifdef OC8051_TC2
450
           .t2_i                        (                      ),
451
           .t2ex_i                      (                      ),
452
        `endif
453
 
454
// BIST
455
`ifdef OC8051_BIST
456
            .scanb_rst                  (                      ),
457
            .scanb_clk                  (                      ),
458
            .scanb_si                   (                      ),
459
            .scanb_so                   (                      ),
460
            .scanb_en                   (                      ),
461
`endif
462
// external access (active low)
463
            .ea_in                      (ea_in                 )
464
         );
465
 
466 10 dinesha
//
467
// external data ram
468
//
469
oc8051_xram oc8051_xram1 (
470
          .clk               (app_clk       ),
471
          .rst               (!reset_n      ),
472
          .wr                (wb_xram_wr    ),
473
          .addr              (wb_xram_adr   ),
474
          .data_in           (wb_xram_wdata ),
475
          .data_out          (wb_xram_rdata ),
476
          .ack               (wb_xram_ack   ),
477
          .stb               (wb_xram_stb   )
478
      );
479
 
480
 
481
defparam oc8051_xram1.DELAY = 2;
482 2 dinesha
endmodule

powered by: WebSVN 2.1.0

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