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

Subversion Repositories oms8051mini

[/] [oms8051mini/] [trunk/] [rtl/] [8051/] [oc8051_sp.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 stack pointer                                          ////
4
////                                                              ////
5
////  This file is part of the 8051 cores project                 ////
6
////  http://www.opencores.org/cores/oms8051mini/                 ////
7
////                                                              ////
8
////  Description                                                 ////
9
////   8051 special function register: stack pointer.             ////
10
////                                                              ////
11
////  To Do:                                                      ////
12
////   nothing                                                    ////
13
////                                                              ////
14
////  Author(s):                                                  ////
15
////      - Simon Teran, simont@opencores.org                     ////
16
////      - Dinesh Annayya, dinesha@opencores.org                 ////
17
////                                                              ////
18
//////////////////////////////////////////////////////////////////////
19 25 dinesha
////   v0.0 - Dinesh A, 5th Jan 2017
20
////        1. Active edge of reset changed from High to Low
21
//////////////////////////////////////////////////////////////////////
22 2 dinesha
////                                                              ////
23
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
24
////                                                              ////
25
//// This source file may be used and distributed without         ////
26
//// restriction provided that this copyright statement is not    ////
27
//// removed from the file and that any derivative work contains  ////
28
//// the original copyright notice and the associated disclaimer. ////
29
////                                                              ////
30
//// This source file is free software; you can redistribute it   ////
31
//// and/or modify it under the terms of the GNU Lesser General   ////
32
//// Public License as published by the Free Software Foundation; ////
33
//// either version 2.1 of the License, or (at your option) any   ////
34
//// later version.                                               ////
35
////                                                              ////
36
//// This source is distributed in the hope that it will be       ////
37
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
38
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
39
//// PURPOSE.  See the GNU Lesser General Public License for more ////
40
//// details.                                                     ////
41
////                                                              ////
42
//// You should have received a copy of the GNU Lesser General    ////
43
//// Public License along with this source; if not, download it   ////
44
//// from http://www.opencores.org/lgpl.shtml                     ////
45
////                                                              ////
46
//////////////////////////////////////////////////////////////////////
47
//
48
// CVS Revision History
49
//
50
// $Log: not supported by cvs2svn $
51
// Revision 1.5  2003/01/13 14:14:41  simont
52
// replace some modules
53
//
54
// Revision 1.4  2002/11/05 17:23:54  simont
55
// add module oc8051_sfr, 256 bytes internal ram
56
//
57
// Revision 1.3  2002/09/30 17:33:59  simont
58
// prepared header
59
//
60
//
61
 
62
`include "top_defines.v"
63
 
64
 
65
 
66 25 dinesha
module oc8051_sp (clk, resetn, ram_rd_sel, ram_wr_sel, wr_addr, wr, wr_bit, data_in, sp_out, sp_w);
67 2 dinesha
 
68
 
69 25 dinesha
input clk, resetn, wr, wr_bit;
70 2 dinesha
input [2:0] ram_rd_sel, ram_wr_sel;
71
input [7:0] data_in, wr_addr;
72
output [7:0] sp_out, sp_w;
73
 
74
reg [7:0] sp_out, sp_w;
75
reg pop;
76
wire write;
77
wire [7:0] sp_t;
78
 
79
reg [7:0] sp;
80
 
81
 
82
assign write = ((wr_addr==`OC8051_SFR_SP) & (wr) & !(wr_bit));
83
 
84
assign sp_t= write ? data_in : sp;
85
 
86
 
87 25 dinesha
always @(posedge clk or negedge resetn)
88 2 dinesha
begin
89 25 dinesha
  if (resetn == 1'b0)
90 2 dinesha
    sp <= #1 `OC8051_RST_SP;
91
  else if (write)
92
    sp <= #1 data_in;
93
  else
94
    sp <= #1 sp_out;
95
end
96
 
97
 
98
always @(sp or ram_wr_sel)
99
begin
100
//
101
// push
102
  if (ram_wr_sel==`OC8051_RWS_SP) sp_w = sp + 8'h01;
103
  else sp_w = sp;
104
 
105
end
106
 
107
 
108
always @(sp_t or ram_wr_sel or pop or write)
109
begin
110
//
111
// push
112
  if (write) sp_out = sp_t;
113
  else if (ram_wr_sel==`OC8051_RWS_SP) sp_out = sp_t + 8'h01;
114
  else sp_out = sp_t - {7'b0, pop};
115
 
116
end
117
 
118
 
119 25 dinesha
always @(posedge clk or negedge resetn)
120 2 dinesha
begin
121 25 dinesha
  if (resetn == 1'b0)
122 2 dinesha
    pop <= #1 1'b0;
123
  else if (ram_rd_sel==`OC8051_RRS_SP) pop <= #1 1'b1;
124
  else pop <= #1 1'b0;
125
end
126
 
127
endmodule

powered by: WebSVN 2.1.0

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