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

Subversion Repositories 8051

[/] [8051/] [trunk/] [rtl/] [verilog/] [oc8051_sfr.v] - Blame information for rev 139

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

Line No. Rev Author Line
1 75 simont
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  8051 cores sfr top level module                             ////
4
////                                                              ////
5
////  This file is part of the 8051 cores project                 ////
6
////  http://www.opencores.org/cores/8051/                        ////
7
////                                                              ////
8
////  Description                                                 ////
9
////   special function registers for oc8051                      ////
10
////                                                              ////
11
////  To Do:                                                      ////
12
////    nothing                                                   ////
13
////                                                              ////
14
////  Author(s):                                                  ////
15
////      - Simon Teran, simont@opencores.org                     ////
16
////                                                              ////
17
//////////////////////////////////////////////////////////////////////
18
////                                                              ////
19
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
20
////                                                              ////
21
//// This source file may be used and distributed without         ////
22
//// restriction provided that this copyright statement is not    ////
23
//// removed from the file and that any derivative work contains  ////
24
//// the original copyright notice and the associated disclaimer. ////
25
////                                                              ////
26
//// This source file is free software; you can redistribute it   ////
27
//// and/or modify it under the terms of the GNU Lesser General   ////
28
//// Public License as published by the Free Software Foundation; ////
29
//// either version 2.1 of the License, or (at your option) any   ////
30
//// later version.                                               ////
31
////                                                              ////
32
//// This source is distributed in the hope that it will be       ////
33
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
34
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
35
//// PURPOSE.  See the GNU Lesser General Public License for more ////
36
//// details.                                                     ////
37
////                                                              ////
38
//// You should have received a copy of the GNU Lesser General    ////
39
//// Public License along with this source; if not, download it   ////
40
//// from http://www.opencores.org/lgpl.shtml                     ////
41
////                                                              ////
42
//////////////////////////////////////////////////////////////////////
43
//
44
// CVS Revision History
45
//
46
// $Log: not supported by cvs2svn $
47 139 simont
// Revision 1.12  2003/04/29 11:24:31  simont
48
// fix bug in case execution of two data dependent instructions.
49
//
50 134 simont
// Revision 1.11  2003/04/25 17:15:51  simont
51
// change branch instruction execution (reduse needed clock periods).
52
//
53 132 simont
// Revision 1.10  2003/04/10 12:43:19  simont
54
// defines for pherypherals added
55
//
56 120 simont
// Revision 1.9  2003/04/09 16:24:03  simont
57
// change wr_sft to 2 bit wire.
58
//
59 118 simont
// Revision 1.8  2003/04/09 15:49:42  simont
60
// Register oc8051_sfr dato output, add signal wait_data.
61
//
62 117 simont
// Revision 1.7  2003/04/07 14:58:02  simont
63
// change sfr's interface.
64
//
65 116 simont
// Revision 1.6  2003/04/07 13:29:16  simont
66
// change uart to meet timing.
67
//
68 115 simont
// Revision 1.5  2003/04/04 10:35:07  simont
69
// signal prsc_ow added.
70
//
71 113 simont
// Revision 1.4  2003/03/28 17:45:57  simont
72
// change module name.
73
//
74 90 simont
// Revision 1.3  2003/01/21 13:51:30  simont
75
// add include oc8051_defines.v
76
//
77 87 simont
// Revision 1.2  2003/01/13 14:14:41  simont
78
// replace some modules
79
//
80 82 simont
// Revision 1.1  2002/11/05 17:22:27  simont
81
// initial import
82 75 simont
//
83 82 simont
//
84 75 simont
 
85
// synopsys translate_off
86
`include "oc8051_timescale.v"
87
// synopsys translate_on
88
 
89 87 simont
`include "oc8051_defines.v"
90 75 simont
 
91 87 simont
 
92 120 simont
module oc8051_sfr (rst, clk,
93 117 simont
       adr0, adr1, dat0,
94 120 simont
       dat1, dat2, bit_in,
95 139 simont
       des_acc,
96 120 simont
       we, wr_bit,
97 117 simont
       bit_out,
98 120 simont
       wr_sfr, acc,
99
       ram_wr_sel, ram_rd_sel,
100
       sp, sp_w,
101
       bank_sel,
102 139 simont
       desAc, desOv,
103 120 simont
       srcAc, cy,
104
       psw_set, rmw,
105 132 simont
       comp_sel,
106
       comp_wait,
107 75 simont
 
108 120 simont
`ifdef OC8051_PORTS
109 75 simont
 
110 120 simont
  `ifdef OC8051_PORT0
111
       p0_out,
112
       p0_in,
113
  `endif
114 75 simont
 
115 120 simont
  `ifdef OC8051_PORT1
116
       p1_out,
117
       p1_in,
118
  `endif
119 75 simont
 
120 120 simont
  `ifdef OC8051_PORT2
121
       p2_out,
122
       p2_in,
123
  `endif
124 75 simont
 
125 120 simont
  `ifdef OC8051_PORT3
126
       p3_out,
127
       p3_in,
128
  `endif
129
 
130
`endif
131
 
132
 
133
  `ifdef OC8051_UART
134
       rxd, txd,
135
  `endif
136
 
137
       int_ack, intr,
138
       int0, int1,
139
       int_src,
140
       reti,
141
 
142
  `ifdef OC8051_TC01
143
       t0, t1,
144
  `endif
145
 
146
  `ifdef OC8051_TC2
147
       t2, t2ex,
148
  `endif
149
 
150
       dptr_hi, dptr_lo,
151
       wait_data);
152
 
153
 
154
input       rst,        // reset - pin
155
            clk,        // clock - pin
156
            we,         // write enable
157
            bit_in,
158
            desAc,
159
            desOv,
160
            rmw;
161
input       int_ack,
162
            int0,
163
            int1,
164
            reti,
165
            wr_bit;
166
input [1:0] psw_set,
167 132 simont
            wr_sfr,
168
            comp_sel;
169 120 simont
input [2:0] ram_rd_sel,
170
            ram_wr_sel;
171
input [7:0] adr0,        //address 0 input
172
            adr1,       //address 1 input
173 139 simont
            des_acc,
174 120 simont
            dat1,       //data 1 input (des1)
175
            dat2;       //data 2 input (des2)
176
 
177
output       bit_out,
178
             intr,
179
             srcAc,
180
             cy,
181 132 simont
             wait_data,
182
             comp_wait;
183 82 simont
output [1:0] bank_sel;
184 120 simont
output [7:0] dat0,       //data output
185
             int_src,
186
             dptr_hi,
187
             dptr_lo,
188
             acc;
189
output [7:0] sp,
190
             sp_w;
191 75 simont
 
192 120 simont
// ports
193
`ifdef OC8051_PORTS
194 82 simont
 
195 120 simont
`ifdef OC8051_PORT0
196
input  [7:0] p0_in;
197
output [7:0] p0_out;
198
wire   [7:0] p0_data;
199
`endif
200 75 simont
 
201 120 simont
`ifdef OC8051_PORT1
202
input  [7:0] p1_in;
203
output [7:0] p1_out;
204
wire   [7:0] p1_data;
205
`endif
206 116 simont
 
207 120 simont
`ifdef OC8051_PORT2
208
input  [7:0] p2_in;
209
output [7:0] p2_out;
210
wire   [7:0] p2_data;
211
`endif
212 116 simont
 
213 120 simont
`ifdef OC8051_PORT3
214
input  [7:0] p3_in;
215
output [7:0] p3_out;
216
wire   [7:0] p3_data;
217
`endif
218 75 simont
 
219 120 simont
`endif
220
 
221
 
222 116 simont
// serial interface
223 120 simont
`ifdef OC8051_UART
224
input        rxd;
225
output       txd;
226
`endif
227 116 simont
 
228 120 simont
// timer/counter 0,1
229
`ifdef OC8051_TC01
230
input        t0, t1;
231
`endif
232 82 simont
 
233 120 simont
// timer/counter 2
234
`ifdef OC8051_TC2
235
input        t2, t2ex;
236
`endif
237 117 simont
 
238 120 simont
reg        bit_out,
239
           wait_data;
240
reg [7:0]  dat0,
241
           adr0_r;
242
 
243
reg        wr_bit_r;
244
reg [2:0]  ram_wr_sel_r;
245
 
246
 
247
wire       p,
248
           uart_int,
249
           tf0,
250
           tf1,
251
           tr0,
252
           tr1,
253
           rclk,
254
           tclk,
255
           brate2,
256
           tc2_int;
257
 
258
 
259
wire [7:0] b_reg,
260
           psw,
261
 
262
`ifdef OC8051_TC2
263
  // t/c 2
264
           t2con,
265
           tl2,
266
           th2,
267
           rcap2l,
268
           rcap2h,
269
`endif
270
 
271
`ifdef OC8051_TC01
272
  // t/c 0,1
273
           tmod,
274
           tl0,
275
           th0,
276
           tl1,
277
           th1,
278
`endif
279
 
280
  // serial interface
281
`ifdef OC8051_UART
282
           scon,
283
           pcon,
284
           sbuf,
285
`endif
286
 
287
  //interrupt control
288
           ie,
289
           tcon,
290
           ip;
291
 
292
 
293
reg        pres_ow;
294
reg [3:0]  prescaler;
295
 
296
 
297 75 simont
assign cy = psw[7];
298
assign srcAc = psw [6];
299
 
300 82 simont
 
301
 
302 75 simont
//
303
// accumulator
304
// ACC
305 120 simont
oc8051_acc oc8051_acc1(.clk(clk),
306
                       .rst(rst),
307
                       .bit_in(bit_in),
308 139 simont
                       .data_in(des_acc),
309
                       .data2_in(dat2),
310
                       .wr(we),
311
                       .wr_bit(wr_bit_r),
312 120 simont
                       .wr_sfr(wr_sfr),
313 139 simont
                       .wr_addr(adr1),
314
                       .data_out(acc),
315 120 simont
                       .p(p));
316 75 simont
 
317
 
318
//
319
// b register
320
// B
321 139 simont
oc8051_b_register oc8051_b_register (.clk(clk),
322
                                     .rst(rst),
323 120 simont
                                     .bit_in(bit_in),
324 139 simont
                                     .data_in(des_acc),
325 120 simont
                                     .wr(we),
326
                                     .wr_bit(wr_bit_r),
327
                                     .wr_addr(adr1),
328
                                     .data_out(b_reg));
329 75 simont
 
330
//
331
//stack pointer
332
// SP
333 120 simont
oc8051_sp oc8051_sp1(.clk(clk),
334
                     .rst(rst),
335
                     .ram_rd_sel(ram_rd_sel),
336
                     .ram_wr_sel(ram_wr_sel),
337
                     .wr_addr(adr1),
338
                     .wr(we),
339
                     .wr_bit(wr_bit_r),
340
                     .data_in(dat1),
341
                     .sp_out(sp),
342
                     .sp_w(sp_w));
343 75 simont
 
344
//
345
//data pointer
346
// DPTR, DPH, DPL
347 120 simont
oc8051_dptr oc8051_dptr1(.clk(clk),
348
                         .rst(rst),
349
                         .addr(adr1),
350 139 simont
                         .data_in(des_acc),
351 120 simont
                         .data2_in(dat2),
352
                         .wr(we),
353
                         .wr_bit(wr_bit_r),
354
                         .data_hi(dptr_hi),
355
                         .data_lo(dptr_lo),
356
                         .wr_sfr(wr_sfr));
357 75 simont
 
358 82 simont
 
359 75 simont
//
360
//program status word
361
// PSW
362 120 simont
oc8051_psw oc8051_psw1 (.clk(clk),
363
                        .rst(rst),
364
                        .wr_addr(adr1),
365
                        .data_in(dat1),
366
                        .wr(we),
367
                        .wr_bit(wr_bit_r),
368
                        .data_out(psw),
369
                        .p(p),
370
                        .cy_in(bit_in),
371
                        .ac_in(desAc),
372
                        .ov_in(desOv),
373
                        .set(psw_set),
374
                        .bank_sel(bank_sel));
375 75 simont
 
376
//
377
// ports
378
// P0, P1, P2, P3
379 120 simont
`ifdef OC8051_PORTS
380
  oc8051_ports oc8051_ports1(.clk(clk),
381
                           .rst(rst),
382
                           .bit_in(bit_in),
383
                           .data_in(dat1),
384
                           .wr(we),
385
                           .wr_bit(wr_bit_r),
386
                           .wr_addr(adr1),
387 75 simont
 
388 120 simont
                `ifdef OC8051_PORT0
389
                           .p0_out(p0_out),
390
                           .p0_in(p0_in),
391
                           .p0_data(p0_data),
392
                `endif
393
 
394
                `ifdef OC8051_PORT1
395
                           .p1_out(p1_out),
396
                           .p1_in(p1_in),
397
                           .p1_data(p1_data),
398
                `endif
399
 
400
                `ifdef OC8051_PORT2
401
                           .p2_out(p2_out),
402
                           .p2_in(p2_in),
403
                           .p2_data(p2_data),
404
                `endif
405
 
406
                `ifdef OC8051_PORT3
407
                           .p3_out(p3_out),
408
                           .p3_in(p3_in),
409
                           .p3_data(p3_data),
410
                `endif
411
 
412
                           .rmw(rmw));
413
`endif
414
 
415 75 simont
//
416
// serial interface
417
// SCON, SBUF
418 120 simont
`ifdef OC8051_UART
419
  oc8051_uart oc8051_uatr1 (.clk(clk),
420
                            .rst(rst),
421
                            .bit_in(bit_in),
422
                            .data_in(dat1),
423
                            .wr(we),
424
                            .wr_bit(wr_bit_r),
425
                            .wr_addr(adr1),
426
                            .rxd(rxd),
427
                            .txd(txd),
428
                // interrupt
429
                            .intr(uart_int),
430
                // baud rate sources
431
                            .brate2(brate2),
432
                            .t1_ow(tf1),
433
                            .pres_ow(pres_ow),
434
                            .rclk(rclk),
435
                            .tclk(tclk),
436
                //registers
437
                            .scon(scon),
438
                            .pcon(pcon),
439
                            .sbuf(sbuf));
440
`else
441
  assign uart_int = 1'b0;
442
`endif
443 75 simont
 
444
//
445
// interrupt control
446
// IP, IE, TCON
447 120 simont
oc8051_int oc8051_int1 (.clk(clk),
448
                        .rst(rst),
449
                        .wr_addr(adr1),
450
                        .bit_in(bit_in),
451
                        .ack(int_ack),
452
                        .data_in(dat1),
453
                        .wr(we),
454
                        .wr_bit(wr_bit_r),
455
                        .tf0(tf0),
456
                        .tf1(tf1),
457
                        .t2_int(tc2_int),
458
                        .tr0(tr0),
459
                        .tr1(tr1),
460
                        .ie0(int0),
461
                        .ie1(int1),
462
                        .uart_int(uart_int),
463
                        .reti(reti),
464
                        .intr(intr),
465
                        .int_vec(int_src),
466
                        .ie(ie),
467
                        .tcon(tcon),
468
                        .ip(ip));
469 75 simont
 
470 82 simont
 
471 75 simont
//
472
// timer/counter control
473
// TH0, TH1, TL0, TH1, TMOD
474 120 simont
`ifdef OC8051_TC01
475
  oc8051_tc oc8051_tc1(.clk(clk),
476
                       .rst(rst),
477
                       .wr_addr(adr1),
478
                       .data_in(dat1),
479
                       .wr(we),
480
                       .wr_bit(wr_bit_r),
481
                       .ie0(int0),
482
                       .ie1(int1),
483
                       .tr0(tr0),
484
                       .tr1(tr1),
485
                       .t0(t0),
486
                       .t1(t1),
487
                       .tf0(tf0),
488
                       .tf1(tf1),
489
                       .pres_ow(pres_ow),
490
                       .tmod(tmod),
491
                       .tl0(tl0),
492
                       .th0(th0),
493
                       .tl1(tl1),
494
                       .th1(th1));
495
`else
496
  assign tf0 = 1'b0;
497
  assign tf1 = 1'b0;
498
`endif
499 75 simont
 
500 82 simont
//
501
// timer/counter 2
502 116 simont
// TH2, TL2, RCAPL2L, RCAPL2H, T2CON
503 120 simont
`ifdef OC8051_TC2
504
  oc8051_tc2 oc8051_tc21(.clk(clk),
505
                         .rst(rst),
506
                         .wr_addr(adr1),
507
                         .data_in(dat1),
508
                         .wr(we),
509
                         .wr_bit(wr_bit_r),
510
                         .bit_in(bit_in),
511
                         .t2(t2),
512
                         .t2ex(t2ex),
513
                         .rclk(rclk),
514
                         .tclk(tclk),
515
                         .brate2(brate2),
516
                         .tc2_int(tc2_int),
517
                         .pres_ow(pres_ow),
518
                         .t2con(t2con),
519
                         .tl2(tl2),
520
                         .th2(th2),
521
                         .rcap2l(rcap2l),
522
                         .rcap2h(rcap2h));
523
`else
524
  assign tc2_int = 1'b0;
525
  assign rclk    = 1'b0;
526
  assign tclk    = 1'b0;
527
  assign brate2  = 1'b0;
528
`endif
529 75 simont
 
530 82 simont
 
531
 
532 75 simont
always @(posedge clk or posedge rst)
533
  if (rst) begin
534
    adr0_r <= #1 8'h00;
535
    ram_wr_sel_r <= #1 3'b000;
536 82 simont
    wr_bit_r <= #1 1'b0;
537 117 simont
//    wait_data <= #1 1'b0;
538 75 simont
  end else begin
539
    adr0_r <= #1 adr0;
540
    ram_wr_sel_r <= #1 ram_wr_sel;
541 82 simont
    wr_bit_r <= #1 wr_bit;
542 75 simont
  end
543
 
544 132 simont
assign comp_wait = !(
545
                    ((comp_sel==`OC8051_CSS_AZ) &
546
                       ((wr_sfr==`OC8051_WRS_ACC1) |
547
                        (wr_sfr==`OC8051_WRS_ACC2) |
548
                        ((adr1==`OC8051_SFR_ACC) & we & !wr_bit_r) |
549
                        ((adr1[7:3]==`OC8051_SFR_B_ACC) & we & wr_bit_r))) |
550
                    ((comp_sel==`OC8051_CSS_CY) &
551
                       ((|psw_set) |
552
                        ((adr1==`OC8051_SFR_PSW) & we & !wr_bit_r) |
553
                        ((adr1[7:3]==`OC8051_SFR_B_PSW) & we & wr_bit_r))) |
554
                    ((comp_sel==`OC8051_CSS_BIT) &
555
                       ((adr1[7:3]==adr0[7:3]) & (~&adr1[2:0]) &  we & !wr_bit_r) |
556
                       ((adr1==adr0) & adr1[7] & we & !wr_bit_r)));
557 75 simont
 
558 132 simont
 
559
 
560 75 simont
//
561 117 simont
//set output in case of address (byte)
562
always @(posedge clk or posedge rst)
563
begin
564
  if (rst) begin
565
    dat0 <= #1 8'h00;
566
    wait_data <= #1 1'b0;
567
  end else if ((wr_sfr==`OC8051_WRS_DPTR) & (adr0==`OC8051_SFR_DPTR_LO)) begin                          //write and read same address
568
    dat0 <= #1 dat1;
569
    wait_data <= #1 1'b0;
570
  end else if (
571 120 simont
      (((wr_sfr==`OC8051_WRS_ACC1) & (adr0==`OC8051_SFR_ACC)) |         //write to acc
572 117 simont
      ((wr_sfr==`OC8051_WRS_DPTR) & (adr0==`OC8051_SFR_DPTR_LO)) |      //write to dpl
573 134 simont
      (adr1[7] & (adr1==adr0) & we & !wr_bit_r) |                       //write and read same address
574
      (adr1[7] & (adr1[7:3]==adr0[7:3]) & (~&adr0[2:0]) &  we & wr_bit_r) //write bit addressable to read address
575
      ) & !wait_data) begin
576 117 simont
    wait_data <= #1 1'b1;
577
 
578 132 simont
  end else if ((
579
      ((|psw_set) & (adr0==`OC8051_SFR_PSW)) |
580
      ((wr_sfr==`OC8051_WRS_ACC2) & (adr0==`OC8051_SFR_ACC)) |  //write to acc
581 118 simont
      ((wr_sfr==`OC8051_WRS_DPTR) & (adr0==`OC8051_SFR_DPTR_HI))        //write to dph
582 120 simont
      ) & !wait_data) begin
583 117 simont
    wait_data <= #1 1'b1;
584
 
585
  end else begin
586
    case (adr0)
587
      `OC8051_SFR_ACC:          dat0 <= #1 acc;
588
      `OC8051_SFR_PSW:          dat0 <= #1 psw;
589 120 simont
 
590
`ifdef OC8051_PORTS
591
  `ifdef OC8051_PORT0
592 117 simont
      `OC8051_SFR_P0:           dat0 <= #1 p0_data;
593 120 simont
  `endif
594
 
595
  `ifdef OC8051_PORT1
596 117 simont
      `OC8051_SFR_P1:           dat0 <= #1 p1_data;
597 120 simont
  `endif
598
 
599
  `ifdef OC8051_PORT2
600 117 simont
      `OC8051_SFR_P2:           dat0 <= #1 p2_data;
601 120 simont
  `endif
602
 
603
  `ifdef OC8051_PORT3
604 117 simont
      `OC8051_SFR_P3:           dat0 <= #1 p3_data;
605 120 simont
  `endif
606
`endif
607
 
608 117 simont
      `OC8051_SFR_SP:           dat0 <= #1 sp;
609
      `OC8051_SFR_B:            dat0 <= #1 b_reg;
610
      `OC8051_SFR_DPTR_HI:      dat0 <= #1 dptr_hi;
611
      `OC8051_SFR_DPTR_LO:      dat0 <= #1 dptr_lo;
612 120 simont
 
613
`ifdef OC8051_UART
614 117 simont
      `OC8051_SFR_SCON:         dat0 <= #1 scon;
615
      `OC8051_SFR_SBUF:         dat0 <= #1 sbuf;
616
      `OC8051_SFR_PCON:         dat0 <= #1 pcon;
617 120 simont
`endif
618
 
619
`ifdef OC8051_TC01
620 117 simont
      `OC8051_SFR_TH0:          dat0 <= #1 th0;
621
      `OC8051_SFR_TH1:          dat0 <= #1 th1;
622
      `OC8051_SFR_TL0:          dat0 <= #1 tl0;
623
      `OC8051_SFR_TL1:          dat0 <= #1 tl1;
624
      `OC8051_SFR_TMOD:         dat0 <= #1 tmod;
625 120 simont
`endif
626
 
627 117 simont
      `OC8051_SFR_IP:           dat0 <= #1 ip;
628
      `OC8051_SFR_IE:           dat0 <= #1 ie;
629
      `OC8051_SFR_TCON:         dat0 <= #1 tcon;
630 120 simont
 
631
`ifdef OC8051_TC2
632 117 simont
      `OC8051_SFR_RCAP2H:       dat0 <= #1 rcap2h;
633
      `OC8051_SFR_RCAP2L:       dat0 <= #1 rcap2l;
634
      `OC8051_SFR_TH2:          dat0 <= #1 th2;
635
      `OC8051_SFR_TL2:          dat0 <= #1 tl2;
636
      `OC8051_SFR_T2CON:        dat0 <= #1 t2con;
637 120 simont
`endif
638
 
639 117 simont
      default:                  dat0 <= #1 8'h00;
640
    endcase
641
    wait_data <= #1 1'b0;
642
  end
643
end
644
 
645
 
646
//
647
//set output in case of address (bit)
648
always @(posedge clk or posedge rst)
649
begin
650
  if (rst)
651
    bit_out <= #1 1'h0;
652
  else if (
653
          ((adr1[7:3]==adr0[7:3]) & (~&adr1[2:0]) &  we & !wr_bit_r) |
654 118 simont
          ((wr_sfr==`OC8051_WRS_ACC1) & (adr0[7:3]==`OC8051_SFR_B_ACC))         //write to acc
655 120 simont
          )
656 117 simont
 
657
    bit_out <= #1 dat1[adr0[2:0]];
658
  else if ((adr1==adr0) & we & wr_bit_r)
659
    bit_out <= #1 bit_in;
660
  else
661
    case (adr0[7:3])
662
      `OC8051_SFR_B_ACC:   bit_out <= #1 acc[adr0[2:0]];
663
      `OC8051_SFR_B_PSW:   bit_out <= #1 psw[adr0[2:0]];
664 120 simont
 
665
`ifdef OC8051_PORTS
666
  `ifdef OC8051_PORT0
667 117 simont
      `OC8051_SFR_B_P0:    bit_out <= #1 p0_data[adr0[2:0]];
668 120 simont
  `endif
669
 
670
  `ifdef OC8051_PORT1
671 117 simont
      `OC8051_SFR_B_P1:    bit_out <= #1 p1_data[adr0[2:0]];
672 120 simont
  `endif
673
 
674
  `ifdef OC8051_PORT2
675 117 simont
      `OC8051_SFR_B_P2:    bit_out <= #1 p2_data[adr0[2:0]];
676 120 simont
  `endif
677
 
678
  `ifdef OC8051_PORT3
679 117 simont
      `OC8051_SFR_B_P3:    bit_out <= #1 p3_data[adr0[2:0]];
680 120 simont
  `endif
681
`endif
682
 
683 117 simont
      `OC8051_SFR_B_B:     bit_out <= #1 b_reg[adr0[2:0]];
684
      `OC8051_SFR_B_IP:    bit_out <= #1 ip[adr0[2:0]];
685
      `OC8051_SFR_B_IE:    bit_out <= #1 ie[adr0[2:0]];
686
      `OC8051_SFR_B_TCON:  bit_out <= #1 tcon[adr0[2:0]];
687 120 simont
 
688
`ifdef OC8051_UART
689 117 simont
      `OC8051_SFR_B_SCON:  bit_out <= #1 scon[adr0[2:0]];
690 120 simont
`endif
691
 
692
`ifdef OC8051_TC2
693 117 simont
      `OC8051_SFR_B_T2CON: bit_out <= #1 t2con[adr0[2:0]];
694 120 simont
`endif
695
 
696 117 simont
      default:             bit_out <= #1 1'b0;
697
    endcase
698
end
699
 
700 120 simont
always @(posedge clk or posedge rst)
701
begin
702
  if (rst) begin
703
    prescaler <= #1 4'h0;
704
    pres_ow <= #1 1'b0;
705
  end else if (prescaler==4'b1011) begin
706
    prescaler <= #1 4'h0;
707
    pres_ow <= #1 1'b1;
708
  end else begin
709
    prescaler <= #1 prescaler + 4'h1;
710
    pres_ow <= #1 1'b0;
711
  end
712
end
713 117 simont
 
714 75 simont
endmodule

powered by: WebSVN 2.1.0

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