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

Subversion Repositories scarm

[/] [scarm/] [branches/] [release_0_1/] [src/] [scARMCore.h] - Blame information for rev 8

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_hold;
78
                 sc_signal<bool>  s_b_is_mrt;
79
sc_signal<bool>  s_b_is_mrt1;
80
        sc_signal<bool>  s_b_is_branch;
81
        sc_signal<bool>  s_b_is_branch1;
82
        sc_signal<bool> s_interrupt1;
83
        sc_signal<bool> s_interrupt2;
84
        sc_signal<COND> s_COND;
85
        sc_signal<bool>  signal_branch_taken_ID;
86
        sc_signal<bool> s_b_flush;
87
        sc_signal<bool> s_b_flush_2;
88
                sc_signal<bool> s_b_branch_taken;
89
        sc_signal<uint32_t> s_n_NPC;
90
        //IF to ID
91
    sc_signal<uint32_t> s_n_Instruction;
92
        sc_signal<uint32_t> s_n_PC;
93
 
94
        //ID to Register File
95
        sc_link_mp<REGS>     l_REG;
96
        sc_signal<MODE>     s_MODE;
97
        sc_link_mp<uint32_t> l_n_Data;
98
        sc_link_mp<bool>        s_b_RW;// 0-Read  1-Write
99
        sc_link_mp<REGS>     l_REG2;
100
        sc_link_mp<uint32_t> l_n_Data2;
101
        sc_link_mp<bool>        s_b_RW2;// 0-Read  1-Write
102
        //ID to EX
103
        sc_signal<OPCODE >    s_OP;
104
    sc_signal<bool>    s_SET;
105
        sc_signal<uint32_t>       s_A;
106
        sc_signal<uint32_t>       s_B;
107
        sc_signal<REGS>           s_Rd1;
108
        sc_signal<REGS>    s_Rm;//used for forwarding
109
    sc_signal<REGS>    s_Rs;
110
    sc_signal<bool>    is_Rm;
111
        sc_signal<bool>    is_Rs;
112
 
113
          //conrol of Barrel shifter
114
            sc_signal<bool>  s_b_S;
115
             sc_signal<SHIFT>  s_SHIFT_TYPE;
116
             sc_signal<uint32_t>  s_n_Dist;
117
                //controls of Mutiplier
118
                 sc_signal<bool>    s_M;
119
                 //controls of MEM
120
         sc_signal<bool>   s_b_ls;
121
         sc_signal<uint32_t>       s_n_Rd;
122
     sc_signal<REGS>   s_Rn;
123
 
124
         sc_signal<bool>   s_b_Pre;
125
         sc_signal<bool>   s_b_Load;
126
     sc_signal<bool>   s_b_WB;
127
        //EX to MEM
128
        sc_signal<uint32_t>       s_Result;
129
        sc_signal<bool>     s_b_write_Rd;
130
        sc_signal<REGS>           s_Rd2;
131
        sc_signal<REGS>           s_Rn1;
132
        sc_signal<uint32_t>       s_n_Rn;
133
        sc_signal<bool>  s_b_ls1;
134
        sc_signal<bool>           s_b_Pre1;// alter base reg before?
135
        sc_signal<bool>           s_b_Load1;// load or store
136
    sc_signal<bool>           s_b_WB1;  //if i should write back to base reg?
137
        //MEM to WB
138
 
139
        sc_signal<REGS>           s_Rd3;
140
        sc_signal<uint32_t>       s_Result1;
141
        sc_signal<REGS>           s_Rn2;
142
        sc_signal<uint32_t>       s_n_Rn1;
143
        sc_signal<bool>           s_b_W_Rd;//if write Rd?
144
        sc_signal<bool>           s_b_WB2;
145
    //WB to RegisterFile
146
        sc_link_mp<REGS>     l_REG1;
147
        sc_link_mp<uint32_t> l_n_Data1;
148
        sc_link_mp<bool>        s_b_RW1;// 0-Read  1-Write
149
           //branch
150
        sc_signal<bool>     s_b_B;  //is it a branch?
151
        sc_signal<uint32_t> s_n_B; //branch address
152
        //access link  
153
 
154
 
155
        sc_link_mp<bool>        s_b_RW_PC;// 0-Read  1-Write
156
        sc_link_mp<REGS>     l_REG_PC;
157
        sc_link_mp<uint32_t> l_n_Data_PC;
158
 
159
        sc_signal<bool>  s_b_excute;
160
        sc_signal<bool>  s_b_excute1;
161
        //forwarding
162
        sc_signal<REGS>         s_Rd_from_mem;//target
163
        sc_signal<uint32_t>     s_n_Result_from_mem;
164
        sc_signal<REGS>         s_Rn_from_mem;//write-back register
165
        sc_signal<uint32_t>     s_n_Rn_from_mem; //write-back data  
166
 
167
 
168
private:
169
        scNPC   inst_NPC;
170
        scIF inst_IFStage;
171
        scID inst_IDStage;
172
        scRegisterFile inst_Regs;
173
        scEX inst_EXStage;
174
        scMEM inst_MEMStage;
175
        scWB inst_WBStage;
176
 
177
public:
178
        SC_HAS_PROCESS(scARMCore);
179
        scARMCore(sc_module_name name_):sc_module(name_),
180
 
181
                inst_Regs("regs"),
182
                inst_NPC("npc"),
183
                inst_IFStage("if"),
184
                inst_IDStage("id"),
185
                inst_EXStage("ex"),
186
                inst_MEMStage("mem"),
187
                inst_WBStage("wb")
188
 
189
        {
190
                        //registers
191
                s_MODE=M_USER;
192
        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);
193
 
194
        //internal structure of the pineline
195
                inst_NPC(s_b_hold,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);
196
                inst_IFStage(s_b_hold,in_b_Clock,s_b_flush,s_b_flush_2,s_n_NPC,
197
                                 s_b_RW_PC,l_REG_PC,l_n_Data_PC,
198
                                 // read memory
199
                                 out_b_nRW,out_n_Addr,inout_n_Data,
200
                                         //out to ID
201
                                 s_n_Instruction,
202
                                         s_n_PC
203
 
204
                                         );
205
 
206
                inst_IDStage(s_b_hold,in_b_Clock,s_b_is_branch,s_interrupt1,s_COND,signal_branch_taken_ID,s_b_flush_2,s_b_flush,
207
                                 //input from IF
208
                                 s_n_Instruction,
209
                                         s_n_PC,
210
                                         //access register file
211
                                         s_b_RW, l_REG,l_n_Data,
212
                                         //ID to EX
213
                                         s_A, s_B,
214
                                     s_OP,s_SET,              //controls of ALU
215
                                         s_b_S,s_SHIFT_TYPE,s_b_is_mrt,s_n_Dist,        //controls of shifter
216
                                         s_M,             //controls of multiplier
217
                                         s_b_ls,s_Rn,s_b_Pre,s_b_Load,s_b_WB,//controls of MEM
218
                                         s_Rd1,s_Rm,s_Rs,is_Rm,is_Rs
219
                                 );
220
                inst_EXStage(s_b_hold,
221
                                                 out_b_nRW,out_n_Addr,inout_n_Data,
222
                        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,
223
                                 s_b_B,//branch
224
                                         s_b_RW1,l_REG1,l_n_Data1,
225
                                 //access register file
226
                                         s_b_RW2,l_REG2, l_n_Data2,
227
                      //A bus and B bus
228
                                s_Rd1,s_Rm,s_Rs,is_Rm,is_Rs,
229
                                        s_Rd2,
230
                                        s_A,s_B,s_OP,s_SET,
231
                                        s_b_S,s_SHIFT_TYPE,s_b_is_mrt,s_b_is_mrt1,s_n_Dist,
232
                                        s_M,//controls of multiplier
233
                                        s_b_ls,s_Rn,s_b_Pre,s_b_Load,s_b_WB,
234
                                        s_b_ls1,s_Rn1,//
235
 
236
                                        s_b_Pre1,// alter base reg before?
237
                                        s_b_Load1,// load or store
238
                                        s_b_WB1,  //if i should write back to base reg?
239
                    s_n_Rn,
240
                                        s_Result,       s_b_write_Rd,s_n_Rd,
241
                                        s_b_excute,
242
                                        s_b_W_Rd,s_Rd3,s_Result1,s_b_WB2,s_Rn2,s_n_Rn1
243
                                        );
244
 
245
                inst_MEMStage(in_b_Clock,s_interrupt2,s_b_branch_taken,s_b_excute,s_b_excute1,
246
 
247
                        //read/write meme
248
                         out_b_nRW,out_n_Addr,inout_n_Data,
249
            // 
250
            s_b_RW,l_REG,l_n_Data,
251
                        s_Rd2,s_b_write_Rd,s_Rn1,s_n_Rn,
252
                        s_b_ls1,s_b_is_mrt1,s_b_Pre1,s_b_Load1,s_b_WB1,
253
                        s_Result,s_n_Rd,s_b_W_Rd,s_b_WB2,
254
                        s_Rd3,s_Result1,s_Rn2,s_n_Rn1
255
 
256
 
257
                        );
258
                        inst_WBStage(in_b_Clock,s_b_excute1,
259
                        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);
260
 
261
 
262
 
263
        };
264
        virtual ~scARMCore();
265
 
266
private:
267
 
268
                void entry(void);
269
};
270
 
271
#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.