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

Subversion Repositories copyblaze

[/] [copyblaze/] [trunk/] [copyblaze/] [rtl/] [vhdl/] [cpu/] [cp_DecodeControl.vhd] - Blame information for rev 57

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 ameziti
--------------------------------------------------------------------------------
2
-- Company: 
3
--
4
-- File: cp_DecodeControl.vhd
5
--
6
-- Description:
7
--      projet copyblaze
8
--      instruction decoding & Operational control
9
--
10
-- File history:
11
-- v1.0: 21/10/11: Creation
12
-- v2.0: 26/10/11: Add Wishbone instructions
13
--
14
-- Targeted device: ProAsic A3P250 VQFP100
15
-- Author: AbdAllah Meziti
16
--------------------------------------------------------------------------------
17
 
18
library ieee;
19
use ieee.std_logic_1164.all;
20
use ieee.numeric_std.all;
21
 
22
use     work.Usefull_Pkg.all;           -- Usefull Package
23
 
24
--------------------------------------------------------------------------------
25
-- Entity: cp_DecodeControl
26
--
27
-- Description:
28
--      
29
--      REMARQUE:
30
--
31
--      
32
-- History:
33
-- 21/10/11 AM: Creation
34
-- ---------------------
35
-- xx/xx/xx AM: 
36
--                              
37
--------------------------------------------------------------------------------
38
entity cp_DecodeControl is
39
        generic
40
        (
41
                GEN_WIDTH_INST          : positive := 18;
42
                GEN_WIDTH_PC            : positive := 10;
43
 
44
                GEN_DEPTH_BANC          : positive := 16;       -- Taille (en octet) du Banc Register
45
                GEN_DEPTH_SCRATCH       : positive := 64        -- Taille (en octet) du Scratch Pad
46
        );
47
        port (
48
        --------------------------------------------------------------------------------
49
        -- Signaux Fonctionels
50
        --------------------------------------------------------------------------------
51
                --Phase1_i                      : in std_ulogic;
52
                Phase2_i                        : in std_ulogic;
53
 
54
                IEvent_i                        : in std_ulogic;
55
 
56
                Instruction_i           : in std_ulogic_vector(GEN_WIDTH_INST-1 downto 0);
57
 
58
                Fetch_o                         : out std_ulogic;
59
                Input_o                         : out std_ulogic;
60
                Ouput_o                         : out std_ulogic;
61
                Jump_o                          : out std_ulogic;
62
                Call_o                          : out std_ulogic;
63
                Return_o                        : out std_ulogic;
64
                ReturnI_o                       : out std_ulogic;
65
                IEWrite_o                       : out std_ulogic;
66
                BancWrite_o                     : out std_ulogic;
67
                ScratchWrite_o          : out std_ulogic;
68
                OperationSelect_o       : out std_ulogic_vector(2 downto 0);
69
                FlagsWrite_o            : out std_ulogic;
70
                FlagsPush_o                     : out std_ulogic;
71
                FlagsPop_o                      : out std_ulogic;
72
 
73
                aaa_o                           : out std_ulogic_vector(GEN_WIDTH_PC-1 downto 0);
74
                kk_o                            : out std_ulogic_vector(7 downto 0);
75
                ss_o                            : out std_ulogic_vector(log2(GEN_DEPTH_SCRATCH)-1 downto 0);
76
                pp_o                            : out std_ulogic_vector(7 downto 0);
77
 
78
                SxPtr_o                         : out std_ulogic_vector(log2(GEN_DEPTH_BANC)-1 downto 0);
79
                SyPtr_o                         : out std_ulogic_vector(log2(GEN_DEPTH_BANC)-1 downto 0);
80
 
81
                OperandSelect_o         : out std_ulogic;
82
 
83
                ArithOper_o                     : out std_ulogic_vector(1 downto 0);
84
                LogicOper_o                     : out std_ulogic_vector(1 downto 0);
85
                ShiftBit_o                      : out std_ulogic_vector(2 downto 0);
86
                ShiftSens_o                     : out std_ulogic;
87
 
88
                ConditionCtrl_o         : out std_ulogic_vector(2 downto 0);
89
 
90
                IEValue_o                       : out std_ulogic;
91
 
92
                wbRdSing_o                      : out std_ulogic;
93
                wbWrSing_o                      : out std_ulogic
94
        );
95
end cp_DecodeControl;
96
 
97
--------------------------------------------------------------------------------
98
-- Architecture: RTL
99
-- of entity : cp_DecodeControl
100
--------------------------------------------------------------------------------
101
architecture rtl of cp_DecodeControl is
102
 
103
        --------------------------------------------------------------------------------
104
        -- Définition des fonctions
105
        --------------------------------------------------------------------------------
106
 
107
 
108
 
109
        --------------------------------------------------------------------------------
110
        -- Définition des constantes
111
        --------------------------------------------------------------------------------
112
 
113
        --------------------------------------------------------------------------------
114
        -- Définition des signaux interne
115
        --------------------------------------------------------------------------------
116
        signal  iInstruction            : std_ulogic_vector(GEN_WIDTH_INST-1 downto 0);
117
 
118
        alias   iInstructionCode        : std_ulogic_vector(4 downto 0) is iInstruction(17 downto 13);
119
        -- **** --
120
        -- PATH --
121
        -- **** --
122
        alias   iaaa                            : std_ulogic_vector(GEN_WIDTH_PC-1 downto 0)                     is iInstruction(GEN_WIDTH_PC-1 downto 0);
123
        alias   ikk                                     : std_ulogic_vector(7 downto 0)                                                  is iInstruction(7 downto 0);
124
        alias   iss                                     : std_ulogic_vector(log2(GEN_DEPTH_SCRATCH)-1 downto 0)  is iInstruction(log2(GEN_DEPTH_SCRATCH)-1 downto 0);
125
        alias   ipp                                     : std_ulogic_vector(7 downto 0)                                                  is iInstruction(7 downto 0);
126
 
127
        alias   iSxPtr                          : std_ulogic_vector(log2(GEN_DEPTH_BANC)-1 downto 0)     is iInstruction(8+log2(GEN_DEPTH_BANC)-1 downto 8);
128
        alias   iSyPtr                          : std_ulogic_vector(log2(GEN_DEPTH_BANC)-1 downto 0)     is iInstruction(4+log2(GEN_DEPTH_BANC)-1 downto 4);
129
        -- ******* --
130
        -- CONTROL --
131
        -- ******* --
132
        -- Alu
133
        signal  iOperationSelect        : std_ulogic_vector(2 downto 0);
134
        alias   iOperandSelect          : std_ulogic                                                                                    is iInstruction(12);
135
 
136
        alias   iArithOper                      : std_ulogic_vector(1 downto 0)                                          is iInstruction(14 downto 13);
137
        alias   iLogicOper                      : std_ulogic_vector(1 downto 0)                                          is iInstruction(14 downto 13);
138
        alias   iShiftBit                       : std_ulogic_vector(2 downto 0)                                          is iInstruction(2 downto 0);
139
        alias   iShiftSens                      : std_ulogic                                                                                    is iInstruction(3);
140
        -- Banc
141
        signal  iBancWrite                      : std_ulogic;
142
        -- Scratch
143
        signal  iScratchWrite           : std_ulogic;
144
        -- Flags
145
        signal  iFlagsWrite                     ,
146
                        iFlagsPush                      ,
147
                        iFlagsPop                       : std_ulogic;
148
 
149
        signal  iIEWrite                        : std_ulogic;
150
        signal  iAddSub                         ,
151
                        iCompare                        ,
152
                        iLoad                           ,
153
                        iLogic                          ,
154
                        iTest                           ,
155
                        iShift                          ,
156
                        iStore                          ,
157
                        iFetch                          ,
158
                        iInput                          ,
159
                        iOuput                          ,
160
                        iJump                           ,
161
                        iCall                           ,
162
                        iReturn                         ,
163
                        iReturnI                        ,
164
                        iSetInterrupt           ,
165
                        -- Wishbone instructions
166
                        iWBWrSing                       ,
167
                        iWBRdSing
168
                                                                : std_ulogic;
169
        -- Flow
170
        alias   iConditionCtrl          : std_ulogic_vector(2 downto 0)                                          is iInstruction(12 downto 10);
171
        -- Int          
172
        alias   iIEValue                        : std_ulogic                                                                                    is iInstruction(0);
173
        signal  iIEvent                         : std_ulogic;
174
 
175
        --------------------------------------------------------------------------------
176
        -- Déclaration des composants
177
        --------------------------------------------------------------------------------
178
 
179
begin
180
        --------------------------------------------------------------------------------
181
        -- DECODER
182
        --------------------------------------------------------------------------------
183
        iIEvent                 <=      IEvent_i;
184
 
185
        -- Preempte the instruction in case of interrupt event
186
        iInstruction    <=      (others => '1') when (iIEvent='1') else Instruction_i;
187
 
188
        --------------------------------------------------------------------------------
189
        -- INSTRUCTION DECODER
190
        --------------------------------------------------------------------------------
191
        -- Arithmetic Group
192 18 ameziti
        iAddSub                 <=      '1' when ((iInstructionCode = '0' & x"C") or
193
                                                                  (iInstructionCode = '0' & x"D") or
194
                                                                  (iInstructionCode = '0' & x"E") or
195
                                                                  (iInstructionCode = '0' & x"F")) else '0';
196 2 ameziti
        iCompare                <=      '1' when ( iInstructionCode = '0' & x"A" ) else '0';
197
 
198
        -- Logic Group
199
        iLoad                   <=      '1' when ( iInstructionCode = '0' & x"0" ) else '0';
200 18 ameziti
        iLogic                  <=      '1' when ((iInstructionCode = '0' & x"5") or
201
                                                                  (iInstructionCode = '0' & x"6") or
202
                                                                  (iInstructionCode = '0' & x"7")) else '0';
203 2 ameziti
        iTest                   <=      '1' when ( iInstructionCode = '0' & x"9" ) else '0';
204
 
205
        -- Shift and Rotate Group
206
        iShift                  <=      '1' when ( iInstructionCode = '1' & x"0" ) else '0';
207
 
208
        -- Storage Group
209
        iStore                  <=      '1' when ( iInstructionCode = '1' & x"7" ) else '0';
210
        iFetch                  <=      '1' when ( iInstructionCode = '0' & x"3" ) else '0';
211
 
212
        -- Input/Ouput Group
213
        iInput                  <=      '1' when ( iInstructionCode = '0' & x"2" ) else '0';
214
        iOuput                  <=      '1' when ( iInstructionCode = '1' & x"6" ) else '0';
215
 
216
        -- Program Control Group
217
        iJump                   <=      '1' when ( iInstructionCode = '1' & x"A" ) else '0';
218
        iCall                   <=      '1' when ( iInstructionCode = '1' & x"8" ) else '0';
219
        iReturn                 <=      '1' when ( iInstructionCode = '1' & x"5" ) else '0';
220
 
221
        -- Interrupt Group
222
        iReturnI                <=      '1' when ( iInstructionCode = '1' & x"C" ) else '0';
223
        -- TODO : The ENABLE INTERRUPT instruction must clear the "iIEvent" bit if is set while the interrupts are disabled.
224
        iSetInterrupt   <=      '1' when ( iInstructionCode = '1' & x"E" ) else '0';
225
 
226
        -- Reserved for extension 6
227
        -- STAR                 = '0' & "B"     
228
        -- TESTCY               = '0' & "7"
229
        -- COMPARECY    = '0' & "F"
230
        -- REGBANK              = '1' & "B"
231
        -- OUTPUTK              = '1' & "5"
232
        -- CALL@                = '1' & "2"
233
        -- LOAD&RETURN  = '1' & "0"
234
        -- HWBUILD              = '0' & "A"
235
 
236
        -- Wishbone instructions
237
        iWBRdSing               <=      '1' when ( iInstructionCode = '0' & x"1" ) else '0';
238
        iWBWrSing               <=      '1' when ( iInstructionCode = '0' & x"4" ) else '0';
239
        --------------------------------------------------------------------------------
240
        -- CONTROL SIGNAL
241
        --------------------------------------------------------------------------------
242
        -- Flow
243
        iIEWrite                <=      (Phase2_i and (iSetInterrupt or iReturnI));
244
        -- Banc
245
        iBancWrite              <=      (Phase2_i and (iAddSub or iLoad or iLogic or iShift or iFetch or iInput));
246
        -- Scratch
247
        iScratchWrite   <=      (Phase2_i and (iStore));
248
        -- Alu
249
        iOperationSelect        <=      "000"   when (iShift='1')                                               else
250
                                                        "001"   when (iLogic='1'        or iTest='1')           else
251
                                                        "010"   when (iAddSub='1'       or iCompare='1')        else
252
                                                        "011"   when (iLoad='1')                                                else
253
                                                        "111";
254
 
255
        -- Flags
256
        iFlagsWrite             <= (Phase2_i and (iAddSub or iCompare or iLogic or iTest or iShift));
257
        iFlagsPush              <= (Phase2_i and (IEvent_i));
258
        iFlagsPop               <= (Phase2_i and (iReturnI));
259
 
260
        --------------------------------------------------------------------------------
261
        -- Outputs
262
        --------------------------------------------------------------------------------
263
        Fetch_o                         <= iFetch                       ;
264
        Input_o                         <= iInput                       ;
265
        Ouput_o                         <= iOuput                       ;
266
        Jump_o                          <= iJump                        ;
267
        Call_o                          <= iCall                        ;
268
        Return_o                        <= iReturn                      ;
269
        ReturnI_o                       <= iReturnI                     ;
270
        IEWrite_o                       <= iIEWrite                     ;
271
        BancWrite_o                     <= iBancWrite           ;
272
        ScratchWrite_o          <= iScratchWrite        ;
273
        OperationSelect_o       <= iOperationSelect     ;
274
        FlagsWrite_o            <= iFlagsWrite          ;
275
        FlagsPush_o                     <= iFlagsPush           ;
276
        FlagsPop_o                      <= iFlagsPop            ;
277
 
278
        aaa_o                           <= iaaa                         ;
279
        kk_o                            <= ikk                          ;
280
        ss_o                            <= iss                          ;
281
        pp_o                            <= ipp                          ;
282
 
283
        SxPtr_o                         <= iSxPtr                       ;
284
        SyPtr_o                         <= iSyPtr                       ;
285
 
286
        OperandSelect_o         <= iOperandSelect       ;
287
 
288
        ArithOper_o                     <= iArithOper           ;
289
        LogicOper_o                     <= iLogicOper           ;
290
        ShiftBit_o                      <= iShiftBit            ;
291
        ShiftSens_o                     <= iShiftSens           ;
292
 
293
        ConditionCtrl_o         <= iConditionCtrl       ;
294
 
295
        IEValue_o                       <= iIEValue                     ;
296
 
297
        wbRdSing_o                      <= iWBRdSing            ;
298
        wbWrSing_o                      <= iWBWrSing            ;
299
 
300
end rtl;

powered by: WebSVN 2.1.0

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