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

Subversion Repositories scarm

[/] [scarm/] [trunk/] [src/] [¸´¼þscARMCore.h] - Blame information for rev 10

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

Line No. Rev Author Line
1 5 zhong
 
2
///////////////////////////////////////////////////////////////////////////////
3
// This program is free software; you can redistribute it and/or
4
// modify it under the terms of the GNU General Public License
5
// as published by the Free Software Foundation; either version 2
6
// of the License, or (at your option) any later version.
7
//
8
// This program is distributed in the hope that it will be useful,
9
// but WITHOUT ANY WARRANTY; without even the implied warranty of
10
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
// GNU General Public License for more details.
12
//
13
// You should have received a copy of the GNU General Public License
14
// along with this program; if not, write to the Free Software
15
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
16
//
17
//   scARMCore.h: interface for the scARMCore class.
18
//              
19
//          
20
//  Original Author: Allen Tao Zhong,
21
//  University of Electronic Science and Technology in China
22
//  email: zhong@opencores.org
23
//  header n/a
24
//  info   This is a simple ARM modeling using SystemC.
25
//               Architecure defined by Allen Tao Zhong. 
26
//
27
///////////////////////////////////////////////////////////////////////////////
28
 
29
/*****************************************************************************
30
 
31
  MODIFICATION LOG - modifiers, enter your name, affiliation, date and
32
  changes you are making here.
33
 
34
      Name, Affiliation, Date:
35
  Description of Modification:
36
 
37
 *****************************************************************************/
38
 
39
 
40
#if !defined(CORE_H)
41
#define CORE_H
42
 
43
 
44
#include<systemc.h>
45
#include"scRegisterFile.h"
46
#include <sc_mslib.h>
47
 
48
#include"scIF.h"
49
#include"scID.h"
50
#include"scEX.h"
51
#include "scMEM.h"
52
#include "scWB.h"
53
#include "scRegisterFile.h"
54
#include "scNPC.h"
55
 
56
 
57
 
58
#include"scTypes.h"     // Added by ClassView
59
 
60
 
61
//vectors for exceptions
62
/*
63
enum VECTOR {V_RESET = 0x00, V_UNDEF = 0x04, V_SWI = 0x08, V_PABORT = 0x0C,
64
             V_DABORT = 0x10, V_IRQ = 0x18, V_FIQ = 0x1C};
65
                 */
66
 
67
 
68
 
69
class scARMCore  :public sc_module
70
{
71
public://ports
72
        sc_in<bool>       in_b_Clock;
73
    sc_outmaster<bool>     out_b_nRW;
74
        sc_outmaster<uint32_t> out_n_Addr;//  address bus
75
        sc_inoutslave<uint32_t>  inout_n_Data; //Instruction bus
76
private://internal interconnects
77
        sc_signal<bool>  s_b_is_branch;
78
        sc_signal<bool>  s_b_is_branch1;
79
        sc_signal<bool> s_interrupt1;
80
        sc_signal<bool> s_interrupt2;
81
        sc_signal<COND> s_COND;
82
        sc_signal<bool>  signal_branch_taken_ID;
83
        sc_signal<bool> s_b_flush;
84
        sc_signal<bool> s_b_flush_2;
85
                sc_signal<bool> s_b_branch_taken;
86
        sc_signal<uint32_t> s_n_NPC;
87
        //IF to ID
88
    sc_signal<uint32_t> s_n_Instruction;
89
        sc_signal<uint32_t> s_n_PC;
90
 
91
        //ID to Register File
92
        sc_link_mp<REGS>     l_REG;
93
        sc_signal<MODE>     s_MODE;
94
        sc_link_mp<uint32_t> l_n_Data;
95
        sc_link_mp<bool>        s_b_RW;// 0-Read  1-Write
96
        sc_link_mp<REGS>     l_REG2;
97
        sc_link_mp<uint32_t> l_n_Data2;
98
        sc_link_mp<bool>        s_b_RW2;// 0-Read  1-Write
99
        //ID to EX
100
        sc_signal<OPCODE >    s_OP;
101
    sc_signal<bool>    s_SET;
102
        sc_signal<uint32_t>       s_A;
103
        sc_signal<uint32_t>       s_B;
104
        sc_signal<REGS>           s_Rd1;
105
        sc_signal<REGS>    s_Rm;//used for forwarding
106
    sc_signal<REGS>    s_Rs;
107
    sc_signal<bool>    is_Rm;
108
        sc_signal<bool>    is_Rs;
109
 
110
          //conrol of Barrel shifter
111
            sc_signal<bool>  s_b_S;
112
             sc_signal<SHIFT>  s_SHIFT_TYPE;
113
             sc_signal<uint32_t>  s_n_Dist;
114
                //controls of Mutiplier
115
                 sc_signal<bool>    s_M;
116
                 //controls of MEM
117
         sc_signal<bool>   s_b_ls;
118
         sc_signal<uint32_t>       s_n_Rd;
119
     sc_signal<REGS>   s_Rn;
120
 
121
         sc_signal<bool>   s_b_Pre;
122
         sc_signal<bool>   s_b_Load;
123
     sc_signal<bool>   s_b_WB;
124
        //EX to MEM
125
        sc_signal<uint32_t>       s_Result;
126
        sc_signal<bool>     s_b_write_Rd;
127
        sc_signal<REGS>           s_Rd2;
128
        sc_signal<REGS>           s_Rn1;
129
        sc_signal<uint32_t>       s_n_Rn;
130
        sc_signal<bool>  s_b_ls1;
131
        sc_signal<bool>           s_b_Pre1;// alter base reg before?
132
        sc_signal<bool>           s_b_Load1;// load or store
133
    sc_signal<bool>           s_b_WB1;  //if i should write back to base reg?
134
        //MEM to WB
135
 
136
        sc_signal<REGS>           s_Rd3;
137
        sc_signal<uint32_t>       s_Result1;
138
        sc_signal<REGS>           s_Rn2;
139
        sc_signal<uint32_t>       s_n_Rn1;
140
        sc_signal<bool>           s_b_W_Rd;//if write Rd?
141
        sc_signal<bool>           s_b_WB2;
142
    //WB to RegisterFile
143
        sc_link_mp<REGS>     l_REG1;
144
        sc_link_mp<uint32_t> l_n_Data1;
145
        sc_link_mp<bool>        s_b_RW1;// 0-Read  1-Write
146
           //branch
147
        sc_signal<bool>     s_b_B;  //is it a branch?
148
        sc_signal<uint32_t> s_n_B; //branch address
149
        //access link  
150
 
151
 
152
        sc_link_mp<bool>        s_b_RW_PC;// 0-Read  1-Write
153
        sc_link_mp<REGS>     l_REG_PC;
154
        sc_link_mp<uint32_t> l_n_Data_PC;
155
 
156
        sc_signal<bool>  s_b_excute;
157
        sc_signal<bool>  s_b_excute1;
158
        //forwarding
159
        sc_signal<REGS>         s_Rd_from_mem;//target
160
        sc_signal<uint32_t>     s_n_Result_from_mem;
161
        sc_signal<REGS>         s_Rn_from_mem;//write-back register
162
        sc_signal<uint32_t>     s_n_Rn_from_mem; //write-back data  
163
 
164
 
165
private:
166
        scNPC   inst_NPC;
167
        scIF inst_IFStage;
168
        scID inst_IDStage;
169
        scRegisterFile inst_Regs;
170
        scEX inst_EXStage;
171
        scMEM inst_MEMStage;
172
        scWB inst_WBStage;
173
 
174
public:
175
        SC_HAS_PROCESS(scARMCore);
176
        scARMCore(sc_module_name name_):sc_module(name_),
177
 
178
                inst_Regs("regs"),
179
                inst_NPC("npc"),
180
                inst_IFStage("if"),
181
                inst_IDStage("id"),
182
                inst_EXStage("ex"),
183
                inst_MEMStage("mem"),
184
                inst_WBStage("wb")
185
 
186
        {
187
                        //registers
188
                s_MODE=M_USER;
189
        inst_Regs(in_b_Clock,s_MODE,s_b_RW,l_REG,l_n_Data,s_b_RW1,l_REG1,l_n_Data1,s_b_RW2,l_REG2,l_n_Data2,s_b_RW_PC,l_REG_PC,l_n_Data_PC);
190
 
191
        //internal structure of the pineline
192
                inst_NPC(in_b_Clock,s_b_flush,s_n_PC,s_b_B,s_Result,s_n_NPC,s_b_RW_PC,l_REG_PC,l_n_Data_PC);
193
                inst_IFStage(in_b_Clock,s_b_flush,s_b_flush_2,s_n_NPC,
194
                                 s_b_RW_PC,l_REG_PC,l_n_Data_PC,
195
                                 // read memory
196
                                 out_b_nRW,out_n_Addr,inout_n_Data,
197
                                         //out to ID
198
                                 s_n_Instruction,
199
                                         s_n_PC
200
 
201
                                         );
202
 
203
                inst_IDStage(in_b_Clock,s_b_is_branch,s_interrupt1,s_COND,signal_branch_taken_ID,s_b_flush_2,s_b_flush,
204
                                 //input from IF
205
                                 s_n_Instruction,
206
                                         s_n_PC,
207
                                         //access register file
208
                                         s_b_RW, l_REG,l_n_Data,
209
                                         //ID to EX
210
                                         s_A, s_B,
211
                                     s_OP,s_SET,              //controls of ALU
212
                                         s_b_S,s_SHIFT_TYPE,s_n_Dist,        //controls of shifter
213
                                         s_M,             //controls of multiplier
214
                                         s_b_ls,s_Rn,s_b_Pre,s_b_Load,s_b_WB,//controls of MEM
215
                                         s_Rd1,s_Rm,s_Rs,is_Rm,is_Rs
216
                                 );
217
                inst_EXStage(in_b_Clock,s_b_is_branch,s_b_is_branch1,s_interrupt1,s_interrupt2,s_COND,signal_branch_taken_ID,s_b_flush_2,s_b_branch_taken,
218
                                 s_b_B,//branch
219
                                         s_b_RW1,l_REG1,l_n_Data1,
220
                                 //access register file
221
                                         s_b_RW2,l_REG2, l_n_Data2,
222
                      //A bus and B bus
223
                                s_Rd1,s_Rm,s_Rs,is_Rm,is_Rs,
224
                                        s_Rd2,
225
                                        s_A,s_B,s_OP,s_SET,
226
                                        s_b_S,s_SHIFT_TYPE,s_n_Dist,
227
                                        s_M,//controls of multiplier
228
                                        s_b_ls,s_Rn,s_b_Pre,s_b_Load,s_b_WB,
229
                                        s_b_ls1,s_Rn1,//
230
 
231
                                        s_b_Pre1,// alter base reg before?
232
                                        s_b_Load1,// load or store
233
                                        s_b_WB1,  //if i should write back to base reg?
234
                    s_n_Rn,
235
                                        s_Result,       s_b_write_Rd,s_n_Rd,
236
                                        s_b_excute,
237
                                        s_b_W_Rd,s_Rd3,s_Result1,s_b_WB2,s_Rn2,s_n_Rn1
238
                                        );
239
 
240
                inst_MEMStage(in_b_Clock,s_interrupt2,s_b_branch_taken,s_b_excute,s_b_excute1,
241
 
242
                        //read/write meme
243
                         out_b_nRW,out_n_Addr,inout_n_Data,
244
            // 
245
            s_b_RW,l_REG,l_n_Data,
246
                        s_Rd2,s_b_write_Rd,s_Rn1,s_n_Rn,
247
                        s_b_ls1,s_b_Pre1,s_b_Load1,s_b_WB1,
248
                        s_Result,s_n_Rd,s_b_W_Rd,s_b_WB2,
249
                        s_Rd3,s_Result1,s_Rn2,s_n_Rn1
250
 
251
 
252
                        );
253
                        inst_WBStage(in_b_Clock,s_b_excute1,
254
                        s_Rd3,s_Result1,s_Rn2,s_n_Rn1,s_b_W_Rd,s_b_WB2,s_b_RW,l_REG,l_n_Data,s_b_RW2,l_REG2,l_n_Data2);
255
 
256
 
257
 
258
        };
259
        virtual ~scARMCore();
260
 
261
private:
262
 
263
                void entry(void);
264
};
265
 
266
#endif // !defined(AFX_SCARMCORE_H__3D36E4DC_3B3D_11D6_B9E2_000000000000__INCLUDED_)

powered by: WebSVN 2.1.0

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