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

Subversion Repositories oms8051mini

[/] [oms8051mini/] [trunk/] [rtl/] [8051/] [oc8051_top.v] - Blame information for rev 25

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

Line No. Rev Author Line
1 2 dinesha
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  8051 cores top level module                                 ////
4
////                                                              ////
5
////  This file is part of the 8051 cores project                 ////
6
////  http://www.opencores.org/cores/oms8051mini/                 ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  8051 definitions.                                           ////
10
////                                                              ////
11
////  To Do:                                                      ////
12
////    nothing                                                   ////
13
////                                                              ////
14
////  Author(s):                                                  ////
15
////      - Simon Teran, simont@opencores.org                     ////
16
////      - Dinesh Annayya, dinesha@opencores.org                 ////
17 11 dinesha
//////////////////////////////////////////////////////////////////////
18 18 dinesha
////   v0.0 - Dinesh A, 8th Dec 2016
19
////        1. External ROM Interface Removed
20 25 dinesha
////   v0.1 - Dinesh A, 5th Jan 2017
21
////        1. Active edge of reset changed from High to Low
22 2 dinesha
////                                                              ////
23
//////////////////////////////////////////////////////////////////////
24
////                                                              ////
25
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
26
////                                                              ////
27
//// This source file may be used and distributed without         ////
28
//// restriction provided that this copyright statement is not    ////
29
//// removed from the file and that any derivative work contains  ////
30
//// the original copyright notice and the associated disclaimer. ////
31
////                                                              ////
32
//// This source file is free software; you can redistribute it   ////
33
//// and/or modify it under the terms of the GNU Lesser General   ////
34
//// Public License as published by the Free Software Foundation; ////
35
//// either version 2.1 of the License, or (at your option) any   ////
36
//// later version.                                               ////
37
////                                                              ////
38
//// This source is distributed in the hope that it will be       ////
39
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
40
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
41
//// PURPOSE.  See the GNU Lesser General Public License for more ////
42
//// details.                                                     ////
43
////                                                              ////
44
//// You should have received a copy of the GNU Lesser General    ////
45
//// Public License along with this source; if not, download it   ////
46
//// from http://www.opencores.org/lgpl.shtml                     ////
47
////                                                              ////
48
//////////////////////////////////////////////////////////////////////
49
//
50
// CVS Revision History
51
//
52
// $Log: not supported by cvs2svn $
53
// Revision 1.32  2003/06/20 13:36:37  simont
54
// ram modules added.
55
//
56
// Revision 1.31  2003/06/17 14:17:22  simont
57
// BIST signals added.
58
//
59
// Revision 1.30  2003/06/03 16:51:24  simont
60
// include "8051_defines" added.
61
//
62
// Revision 1.29  2003/05/07 12:36:03  simont
63
// chsnge comp.des to des1
64
//
65
// Revision 1.28  2003/05/06 09:41:35  simont
66
// remove define OC8051_AS2_PCL, chane signal src_sel2 to 2 bit wide.
67
//
68
// Revision 1.27  2003/05/05 15:46:37  simont
69
// add aditional alu destination to solve critical path.
70
//
71
// Revision 1.26  2003/04/29 11:24:31  simont
72
// fix bug in case execution of two data dependent instructions.
73
//
74
// Revision 1.25  2003/04/25 17:15:51  simont
75
// change branch instruction execution (reduse needed clock periods).
76
//
77
// Revision 1.24  2003/04/11 10:05:59  simont
78
// deifne OC8051_ROM added
79
//
80
// Revision 1.23  2003/04/10 12:43:19  simont
81
// defines for pherypherals added
82
//
83
// Revision 1.22  2003/04/09 16:24:04  simont
84
// change wr_sft to 2 bit wire.
85
//
86
// Revision 1.21  2003/04/09 15:49:42  simont
87
// Register oc8051_sfr dato output, add signal wait_data.
88
//
89
// Revision 1.20  2003/04/03 19:13:28  simont
90
// Include instruction cache.
91
//
92
// Revision 1.19  2003/04/02 15:08:30  simont
93
// raname signals.
94
//
95
// Revision 1.18  2003/01/13 14:14:41  simont
96
// replace some modules
97
//
98
// Revision 1.17  2002/11/05 17:23:54  simont
99
// add module oc8051_sfr, 256 bytes internal ram
100
//
101
// Revision 1.16  2002/10/28 14:55:00  simont
102
// fix bug in interface to external data ram
103
//
104
// Revision 1.15  2002/10/23 16:53:39  simont
105
// fix bugs in instruction interface
106
//
107
// Revision 1.14  2002/10/17 18:50:00  simont
108
// cahnge interface to instruction rom
109
//
110
// Revision 1.13  2002/09/30 17:33:59  simont
111
// prepared header
112
//
113
//
114
 
115
 
116
`include "top_defines.v"
117
 
118 25 dinesha
module oc8051_top (resetn, wb_clk_i,
119 2 dinesha
 
120
//interface to data ram
121
                wbd_dat_i,
122
                wbd_dat_o,
123
                wbd_adr_o,
124
                wbd_we_o,
125
                wbd_ack_i,
126
                wbd_stb_o,
127
                wbd_cyc_o,
128
                wbd_err_i,
129
 
130
// interrupt interface
131
                int0_i,
132
                int1_i,
133
 
134
 
135
// port interface
136
  `ifdef OC8051_PORTS
137
        `ifdef OC8051_PORT0
138
                p0_i,
139
                p0_o,
140
        `endif
141
 
142
        `ifdef OC8051_PORT1
143
                p1_i,
144
                p1_o,
145
        `endif
146
 
147
        `ifdef OC8051_PORT2
148
                p2_i,
149
                p2_o,
150
        `endif
151
 
152
        `ifdef OC8051_PORT3
153
                p3_i,
154
                p3_o,
155
        `endif
156
  `endif
157
 
158
// serial interface
159
        `ifdef OC8051_UART
160
                rxd_i, txd_o,
161
        `endif
162
 
163
// counter interface
164
        `ifdef OC8051_TC01
165
                t0_i, t1_i,
166
        `endif
167
 
168
        `ifdef OC8051_TC2
169
                t2_i, t2ex_i,
170
        `endif
171
 
172
// BIST
173
`ifdef OC8051_BIST
174
         scanb_rst,
175
         scanb_clk,
176
         scanb_si,
177
         scanb_so,
178
         scanb_en,
179
`endif
180
// external access (active low)
181
                ea_in
182
                );
183
 
184
 
185
 
186 25 dinesha
input         resetn,         // reset input
187 2 dinesha
              wb_clk_i,         // clock input
188
              int0_i,           // interrupt 0
189
              int1_i,           // interrupt 1
190
              ea_in,            // external access
191
              wbd_ack_i,        // data acknowalge
192 11 dinesha
              wbd_err_i;        // data error
193 2 dinesha
 
194
input [7:0]   wbd_dat_i;        // ram data input
195
 
196
output        wbd_we_o,         // data write enable
197
              wbd_stb_o,        // data strobe
198 11 dinesha
              wbd_cyc_o;        // data cycle
199 2 dinesha
 
200
output [7:0]  wbd_dat_o;        // data output
201
 
202 11 dinesha
output [15:0] wbd_adr_o;        // data address
203 2 dinesha
 
204
`ifdef OC8051_PORTS
205
 
206
`ifdef OC8051_PORT0
207
input  [7:0]  p0_i;             // port 0 input
208
output [7:0]  p0_o;             // port 0 output
209
`endif
210
 
211
`ifdef OC8051_PORT1
212
input  [7:0]  p1_i;             // port 1 input
213
output [7:0]  p1_o;             // port 1 output
214
`endif
215
 
216
`ifdef OC8051_PORT2
217
input  [7:0]  p2_i;             // port 2 input
218
output [7:0]  p2_o;             // port 2 output
219
`endif
220
 
221
`ifdef OC8051_PORT3
222
input  [7:0]  p3_i;             // port 3 input
223
output [7:0]  p3_o;             // port 3 output
224
`endif
225
 
226
`endif
227
 
228
 
229
 
230
 
231
 
232
 
233
`ifdef OC8051_UART
234
input         rxd_i;            // receive
235
output        txd_o;            // transnmit
236
`endif
237
 
238
`ifdef OC8051_TC01
239
input         t0_i,             // counter 0 input
240
              t1_i;             // counter 1 input
241
`endif
242
 
243
`ifdef OC8051_TC2
244
input         t2_i,             // counter 2 input
245
              t2ex_i;           //
246
`endif
247
 
248
`ifdef OC8051_BIST
249
input   scanb_rst;
250
input   scanb_clk;
251
input   scanb_si;
252
output  scanb_so;
253
input   scanb_en;
254
wire    scanb_soi;
255
`endif
256
 
257
wire [7:0]  dptr_hi,
258
            dptr_lo,
259
            ri,
260
            data_out,
261
            op1,
262
            op2,
263
            op3,
264
            acc,
265
            p0_out,
266
            p1_out,
267
            p2_out,
268
            p3_out,
269
            sp,
270
            sp_w;
271
 
272
wire [31:0] idat_onchip;
273
 
274
wire [15:0] pc;
275
 
276
assign wbd_cyc_o = wbd_stb_o;
277
 
278
wire        src_sel3;
279
wire [1:0]  wr_sfr,
280
            src_sel2;
281
wire [2:0]  ram_rd_sel, // ram read
282
            ram_wr_sel, // ram write
283
            src_sel1;
284
 
285
wire [7:0]  ram_data,
286
            ram_out,    //data from ram
287
            sfr_out,
288
            wr_dat,
289
            wr_addr,    //ram write addres
290
            rd_addr;    //data ram read addres
291
wire        sfr_bit;
292
 
293
wire [1:0]  cy_sel,     //carry select; from decoder to cy_selct1
294
            bank_sel;
295
wire        rom_addr_sel,       //rom addres select; alu or pc
296
            rmw,
297
            ea_int;
298
 
299
wire        reti,
300
            intr,
301
            int_ack,
302
            istb;
303
wire [7:0]  int_src;
304
 
305
wire        mem_wait;
306
wire [2:0]  mem_act;
307
wire [3:0]  alu_op;     //alu operation (from decoder)
308
wire [1:0]  psw_set;    //write to psw or not; from decoder to psw (through register)
309
 
310
wire [7:0]  src1,       //alu sources 1
311
            src2,       //alu sources 2
312
            src3,       //alu sources 3
313
            des_acc,
314
            des1,       //alu destination 1
315
            des2;       //alu destinations 2
316
wire        desCy,      //carry out
317
            desAc,
318
            desOv,      //overflow
319
            alu_cy,
320
            wr,         //write to data ram
321
            wr_o;
322
 
323
wire        rd,         //read program rom
324
            pc_wr;
325
wire [2:0]  pc_wr_sel;  //program counter write select (from decoder to pc)
326
 
327
wire [7:0]  op1_n, //from memory_interface to decoder
328
            op2_n,
329
            op3_n;
330
 
331
wire [1:0]  comp_sel;   //select source1 and source2 to compare
332
wire        eq,         //result (from comp1 to decoder)
333
            srcAc,
334
            cy,
335
            rd_ind,
336
            wr_ind,
337
            comp_wait;
338
wire [2:0]  op1_cur;
339
 
340
wire        bit_addr,   //bit addresable instruction
341
            bit_data,   //bit data from ram to ram_select
342
            bit_out,    //bit data from ram_select to alu and cy_select
343
            bit_addr_o,
344
            wait_data;
345
 
346
//
347
// cpu to cache/wb_interface
348
wire [15:0] iadr_o;
349
 
350
 
351
//
352
// decoder
353 20 dinesha
oc8051_decoder u_decoder(
354 2 dinesha
          .clk                (wb_clk_i           ),
355 25 dinesha
          .resetn                (resetn           ),
356 2 dinesha
          .op_in              (op1_n              ),
357
          .op1_c              (op1_cur            ),
358
          .ram_rd_sel_o       (ram_rd_sel         ),
359
          .ram_wr_sel_o       (ram_wr_sel         ),
360
          .bit_addr           (bit_addr           ),
361
 
362
          .src_sel1           (src_sel1           ),
363
          .src_sel2           (src_sel2           ),
364
          .src_sel3           (src_sel3           ),
365
 
366
          .alu_op_o           (alu_op             ),
367
          .psw_set            (psw_set            ),
368
          .cy_sel             (cy_sel             ),
369
          .wr_o               (wr                 ),
370
          .pc_wr              (pc_wr              ),
371
          .pc_sel             (pc_wr_sel          ),
372
          .comp_sel           (comp_sel           ),
373
          .eq                 (eq                 ),
374
          .wr_sfr_o           (wr_sfr             ),
375
          .rd                 (rd                 ),
376
          .rmw                (rmw                ),
377
          .istb               (istb               ),
378
          .mem_act            (mem_act            ),
379
          .mem_wait           (mem_wait           ),
380
          .wait_data          (wait_data          )
381
     );
382
 
383
 
384
wire [7:0] sub_result;
385
//
386
//alu
387 20 dinesha
oc8051_alu u_alu(
388 25 dinesha
          .resetn                (resetn           ),
389 2 dinesha
          .clk                (wb_clk_i           ),
390
          .op_code            (alu_op             ),
391
          .src1               (src1               ),
392
          .src2               (src2               ),
393
          .src3               (src3               ),
394
          .srcCy              (alu_cy             ),
395
          .srcAc              (srcAc              ),
396
          .des_acc            (des_acc            ),
397
          .sub_result         (sub_result         ),
398
          .des1               (des1               ),
399
          .des2               (des2               ),
400
          .desCy              (desCy              ),
401
          .desAc              (desAc              ),
402
          .desOv              (desOv              ),
403
          .bit_in(bit_out)
404
       );
405
 
406
//
407
//data ram
408 20 dinesha
oc8051_ram_top u_ram_top(
409 2 dinesha
          .clk                (wb_clk_i           ),
410 25 dinesha
          .resetn                (resetn           ),
411 2 dinesha
          .rd_addr            (rd_addr            ),
412
          .rd_data            (ram_data           ),
413
          .wr_addr            (wr_addr            ),
414
          .bit_addr           (bit_addr_o         ),
415
          .wr_data            (wr_dat             ),
416
          .wr                 (wr_o &&
417
                               (!wr_addr[7] || wr_ind)),
418
          .bit_data_in        (desCy              ),
419
          .bit_data_out       (bit_data           )
420
`ifdef OC8051_BIST
421
         ,
422
          .scanb_rst          (scanb_rst          ),
423
          .scanb_clk          (scanb_clk          ),
424
          .scanb_si           (scanb_soi          ),
425
          .scanb_so           (scanb_so           ),
426
          .scanb_en           (scanb_en           )
427
`endif
428
                               );
429
 
430
//
431
 
432 20 dinesha
oc8051_alu_src_sel u_alu_src_sel(
433 2 dinesha
          .clk                (wb_clk_i           ),
434 25 dinesha
          .resetn                (resetn           ),
435 2 dinesha
          .rd                 (rd                 ),
436
 
437
          .sel1               (src_sel1           ),
438
          .sel2               (src_sel2           ),
439
          .sel3               (src_sel3           ),
440
 
441
          .acc                (acc                ),
442
          .ram                (ram_out            ),
443
          .pc                 (pc                 ),
444
          .dptr               ({dptr_hi, dptr_lo} ),
445
          .op1                (op1_n              ),
446
          .op2                (op2_n              ),
447
          .op3                (op3_n              ),
448
 
449
          .src1               (src1               ),
450
          .src2               (src2               ),
451
          .src3               (src3               )
452
      );
453
 
454
 
455
//
456
//
457 20 dinesha
oc8051_comp u_comp(
458 2 dinesha
          .sel                (comp_sel           ),
459
          .eq                 (eq                 ),
460
          .b_in               (bit_out            ),
461
          .cy                 (cy                 ),
462
          .acc                (acc                ),
463
          .des                (sub_result         )
464
    );
465
 
466
 
467
//
468
//program rom
469
`ifdef OC8051_ROM
470 20 dinesha
  oc8051_rom u_rom(
471 25 dinesha
          .resetn                (resetn           ),
472 2 dinesha
          .clk                (wb_clk_i           ),
473
          .ea_int             (ea_int             ),
474
          .addr               (iadr_o             ),
475
          .data_o             (idat_onchip        )
476
     );
477
`else
478
  assign ea_int = 1'b0;
479
  assign idat_onchip = 32'h0;
480
 
481
  `ifdef OC8051_SIMULATION
482
 
483
    initial
484
    begin
485
      $display("\t * ");
486
      $display("\t * Internal rom disabled!!!");
487
      $display("\t * ");
488
    end
489
 
490
  `endif
491
 
492
`endif
493
 
494
//
495
//
496 20 dinesha
oc8051_cy_select u_cy_select(
497 2 dinesha
          .cy_sel             (cy_sel             ),
498
          .cy_in              (cy                 ),
499
          .data_in            (bit_out            ),
500
          .data_out           (alu_cy             )
501
    );
502
//
503
//
504 20 dinesha
oc8051_indi_addr u_indi_addr (
505 2 dinesha
          .clk                (wb_clk_i           ),
506 25 dinesha
          .resetn                (resetn           ),
507 2 dinesha
          .wr_addr            (wr_addr            ),
508
          .data_in            (wr_dat             ),
509
          .wr                 (wr_o               ),
510
          .wr_bit             (bit_addr_o         ),
511
          .ri_out             (ri                 ),
512
          .sel                (op1_cur[0]         ),
513
          .bank               (bank_sel           )
514
 );
515
 
516
 
517
 
518
//
519
//
520 20 dinesha
oc8051_memory_interface u_memory_interface(
521 2 dinesha
          .clk                (wb_clk_i           ),
522 25 dinesha
          .resetn                (resetn           ),
523 2 dinesha
// internal ram
524
          .wr_i               (wr                 ),
525
          .wr_o               (wr_o               ),
526
          .wr_bit_i           (bit_addr           ),
527
          .wr_bit_o           (bit_addr_o         ),
528
          .wr_dat             (wr_dat             ),
529
          .des_acc            (des_acc            ),
530
          .des1               (des1               ),
531
          .des2               (des2               ),
532
          .rd_addr            (rd_addr            ),
533
          .wr_addr            (wr_addr            ),
534
          .wr_ind             (wr_ind             ),
535
          .bit_in             (bit_data           ),
536
          .in_ram             (ram_data           ),
537
          .sfr                (sfr_out            ),
538
          .sfr_bit            (sfr_bit            ),
539
          .bit_out            (bit_out            ),
540
          .iram_out           (ram_out            ),
541
 
542
// external instrauction rom
543
          .iadr_o             (iadr_o             ),
544
 
545
// internal instruction rom
546
          .idat_onchip        (idat_onchip        ),
547
 
548
// data memory
549
          .dadr_o             (wbd_adr_o          ),
550
          .ddat_o             (wbd_dat_o          ),
551
          .dwe_o              (wbd_we_o           ),
552
          .dstb_o             (wbd_stb_o          ),
553
          .ddat_i             (wbd_dat_i          ),
554
          .dack_i             (wbd_ack_i          ),
555
 
556
// from decoder
557
          .rd_sel             (ram_rd_sel         ),
558
          .wr_sel             (ram_wr_sel         ),
559
          .rn                 ({bank_sel, op1_cur}),
560
          .rd_ind             (rd_ind             ),
561
          .rd                 (rd                 ),
562
          .mem_act            (mem_act            ),
563
          .mem_wait           (mem_wait           ),
564
 
565
// external access
566
          .ea                 (ea_in              ),
567
          .ea_int             (ea_int             ),
568
 
569
// instructions outputs to cpu
570
          .op1_out            (op1_n              ),
571
          .op2_out            (op2_n              ),
572
          .op3_out            (op3_n              ),
573
 
574
// interrupt interface
575
          .intr               (intr               ),
576
                       .int_v(int_src),
577
          .int_ack            (int_ack            ),
578
          .istb               (istb               ),
579
          .reti               (reti               ),
580
 
581
//pc
582
          .pc_wr_sel          (pc_wr_sel          ),
583
          .pc_wr              (pc_wr & comp_wait  ),
584
          .pc                 (pc                 ),
585
 
586
// sfr's
587
          .sp_w               (sp_w               ),
588
          .dptr               ({dptr_hi, dptr_lo} ),
589
          .ri                 (ri                 ),
590
          .acc                (acc                ),
591
          .sp                 (sp                 )
592
       );
593
 
594
 
595
//
596
//
597
 
598 20 dinesha
oc8051_sfr u_sfr(
599 25 dinesha
          .resetn                (resetn           ),
600 2 dinesha
          .clk                (wb_clk_i           ),
601
          .adr0               (rd_addr[7:0]       ),
602
          .adr1               (wr_addr[7:0]       ),
603
          .dat0               (sfr_out            ),
604
          .dat1               (wr_dat             ),
605
          .dat2               (des2               ),
606
          .des_acc            (des_acc            ),
607
          .we                 (wr_o && !wr_ind    ),
608
          .bit_in             (desCy              ),
609
          .bit_out            (sfr_bit            ),
610
          .wr_bit             (bit_addr_o         ),
611
          .ram_rd_sel         (ram_rd_sel         ),
612
          .ram_wr_sel         (ram_wr_sel         ),
613
          .wr_sfr             (wr_sfr             ),
614
          .comp_sel           (comp_sel           ),
615
          .comp_wait          (comp_wait          ),
616
// acc
617
          .acc                (acc                ),
618
// sp
619
          .sp                 (sp                 ),
620
          .sp_w               (sp_w               ),
621
// psw
622
          .bank_sel           (bank_sel           ),
623
          .desAc              (desAc              ),
624
          .desOv              (desOv              ),
625
          .psw_set            (psw_set            ),
626
          .srcAc              (srcAc              ),
627
          .cy                 (cy                 ),
628
// ports
629
          .rmw                (rmw                ),
630
 
631
  `ifdef OC8051_PORTS
632
        `ifdef OC8051_PORT0
633
          .p0_out             (p0_o               ),
634
          .p0_in              (p0_i               ),
635
        `endif
636
 
637
        `ifdef OC8051_PORT1
638
          .p1_out             (p1_o               ),
639
          .p1_in              (p1_i               ),
640
        `endif
641
 
642
        `ifdef OC8051_PORT2
643
          .p2_out             (p2_o               ),
644
          .p2_in              (p2_i               ),
645
        `endif
646
 
647
        `ifdef OC8051_PORT3
648
          .p3_out             (p3_o               ),
649
          .p3_in              (p3_i               ),
650
        `endif
651
  `endif
652
 
653
// uart
654
        `ifdef OC8051_UART
655
          .rxd                (rxd_i              ),
656
          .txd                (txd_o              ),
657
        `endif
658
 
659
// int
660
          .int_ack            (int_ack            ),
661
          .intr               (intr               ),
662
          .int0               (int0_i             ),
663
          .int1               (int1_i             ),
664
          .reti               (reti               ),
665
          .int_src            (int_src            ),
666
 
667
// t/c 0,1
668
        `ifdef OC8051_TC01
669
          .t0                 (t0_i               ),
670
          .t1                 (t1_i               ),
671
        `endif
672
 
673
// t/c 2
674
        `ifdef OC8051_TC2
675
          .t2                 (t2_i               ),
676
          .t2ex               (t2ex_i             ),
677
        `endif
678
 
679
// dptr
680
          .dptr_hi            (dptr_hi            ),
681
          .dptr_lo            (dptr_lo            ),
682
          .wait_data          (wait_data          )
683
       );
684
 
685
 
686
  `ifdef OC8051_BIST
687
       assign scanb_soi=scanb_si;
688
  `endif
689
 
690
 
691
 
692
  `ifdef OC8051_SIMULATION
693
 
694
    initial
695
    begin
696
      #1
697
      $display("\t * ");
698
      $display("\t * External rom interface: Pipelined interface");
699
      $display("\t * ");
700
    end
701
 
702
  `endif
703
 
704
 
705
 
706
 
707
 
708
// synopsys translate_off
709
// Debug Purpose only
710
// Stack Pointer Push & Pop analysis
711
reg [7:0]   StackMem[$];
712
reg  [7:0]  stack_pop;
713
reg  [7:0]  pushpop_cnt;
714
 
715
// Assumption, Both Write and Read access will not be
716
// possbile in single clock cycle
717 25 dinesha
always @(posedge wb_clk_i or negedge resetn)
718 2 dinesha
begin
719 25 dinesha
   if(resetn == 1'b0) begin
720 2 dinesha
      pushpop_cnt = 0;
721
   end
722
   else begin
723
      if(ram_wr_sel==`OC8051_RWS_SP) begin
724
            StackMem.push_back(wr_dat);
725
            pushpop_cnt = pushpop_cnt + 1;
726
      end
727
      if(ram_rd_sel==`OC8051_RRS_SP) begin
728
            stack_pop = StackMem.pop_back();
729
            pushpop_cnt = pushpop_cnt - 1;
730
            #2  // Add 1ns Delay to take care of Ram Dealy
731
            if(stack_pop != ram_data) begin
732
              $display("ERROR: Invalid Stack Pointer Pop Detected, Exp: %x,Rxd:%x",stack_pop,ram_data);
733
              $stop;
734
            end
735
      end
736
   end
737
end
738
 
739
// synopsys translate_on
740
 
741
endmodule

powered by: WebSVN 2.1.0

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