OpenCores
URL https://opencores.org/ocsvn/an-fpga-implementation-of-low-latency-noc-based-mpsoc/an-fpga-implementation-of-low-latency-noc-based-mpsoc/trunk

Subversion Repositories an-fpga-implementation-of-low-latency-noc-based-mpsoc

[/] [an-fpga-implementation-of-low-latency-noc-based-mpsoc/] [trunk/] [mpsoc/] [src_processor/] [aeMB/] [sw/] [aemb/] [stack.hh] - Blame information for rev 48

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 17 alirezamon
/* $Id: stack.hh,v 1.8 2008-04-28 20:29:15 sybreon Exp $
2
**
3
** AEMB2 HI-PERFORMANCE CPU
4
** Copyright (C) 2004-2007 Shawn Tan Ser Ngiap 
5
**
6
** This file is part of AEMB.
7
**
8
** AEMB is free software: you can redistribute it and/or modify it
9
** under the terms of the GNU General Public License as published by
10
** the Free Software Foundation, either version 3 of the License, or
11
** (at your option) any later version.
12
**
13
** AEMB is distributed in the hope that it will be useful, but WITHOUT
14
** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15
** or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
16
** License for more details.
17
**
18
** You should have received a copy of the GNU General Public License
19
** along with AEMB.  If not, see .
20
*/
21
 
22
/**
23
   Basic stack related functions
24
   @file stack.hh
25
 */
26
 
27
#ifndef _AEMB_STACK_HH
28
#define _AEMB_STACK_HH
29
 
30
#ifdef __cplusplus
31
extern "C" {
32
#endif
33
 
34
  /**
35
  Reads the size of the memory space allocated for the stack in bytes.
36
  @return size of stack
37
  */
38
 
39 48 alirezamon
  static inline int aembGetStackSize()
40 17 alirezamon
  {
41
    int tmp;
42
    asm ("la %0, r0, _STACK_SIZE":"=r"(tmp));
43
    return tmp;
44
  }
45
 
46
  /**
47
  Reads the end of the memory space allocated for the stack. This is
48
  where the stack ends.
49
  @return end of stack
50
  */
51
 
52 48 alirezamon
  static inline int aembGetStackEnd()
53 17 alirezamon
  {
54
    int tmp;
55
    asm ("la %0, r0, _stack_end":"=r"(tmp));
56
    return tmp;
57
  }
58
 
59
  /**
60
  Reads the top of the memory space allocated for the stack. This is
61
  where the stack starts.
62
  @return top of stack
63
  */
64
 
65 48 alirezamon
  static inline int aembGetStackTop()
66 17 alirezamon
  {
67
    int tmp;
68
    asm ("la %0, r0, _stack":"=r"(tmp));
69
    return tmp;
70
  }
71
 
72
  /**
73
  Reads register R1 which is the designated stack pointer.
74
  @return stack pointer
75
  */
76
 
77 48 alirezamon
  static inline int aembGetStack()
78 17 alirezamon
  {
79
    int tmp;
80
    asm ("addk %0, r0, r1":"=r"(tmp));
81
    return tmp;
82
  }
83
 
84
  /**
85
  Sets register R1 to the new stack pointer.
86
  @param stk new stack pointer
87
  @return new stack pointer
88
  */
89
 
90 48 alirezamon
  static inline int aembSetStack(int stk)
91 17 alirezamon
  {
92
    asm ("addk r1, r0, %0"::"r"(stk));
93
    return stk;
94
  }
95
 
96
  /**
97
     Duplicates the stack
98
     @param newp new stack pointer
99
     @param oldp old stack pointer
100
     @param endp end of the stack
101
  */
102
 
103 48 alirezamon
  static inline void aembDupStack(unsigned int *newp, unsigned int *oldp, unsigned int *endp)
104 17 alirezamon
  {
105
    while (oldp < endp)
106
      {
107
        // copy the stack content
108
        *newp = *oldp;
109
        // this increments 1 word (not 1 byte)
110
        newp++;
111
        oldp++;
112
      }
113
  }
114
 
115
#ifdef __cplusplus
116
}
117
#endif
118
 
119
#endif
120
 
121
/*
122
  $Log: not supported by cvs2svn $
123
  Revision 1.7  2008/04/27 16:33:42  sybreon
124
  License change to GPL3.
125
 
126
  Revision 1.6  2008/04/27 16:04:42  sybreon
127
  Minor cosmetic changes.
128
 
129
  Revision 1.5  2008/04/26 19:31:35  sybreon
130
  Made headers C compatible.
131
 
132
  Revision 1.4  2008/04/26 18:04:31  sybreon
133
  Updated software to freeze T0 and run T1.
134
 
135
  Revision 1.3  2008/04/23 14:19:39  sybreon
136
  Fixed minor bugs.
137
  Initial use of hardware mutex.
138
 
139
  Revision 1.2  2008/04/20 16:35:53  sybreon
140
  Added C/C++ compatible #ifdef statements
141
 
142
  Revision 1.1  2008/04/09 19:48:37  sybreon
143
  Added new C++ files
144
 
145
*/

powered by: WebSVN 2.1.0

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