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

Subversion Repositories scarm

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 zhong
// scEX.h: interface for the scEX class.
2
/*                            -------------------
3
    begin                : Oct 2 2002
4
    copyright            : (C) 2002 UESTC
5
    author               : Zhong Tao
6
    email                : zhong@opencores.org
7
 ***************************************************************************/
8
 
9
/***************************************************************************
10
 *                                                                         *
11
 *   This program is free software; you can redistribute it and/or modify  *
12
 *   it under the terms of the GNU General Public License as published by  *
13
 *   the Free Software Foundation; either version 2 of the License, or     *
14
 *   (at your option) any later version.                                   *
15
 *                                                                         *
16
 ***************************************************************************/
17
 
18
#if !defined(AFX_SCEX_H__8C326337_AB49_11D6_BB1E_000000000000__INCLUDED_)
19
#define AFX_SCEX_H__8C326337_AB49_11D6_BB1E_000000000000__INCLUDED_
20
 
21
#if _MSC_VER > 1000
22
#pragma once
23
#endif // _MSC_VER > 1000
24
#include <systemc.h>
25
#include "scTypes.h"
26
#include "scALU.h"
27
#include "scRegisterFile.h"
28
#include "scBarrelShifter.h"
29
#include "scBooth.h"
30
#define DEBUG  
31
class scEX:  public sc_module
32
{
33
public:
34
        sc_out<bool>     out_b_hold;
35
        sc_outmaster<bool>  out_b_nRW_mem;
36
        sc_outmaster<uint32_t> out_n_Addr_mem;//  address bus
37
        sc_inoutslave<uint32_t>  inout_n_Data_mem; //Instruction bus
38
        sc_in<bool> in_b_Clock;
39
        sc_in<bool>  in_b_is_branch;
40
        sc_out<bool>  out_b_is_branch;
41
        sc_in<bool> in_interrupt;
42
        sc_out<bool> out_interrupt;
43
        sc_in<COND> in_COND;
44
        sc_in<bool>  in_branch_taken;
45
        sc_out<bool> out_b_flush_2;
46
                //branch
47
        sc_out<bool> out_b_branch_taken;
48
        sc_out<bool> out_b_Branch;
49
        //access link  
50
        sc_outmaster<bool> out_b_RW_link;
51
        sc_outmaster<REGS> out_REG_link;
52
        sc_inoutslave<uint32_t> inout_n_Data_link;
53
 
54
        //access CPSR  
55
        sc_outmaster<bool> out_b_RW;
56
        sc_outmaster<REGS> out_REG;
57
        sc_inoutslave<uint32_t> inout_n_Data;
58
 
59
        //target reg
60
        sc_in<REGS> in_Rd;
61
        sc_out<REGS> in_Rm;//used for forwarding
62
    sc_out<REGS> in_Rs;
63
    sc_in<bool>    is_Rm;
64
        sc_in<bool>    is_Rs;
65
   // sc_out<bool>    out_is_Rm;
66
        //sc_out<bool>    out_is_Rs;
67
        sc_out<REGS> out_Rd;
68
        //
69
        sc_in<uint32_t> in_A;
70
        sc_in<uint32_t> in_B;
71
 
72
        // ALU controls
73
        sc_in<OPCODE >    in_OP;
74
    sc_in<bool>    in_SET;
75
        // controls of shifter
76
        sc_in<bool>   in_b_S;
77
        sc_in<SHIFT>  in_SHIFT_TYPE;
78
                 sc_in<bool>  in_b_is_mrt;
79
                        sc_out<bool>   out_is_mrt;
80
        sc_in<uint32_t>  in_n_Dist;
81
        //controls of booth mutiplier
82
        sc_in<bool>  in_b_M;
83
 
84
        //controls of MEM
85
         sc_in<bool>  in_b_ls;//is it load/store instruction
86
         sc_in<REGS>   in_Rn; //base adress register
87
         sc_in<bool>   in_b_Pre;// alter base reg before?
88
         sc_in<bool>   in_b_Load;// load or store
89
     sc_in<bool>   in_b_WB;  //if i should write back to base reg?
90
    // EX to MEM
91
         sc_out<bool>  out_b_ls;//is it load/store instruction
92
         sc_out<REGS> out_Rn; //base adress register
93
         sc_out<bool> out_b_Pre;// alter base reg before?
94
         sc_out<bool> out_b_Load;// load or store
95
     sc_out<bool> out_b_WB;  //if i should write back to base reg?
96
     sc_out<uint32_t>  out_n_Rn;
97
        sc_out<uint32_t> out_n_Result;
98
        sc_out<bool>     out_b_write_Rd;
99
 
100
        //  if store instruction, load Rd 
101
        sc_out<uint32_t> out_n_Rd;
102
        sc_out<bool>  out_b_excute;
103
        //forwarding
104
        sc_in<bool>         in_is_write_Rd;
105
        sc_in<REGS>         in_Rd_from_mem;//target
106
        sc_in<uint32_t>     in_n_Result_from_mem;
107
        sc_in<bool>         in_b_WB_from_mem;
108
        sc_in<REGS>         in_Rn_from_mem;//write-back register
109
        sc_in<uint32_t>     in_n_Rn_from_mem; //write-back data (value in memory rather than Rn) 
110
private:
111
 
112
        bool m_b_branch;
113
        bool m_b_hold;
114
        uint32_t m_n_CPSR;
115
        bool m_b_flush;
116
        bool m_b_excute;
117
        //target reg
118
        REGS m_Rd;
119
    uint32_t m_A;
120
        uint32_t m_B;
121
 
122
        // ALU controls
123
        COND m_COND;
124
        OPCODE   m_OP;
125
    bool     m_SET;
126
        // controls of shifter
127
        bool     m_b_S;
128
        SHIFT  m_SHIFT_TYPE;
129
        uint32_t  m_n_Dist;
130
        //controls of booth mutiplier
131
        bool  m_b_M;
132
        //controls of MEM
133
         bool  m_b_ls;//is it load/store instruction
134
         REGS   m_Rn; //base adress register
135
         bool   m_b_Pre;// alter base reg before?
136
         bool   m_b_Load;// load or store
137
     bool   m_b_WB;  //if i should write back to base reg?
138
         bool  m_is_Rs;
139
         bool  m_is_Rm;
140
         bool  m_predict;
141
         uint32_t m_n_Result;
142
        //forwarding
143
        bool         m_is_write_Rd;
144
        REGS         m_Rd_from_mem;//target
145
        uint32_t     m_n_Result_from_mem;
146
        bool         m_b_WB_from_mem;
147
        REGS         m_Rn_from_mem;//write-back register
148
        uint32_t     m_n_Rn_from_mem; //write-back data 
149
 
150
private:
151
        sc_event trigger1,trigger2,trigger3,trigger4,trigger5;
152
        sc_event trigger01_ex,trigger02_ex, trigger03_ex;
153
        sc_event trigger_write_lr;
154
        sc_signal<uint32_t> s_A;
155
        sc_signal<uint32_t> s_B;
156
        //multiplier
157
        sc_signal<uint32_t> s_A_Mult;
158
        sc_signal<uint32_t> s_B_Mult;
159
        sc_signal<uint32_t> s_mult_out;
160
        //shifter
161
        sc_signal<uint32_t> s_shift_in;
162
        sc_signal<uint32_t> s_shift_out;
163
        sc_signal<SHIFT>   s_shift_type;
164
        sc_signal<uint32_t> s_shift_dist;
165
        sc_signal<bool>     s_carry;
166
        //
167
        sc_signal<uint32_t> s_alu_out;
168
        sc_signal<uint32_t> s_n_CPSR;
169
        sc_signal<COND>     s_COND;
170
        sc_signal<OPCODE>   s_OP;
171
 
172
public:
173
        void write_lr();
174
        void last_half();
175
        void delay0();
176
        void forwarding_pc();
177
        void delay3();
178
        void delay2();
179
        void delay1();
180
        void forwarding1();
181
        void out_delay();
182
        void regs();
183
        void forwarding();
184
        void display();
185
        void alu_delay();
186
        bool is_excute(COND cond,uint32_t flag);
187
        void shift_delay();
188
        void middle();
189
        void out();
190
        void entry();
191
        SC_HAS_PROCESS(scEX);
192
        scEX(sc_module_name);
193
        virtual ~scEX();
194
private:
195
        scBooth    mult;
196
        scBarrelShifter bsh;
197
        scALU alu;
198
private:
199
         //save for forwarding
200
        REGS m_last_Rd;
201
 
202
        REGS m_last_Rn;
203
    OPCODE m_last_OP;
204
        bool m_b_last_Load;
205
        bool m_b_last_ls;
206
    REGS m_Rm,m_Rs;
207
        uint32_t m_last_Result;
208
        bool m_b_last_WB;
209
        bool m_b_last_is_Rm;
210
        bool m_b_last_is_Rs;
211
        bool m_b_last_excute;
212
        bool m_b_last_branch;
213
        bool m_b_interrupt;
214
        uint32_t m_n_list;
215
        bool m_b_is_mrt;
216
 
217
#if defined(DEBUG)
218
int flush_number;
219
#endif
220
 
221
};
222
 
223
 
224
 
225
#endif // !defined(AFX_SCEX_H__8C326337_AB49_11D6_BB1E_000000000000__INCLUDED_)

powered by: WebSVN 2.1.0

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