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

Subversion Repositories scarm

[/] [scarm/] [trunk/] [src/] [scRegisterFile.h] - Blame information for rev 6

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

Line No. Rev Author Line
1 5 zhong
///////////////////////////////////////////////////////////////////////////////
2
// This program is free software; you can redistribute it and/or
3
// modify it under the terms of the GNU General Public License
4
// as published by the Free Software Foundation; either version 2
5
// of the License, or (at your option) any later version.
6
//
7
// This program is distributed in the hope that it will be useful,
8
// but WITHOUT ANY WARRANTY; without even the implied warranty of
9
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
// GNU General Public License for more details.
11
//
12
// You should have received a copy of the GNU General Public License
13
// along with this program; if not, write to the Free Software
14
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
15
//////////////////////////////////////////////////////////////////////
16
 
17
///////////////////////////////////////////////////////////////////              
18
//          
19
//  Original Author: Allen Tao Zhong,
20
//  University of Electronic Science and Technology in China
21
//  email: zhong@opencores.org
22
//  info   This is a SystemC ARM model 
23
//   
24
//
25
///////////////////////////////////////////////////////////////////////////////
26
// scRegisterFile.h: interface for the scm_registerFile class.
27
//
28
//////////////////////////////////////////////////////////////////////
29
 
30
#ifndef REGISTERS_H
31
#define REGISTERS_H
32
 
33
#include <systemc.h>
34
#include <sc_mslib.h>
35
#include"scTypes.h"
36
// mode of processor
37
enum MODE {M_PREV = 0x00, M_USER = 0x10, M_FIQ = 0x11, M_IRQ = 0x12,
38
           M_SVC = 0x13, M_ABORT = 0x17, M_UNDEF = 0x1B, M_SYSTEM = 0x1F};
39
//registers in core
40
enum REGS {R_R0 = 0x00, R_R1 = 0x01, R_R2 = 0x02, R_R3 = 0x03,
41
           R_R4 = 0x04, R_R5 = 0x05, R_R6 = 0x06, R_R7 = 0x07,
42
           R_R8 = 0x08, R_R9 = 0x09, R_R10 = 0x0A, R_FP = 0x0B,
43
           R_IP = 0x0C, R_SP = 0x0D, R_LR = 0x0E, R_PC = 0x0F,
44
           R_CPSR = 0x10,R_SPSR=0x11};
45
// Bit masks for CPSR
46
const uint32_t  V_FLAG= 0x10000000;
47
const uint32_t  C_FLAG= 0x20000000;
48
const uint32_t  Z_FLAG= 0x40000000;
49
const uint32_t  N_FLAG= 0x80000000;
50
 
51
const uint32_t  CZ_FLAGS= 0x60000000;
52
const uint32_t  NV_FLAGS= 0x90000000;
53
 
54
class scRegisterFile:public sc_module
55
{
56
        friend class scARMCore;
57
public:
58
        sc_in<bool>        in_Clock;
59
        sc_in<MODE>        in_MODE;
60
        sc_inslave<bool>        in_b_RW;// 0-Read  1-Write
61
        sc_inslave<REGS>     in_REG;
62
        sc_inoutmaster<uint32_t> inout_n_Data;
63
        sc_inslave<bool>        in_b_RW1;// 0-Read  1-Write
64
        sc_inslave<REGS>     in_REG1;
65
        sc_inoutmaster<uint32_t> inout_n_Data1;
66
        sc_inslave<bool>        in_b_RW2;// 0-Read  1-Write
67
        sc_inslave<REGS>     in_REG2;
68
        sc_inoutmaster<uint32_t> inout_n_Data2;
69
        sc_inslave<bool>        in_b_RW_PC;// 0-Read  1-Write
70
        sc_inslave<REGS>     in_REG_PC;
71
        sc_inoutmaster<uint32_t> inout_n_Data_PC;
72
 
73
public:
74
        void show();
75
        void rw();
76
        void rw1();
77
        void rw2();
78
        void rw4();
79
        void display();
80
 
81
        void entry4();
82
        void entry2();
83
        void entry1();
84
 
85
        SC_HAS_PROCESS(scRegisterFile);
86
        scRegisterFile(const sc_module_name name_):sc_module(name_)
87
        {
88
  //according mode to set the visualabiliy of the registers
89
           set_mode(M_USER);
90
           m_rw=0;
91
 
92
  m_r0=0;
93
  m_r1=0;
94
  m_r2=0;
95
  m_r3=0;
96
  m_r4=0;
97
  m_r5=0;
98
  m_r6=0;
99
  m_r7=0;
100
  m_r8=0;
101
  m_r9=0;
102
  m_r10=0;
103
  m_r11=0;
104
  m_r12=0;
105
  m_r13=0;
106
  m_r14=0;
107
  m_r15=0;
108
  m_cpsr=0;
109
  m_spsr=0;
110
 
111
    //port0
112
       SC_SLAVE(rw,in_b_RW);
113
           SC_SLAVE(entry,in_REG);
114
    //port1  
115
           SC_SLAVE(rw1,in_b_RW1);
116
           SC_SLAVE(entry1,in_REG1);
117
 
118
       SC_SLAVE(rw2,in_b_RW2);
119
           SC_SLAVE(entry2,in_REG2);
120
 
121
       SC_SLAVE(rw4,in_b_RW_PC);
122
           SC_SLAVE(entry4,in_REG_PC);
123
           SC_METHOD(change_mode);
124
           sensitive<<in_MODE;
125
          // SC_METHOD(display);
126
          // sensitive_pos<<in_Clock;
127
 
128
        }
129
        virtual ~scRegisterFile();
130
private:
131
        enum MODE m_Mode;
132
        uint32_t* r[18];
133
        bool m_rw;
134
 
135
private:
136
        void set_mode(MODE);
137
        void change_mode();
138
        void entry(void);
139
 
140
//////////////////////////////////////////////////
141
//////////////////////////////////////////////////
142
//              memom_ry for m_registers                //
143
//////////////////////////////////////////////////
144
//////////////////////////////////////////////////
145
//16 general register   
146
uint32_t  m_r0;
147
uint32_t  m_r1;
148
uint32_t  m_r2;
149
uint32_t  m_r3;
150
uint32_t  m_r4;
151
uint32_t  m_r5;
152
uint32_t  m_r6;
153
uint32_t  m_r7;
154
uint32_t  m_r8;
155
uint32_t  m_r9;
156
uint32_t  m_r10;
157
uint32_t  m_r11;
158
uint32_t  m_r12;
159
uint32_t  m_r13;
160
uint32_t  m_r14;
161
uint32_t  m_r15;
162
uint32_t  m_cpsr;
163
uint32_t  m_spsr;
164
 
165
//7 reg for FIQ mode 
166
uint32_t  m_r8_fiq;
167
uint32_t  m_r9_fiq;
168
uint32_t  m_r10_fiq;
169
uint32_t  m_r11_fiq;
170
uint32_t  m_r12_fiq;
171
uint32_t  m_r13_fiq;
172
uint32_t  m_r14_fiq;
173
uint32_t  m_spsr_fiq;
174
 
175
 //2 reg for supervisor mode
176
uint32_t  m_r13_svc;
177
uint32_t  m_r14_svc;
178
uint32_t  m_spsr_svc;
179
 
180
//2 reg for abort mode
181
uint32_t  m_r13_abt;
182
uint32_t  m_r14_abt;
183
uint32_t  m_spsr_abt;
184
 
185
//2 m_reg for IRQ mode
186
uint32_t  m_r13_irq;
187
uint32_t  m_r14_irq;
188
uint32_t  m_spsr_irq;
189
 
190
//2 m_reg undefined instruction mode
191
uint32_t  m_r13_und;
192
uint32_t  m_r14_und;
193
uint32_t  m_spsr_und;
194
//
195
 
196
 
197
};
198
#endif

powered by: WebSVN 2.1.0

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