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

Subversion Repositories hicovec

[/] [hicovec/] [trunk/] [cpu/] [groups/] [cpu.vhd] - Blame information for rev 12

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 hmanske
------------------------------------------------------------------
2 4 hmanske
-- PROJECT:      HiCoVec (highly configurable vector processor)
3 2 hmanske
--
4
-- ENTITY:      cpu
5
--
6
-- PURPOSE:     connects components of the
7
--              scalar unit and the vector unit
8
--              
9
-- AUTHOR:      harald manske, haraldmanske@gmx.de
10
--
11
-- VERSION:     1.0
12
------------------------------------------------------------------
13
library ieee;
14
use ieee.std_logic_1164.all;
15
use ieee.std_logic_unsigned.all;
16
 
17
use work.cfg.all;
18
use work.datatypes.all;
19
 
20
entity cpu is
21
    port(
22
        clk: in std_logic;
23
        reset: in std_logic;
24
 
25
        dbg_a: out std_logic_vector(31 downto 0);
26
        dbg_x: out std_logic_vector(31 downto 0);
27
        dbg_y: out std_logic_vector(31 downto 0);
28
        dbg_ir: out std_logic_vector(31 downto 0);
29
        dbg_ic: out std_logic_vector(31 downto 0);
30
        dbg_carry: out std_logic;
31
        dbg_zero: out std_logic;
32
        dbg_ir_ready: out std_logic;
33
        dbg_halted: out std_logic;
34
 
35
        mem_data_in: in std_logic_vector(31 downto 0);
36
        mem_data_out: out std_logic_vector(31 downto 0);
37
        mem_vdata_in: in vectordata_type;
38
        mem_vdata_out: out vectordata_type;
39
        mem_address: out std_logic_vector(31 downto 0);
40
        mem_access: out std_logic_vector(2 downto 0);
41
        mem_ready: in std_logic
42
     );
43
end cpu;
44
 
45
architecture rtl of cpu is
46
    component controlunit
47
        port(
48
            clk:            in std_logic;
49
            ir:             in std_logic_vector(31 downto 0);
50
            reset_cpu:      in std_logic;
51
            zero:           in std_logic;
52
            carry:          in std_logic;
53
            ready:          in std_logic;
54
            access_type:    out std_logic_vector(2 downto 0);
55
            c0:             out std_logic;
56
            c1:             out std_logic;
57
            cc2:            out std_logic_vector(1 downto 0);
58
            cc4:            out std_logic_vector(1 downto 0);
59
            cc5:            out std_logic_vector(1 downto 0);
60
            c6:             out std_logic;
61
            c7:             out std_logic;
62
            c8:             out std_logic;
63
            load_ir:        out std_logic;
64
            inc_ic:         out std_logic;
65
            load_ic:        out std_logic;
66
            load_c:         out std_logic;
67
            load_z:         out std_logic;
68
            ir_ready:       out std_logic;
69
            s_ready:        out std_logic;
70
            s_fetched:      out std_logic;
71
            v_ready:        in std_logic;
72
            v_fetched:      in std_logic;
73
            v_done:         in std_logic;
74
            halted:         out std_logic
75
        );
76
    end component;
77
 
78
    component aluinputgroup
79
        port(
80
            clk:            in std_logic;
81
            memory_in:      in std_logic_vector(31 downto 0);
82
            x_in:           in std_logic_vector(31 downto 0);
83
            y_in:           in std_logic_vector(31 downto 0);
84
            a_in:           in std_logic_vector(31 downto 0);
85
            ir_out:         out std_logic_vector(31 downto 0);
86
            k_out:          out std_logic_vector(31 downto 0);
87
            vector_out:     out std_logic_vector(31 downto 0);
88
            a_out:          out std_logic_vector(31 downto 0);
89
            b_out:          out std_logic_vector(31 downto 0);
90
            sel_a:          in std_logic_vector(1 downto 0);
91
            sel_b:          in std_logic_vector(1 downto 0);
92
            sel_source_a:   in std_logic;
93
            sel_source_b:   in std_logic;
94
            load_ir:        in std_logic
95
         );
96
    end component;
97
 
98
    component alu
99
        port(
100
            a_in:       in std_logic_vector(31 downto 0);
101
            b_in:       in std_logic_vector(31 downto 0);
102
            carry_in:   in std_logic;
103
            aluop:      in std_logic_vector(3 downto 0);
104
            op_select:  in std_logic;
105
            zero_out:   out std_logic;
106
            carry_out:  out std_logic;
107
            alu_out:    out std_logic_vector(31 downto 0)
108
        );
109
    end component;
110
 
111
    component addressgroup
112
        port(
113
            clk:            in std_logic;
114
            address_in:     in std_logic_vector(31 downto 0);
115
            address_out:    out std_logic_vector(31 downto 0);
116
            ic_out:         out std_logic_vector(31 downto 0);
117
            sel_source:     in std_logic;
118
            inc:            in std_logic;
119
            load_ic:        in std_logic;
120
            reset_ic:       in std_logic
121
         );
122
    end component;
123
 
124
    component registergroup
125
        port(
126
            clk:            in std_logic;
127
            result_in:      in std_logic_vector(31 downto 0);
128
            vector_in:      in std_logic_vector(31 downto 0);
129
            ic_in:          in std_logic_vector(31 downto 0);
130
            enable_in:      in std_logic;
131
            x_out:          out std_logic_vector(31 downto 0);
132
            y_out:          out std_logic_vector(31 downto 0);
133
            a_out:          out std_logic_vector(31 downto 0);
134
            sel_source:     in std_logic_vector(1 downto 0);
135
            sel_dest:       in std_logic_vector(1 downto 0)
136
         );
137
    end component;
138
 
139
    component flaggroup
140
        port(
141
            clk:    in std_logic;
142
            c_in:   in std_logic;
143
            z_in:   in std_logic;
144
            c_out:  out std_logic;
145
            z_out:  out std_logic;
146
            load_c: in std_logic;
147
            load_z: in std_logic;
148
            sel_c:  in std_logic_vector(1 downto 0);
149
            sel_z:  in std_logic_vector(1 downto 0)
150
        );
151
    end component;
152
 
153
    component vector_controlunit
154
        port(
155
            clk:            in std_logic;
156
            ir:             in std_logic_vector(31 downto 0);
157
            load_r:         out std_logic;
158
            cc9:            out std_logic_vector(1 downto 0);
159
            c10:            out std_logic;
160
            c11:            out std_logic;
161
            c12:            out std_logic;
162
            cc13:           out std_logic_vector(1 downto 0);
163
            valu_go:        out std_logic;
164
            shuffle_go:     out std_logic;
165
            out_valid:      in std_logic;
166
            shuffle_valid:  in std_logic;
167
            ir_ready:       in std_logic;
168
            s_ready:        in std_logic;
169
            s_fetched:      in std_logic;
170
            v_ready:        out std_logic;
171
            v_fetched:      out std_logic;
172
            v_done:         out std_logic
173
        );
174
    end component;
175
 
176
    component vector_executionunit
177
        port (
178
            clk:        in std_logic;
179
            memory_in:  in vectordata_type;
180
            scalar_in:  in std_logic_vector(31 downto 0);
181
            memory_out: out vectordata_type;
182
            scalar_out: out std_logic_vector(31 downto 0);
183
            out_valid:  out std_logic;
184
            shuffle_valid: out std_logic;
185
            rrrr:       in std_logic_vector(3 downto 0);
186
            vvvv:       in std_logic_vector(3 downto 0);
187
            wwww:       in std_logic_vector(3 downto 0);
188
            k_in:       in std_logic_vector(31 downto 0);
189
            vn:         in std_logic_vector(7 downto 0);
190
            valuop:     in std_logic_vector(3 downto 0);
191
            vwidth:     in std_logic_vector(1 downto 0);
192
            load_r:     in std_logic;
193
            cc9:        in std_logic_vector(1 downto 0);
194
            c10:        in std_logic;
195
            c11:        in std_logic;
196
            c12:        in std_logic;
197
            cc13:       in std_logic_vector(1 downto 0);
198
            valu_go:    in std_logic;
199
            shuffle_go: in std_logic
200
        );
201
    end component;
202
 
203
    for controlunit_impl:           controlunit             use entity work.controlunit(rtl);
204
    for aluinputgroup_impl:         aluinputgroup           use entity work.aluinputgroup(rtl);
205
    for alu_impl:                   alu                     use entity work.alu(rtl);
206
    for addressgroup_impl:          addressgroup            use entity work.addressgroup(rtl);
207
    for registergroup_impl:         registergroup           use entity work.registergroup(rtl);
208
    for flaggroup_impl:             flaggroup               use entity work.flaggroup(rtl);
209
    for vector_controlunit_impl:    vector_controlunit      use entity work.vector_controlunit(rtl);
210
    for vector_executionunit_impl:  vector_executionunit    use entity work.vector_executionunit(rtl);
211
 
212
    -- controlunit signals
213
    signal ir:              std_logic_vector(31 downto 0);
214
    signal zero:            std_logic;
215
    signal carry:           std_logic;
216
    signal c0:              std_logic;
217
    signal c1:              std_logic;
218
    signal cc2:             std_logic_vector(1 downto 0);
219
    signal cc4:             std_logic_vector(1 downto 0);
220
    signal cc5:             std_logic_vector(1 downto 0);
221
    signal c6:              std_logic;
222
    signal c7:              std_logic;
223
    signal c8:              std_logic;
224
    signal load_ir:         std_logic;
225
    signal inc_ic:          std_logic;
226
    signal load_ic:         std_logic;
227
    signal load_c:          std_logic;
228
    signal load_z:          std_logic;
229
    signal ir_ready:        std_logic;
230
    signal s_ready:         std_logic;
231
    signal s_fetched:       std_logic;
232
    signal v_ready:         std_logic;
233
    signal v_fetched:       std_logic;
234
    signal v_done:          std_logic;
235
 
236
    -- aluinputgroup
237
    signal x:               std_logic_vector(31 downto 0);
238
    signal y:               std_logic_vector(31 downto 0);
239
    signal a:               std_logic_vector(31 downto 0);
240
    signal k_out:           std_logic_vector(31 downto 0);
241
    signal vector_out:      std_logic_vector(31 downto 0);
242
    signal alu_input_a:     std_logic_vector(31 downto 0);
243
    signal alu_input_b:     std_logic_vector(31 downto 0);
244
 
245
    -- alu signals
246
    signal aluop:           std_logic_vector(3 downto 0) ;
247
    signal zero_out:        std_logic;
248
    signal carry_out:       std_logic;
249
    signal alu_out:         std_logic_vector(31 downto 0);
250
 
251
    -- address group signals
252
    signal ic:              std_logic_vector(31 downto 0);
253
 
254
    -- register group signals
255
    signal vector_in:      std_logic_vector(31 downto 0);
256
 
257
    -- signals from instruction
258
    signal ss:              std_logic_vector(1 downto 0);
259
    signal dd:              std_logic_vector(1 downto 0);
260
    signal tt:              std_logic_vector(1 downto 0);
261
 
262
    -- vector_controlunit signals 
263
    signal load_r:          std_logic;
264
    signal cc9:             std_logic_vector(1 downto 0);
265
    signal c10:             std_logic;
266
    signal c11:             std_logic;
267
    signal c12:             std_logic;
268
    signal cc13:            std_logic_vector(1 downto 0);
269
    signal valu_go:         std_logic;
270
    signal out_valid:       std_logic;
271
    signal shuffle_go:      std_logic;
272
    signal shuffle_valid:   std_logic;
273
 
274
    -- vector_executionunit signals
275
    signal rrrr:            std_logic_vector(3 downto 0);
276
    signal vvvv:            std_logic_vector(3 downto 0);
277
    signal wwww:            std_logic_vector(3 downto 0);
278
    signal vn:              std_logic_vector(7 downto 0);
279
    signal valuop:          std_logic_vector(3 downto 0);
280
    signal vwidth:          std_logic_vector(1 downto 0);
281
 
282
begin
283
 
284
    controlunit_impl: controlunit
285
        port map (
286
            clk => clk, ir => ir, reset_cpu => reset, zero => zero, carry => carry, ready => mem_ready,
287
            access_type => mem_access, c0 => c0, c1 => c1, cc2 => cc2, cc4 => cc4, cc5 => cc5,
288
            c6 => c6, c7 => c7, c8 => c8, load_ir => load_ir, inc_ic => inc_ic, load_ic => load_ic,
289
            load_c => load_c, load_z => load_z, ir_ready => ir_ready, s_ready =>
290
            s_ready, s_fetched => s_fetched,v_ready => v_ready, v_fetched => v_fetched, v_done => v_done,
291
            halted => dbg_halted
292
        );
293
 
294
    aluinputgroup_impl: aluinputgroup
295
        port map (
296
            clk => clk, memory_in => mem_data_in, x_in => x, y_in => y, a_in => a, ir_out => ir, k_out => k_out,
297
            vector_out => vector_out, a_out => alu_input_a, b_out => alu_input_b, sel_a => ss, sel_b => tt,
298
            sel_source_a => c8, sel_source_b => c0, load_ir => load_ir
299
        );
300
 
301
    alu_impl: alu
302
        port map (
303
            a_in => alu_input_a, b_in => alu_input_b, carry_in => carry, aluop => aluop,
304
            op_select => c7, carry_out => carry_out, zero_out => zero_out, alu_out => alu_out
305
        );
306
 
307
    addressgroup_impl: addressgroup
308
        port map (
309
            clk => clk, address_in => alu_out, address_out => mem_address, ic_out => ic, sel_source => c1,
310
            inc => inc_ic, load_ic => load_ic, reset_ic => reset
311
        );
312
 
313
    registergroup_impl: registergroup
314
        port map (
315
            clk => clk, result_in => alu_out, vector_in => vector_in,
316
            ic_in => ic, enable_in => c6,  x_out => x, y_out => y, a_out => a,
317
            sel_source => cc2, sel_dest => dd
318
        );
319
 
320
    flaggroup_impl: flaggroup
321
        port map (
322
            clk => clk, c_in => carry_out, z_in => zero_out, c_out => carry,
323
            z_out => zero, load_c => load_c, load_z => load_z, sel_c => cc5, sel_z => cc4
324
        );
325
 
326
    vector_controlunit_impl: vector_controlunit
327
        port map (
328
            clk => clk, ir => ir, load_r => load_r, cc9 => cc9, c10 => c10, c11 => c11,
329
            c12 => c12, cc13 => cc13, valu_go => valu_go, shuffle_go => shuffle_go, out_valid => out_valid,
330
            shuffle_valid => shuffle_valid, ir_ready => ir_ready, s_ready => s_ready, s_fetched => s_fetched,
331
            v_ready => v_ready, v_fetched => v_fetched, v_done => v_done
332
        );
333
 
334
    vector_executionunit_impl: vector_executionunit
335
        port map (
336
            clk => clk, memory_in => mem_vdata_in, scalar_in => vector_out, memory_out => mem_vdata_out,
337
            scalar_out => vector_in, out_valid => out_valid, shuffle_valid => shuffle_valid, rrrr => rrrr,
338
            vvvv => vvvv, wwww => wwww, k_in => k_out, vn => vn, valuop => valuop, vwidth => vwidth,
339
            load_r => load_r, cc9 => cc9, c10 => c10, c11 => c11, c12 => c12, cc13 => cc13, valu_go => valu_go,
340
            shuffle_go => shuffle_go
341
        );
342
 
343
    -- from ir derived signals
344
    dd <= ir (25 downto 24);
345
    ss <= ir (23 downto 22);
346
    tt <= ir (21 downto 20);
347
    aluop <= ir (29 downto 26);
348
    rrrr <= ir (11 downto 8);
349
    vvvv <= ir (7 downto 4);
350
    wwww <= ir (3 downto 0);
351
    vn <= ir (27 downto 20);
352
    valuop <= ir (15 downto 12);
353
    vwidth <= ir (17 downto 16);
354
 
355
    -- memory interfaces signals
356
    mem_data_out <= a;
357
 
358
    -- debugging signals
359
    dbg_a <= a;
360
    dbg_x <= x;
361
    dbg_y <= y;
362
    dbg_ir <= ir;
363
    dbg_ic <= ic;
364
    dbg_carry <= carry;
365
    dbg_zero <= zero;
366
    dbg_ir_ready <= ir_ready;
367
 
368
end;

powered by: WebSVN 2.1.0

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