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

Subversion Repositories 8051

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

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

powered by: WebSVN 2.1.0

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