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

Subversion Repositories mblite

[/] [mblite/] [trunk/] [hw/] [core/] [core_Pkg.vhd] - Blame information for rev 2

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

Line No. Rev Author Line
1 2 takar
----------------------------------------------------------------------------------------------
2
--
3
--      Input file         : core_Pkg.vhd
4
--      Design name        : core_Pkg
5
--      Author             : Tamar Kranenburg
6
--      Company            : Delft University of Technology
7
--                         : Faculty EEMCS, Department ME&CE
8
--                         : Systems and Circuits group
9
--
10
--      Description        : Package with components and type definitions for the interface
11
--                           of the components
12
--
13
--
14
----------------------------------------------------------------------------------------------
15
 
16
LIBRARY ieee;
17
USE ieee.std_logic_1164.ALL;
18
USE ieee.std_logic_unsigned.ALL;
19
 
20
LIBRARY mblite;
21
USE mblite.config_Pkg.ALL;
22
USE mblite.std_Pkg.ALL;
23
 
24
PACKAGE core_Pkg IS
25
 
26
----------------------------------------------------------------------------------------------
27
-- TYPES USED IN MB-LITE
28
----------------------------------------------------------------------------------------------
29
 
30
    TYPE alu_operation     IS (ALU_ADD, ALU_OR, ALU_AND, ALU_XOR, ALU_SHIFT, ALU_SEXT8, ALU_SEXT16, ALU_MUL, ALU_BS);
31
    TYPE src_type_a        IS (ALU_SRC_REGA, ALU_SRC_NOT_REGA, ALU_SRC_PC, ALU_SRC_ZERO);
32
    TYPE src_type_b        IS (ALU_SRC_REGB, ALU_SRC_NOT_REGB, ALU_SRC_IMM, ALU_SRC_NOT_IMM);
33
    TYPE carry_type        IS (CARRY_ZERO, CARRY_ONE, CARRY_ALU, CARRY_ARITH);
34
    TYPE carry_keep_type   IS (CARRY_NOT_KEEP, CARRY_KEEP);
35
    TYPE branch_condition  IS (NOP, BNC, BEQ, BNE, BLT, BLE, BGT, BGE);
36
    TYPE transfer_size     IS (WORD, HALFWORD, BYTE);
37
 
38
    TYPE ctrl_execution IS RECORD
39
        alu_op      : alu_operation;
40
        alu_src_a   : src_type_a;
41
        alu_src_b   : src_type_b;
42
        operation   : std_ulogic;
43
        carry       : carry_type;
44
        carry_keep  : carry_keep_type;
45
        branch_cond : branch_condition;
46
        delay       : std_ulogic;
47
    END RECORD;
48
 
49
    TYPE ctrl_memory IS RECORD
50
        mem_write     : std_ulogic;
51
        mem_read      : std_ulogic;
52
        transfer_size : transfer_size;
53
    END RECORD;
54
 
55
    TYPE ctrl_memory_writeback_type IS RECORD
56
        mem_read      : std_ulogic;
57
        transfer_size : transfer_size;
58
    END RECORD;
59
 
60
    TYPE forward_type IS RECORD
61
        reg_d     : std_ulogic_vector(CFG_GPRF_SIZE - 1 DOWNTO 0);
62
        reg_write : std_ulogic;
63
    END RECORD;
64
 
65
    TYPE imem_in_type IS RECORD
66
        dat_i : std_ulogic_vector(CFG_IMEM_WIDTH - 1 DOWNTO 0);
67
    END RECORD;
68
 
69
    TYPE imem_out_type IS RECORD
70
        adr_o : std_ulogic_vector(CFG_IMEM_SIZE - 1 DOWNTO 0);
71
        ena_o : std_ulogic;
72
    END RECORD;
73
 
74
    TYPE fetch_in_type IS RECORD
75
        hazard : std_ulogic;
76
        branch : std_ulogic;
77
        branch_target : std_ulogic_vector(CFG_IMEM_SIZE - 1 DOWNTO 0);
78
    END RECORD;
79
 
80
    TYPE fetch_out_type IS RECORD
81
        program_counter : std_ulogic_vector(CFG_IMEM_SIZE - 1 DOWNTO 0);
82
    END RECORD;
83
 
84
    TYPE gprf_out_type IS RECORD
85
        dat_a_o : std_ulogic_vector(CFG_DMEM_WIDTH - 1 DOWNTO 0);
86
        dat_b_o : std_ulogic_vector(CFG_DMEM_WIDTH - 1 DOWNTO 0);
87
        dat_d_o : std_ulogic_vector(CFG_DMEM_WIDTH - 1 DOWNTO 0);
88
    END RECORD;
89
 
90
    TYPE decode_in_type IS RECORD
91
        program_counter : std_ulogic_vector(CFG_IMEM_SIZE - 1 DOWNTO 0);
92
        instruction     : std_ulogic_vector(CFG_IMEM_WIDTH - 1 DOWNTO 0);
93
        ctrl_wb         : forward_type;
94
        ctrl_mem_wb     : ctrl_memory_writeback_type;
95
        mem_result      : std_ulogic_vector(CFG_DMEM_WIDTH - 1 DOWNTO 0);
96
        alu_result      : std_ulogic_vector(CFG_DMEM_WIDTH - 1 DOWNTO 0);
97
        interrupt       : std_ulogic;
98
        flush_id        : std_ulogic;
99
    END RECORD;
100
 
101
    TYPE decode_out_type IS RECORD
102
        reg_a           : std_ulogic_vector(CFG_GPRF_SIZE - 1 DOWNTO 0);
103
        reg_b           : std_ulogic_vector(CFG_GPRF_SIZE - 1 DOWNTO 0);
104
        imm             : std_ulogic_vector(CFG_DMEM_WIDTH - 1 DOWNTO 0);
105
        program_counter : std_ulogic_vector(CFG_IMEM_SIZE - 1 DOWNTO 0);
106
        hazard          : std_ulogic;
107
        ctrl_ex         : ctrl_execution;
108
        ctrl_mem        : ctrl_memory;
109
        ctrl_wb         : forward_type;
110
        fwd_dec_result  : std_ulogic_vector(CFG_DMEM_WIDTH - 1 DOWNTO 0);
111
        fwd_dec         : forward_type;
112
    END RECORD;
113
 
114
    TYPE gprf_in_type IS RECORD
115
        adr_a_i : std_ulogic_vector(CFG_GPRF_SIZE - 1 DOWNTO 0);
116
        adr_b_i : std_ulogic_vector(CFG_GPRF_SIZE - 1 DOWNTO 0);
117
        adr_d_i : std_ulogic_vector(CFG_GPRF_SIZE - 1 DOWNTO 0);
118
        dat_w_i : std_ulogic_vector(CFG_DMEM_WIDTH - 1 DOWNTO 0);
119
        adr_w_i : std_ulogic_vector(CFG_GPRF_SIZE - 1 DOWNTO 0);
120
        wre_i   : std_ulogic;
121
    END RECORD;
122
 
123
    TYPE execute_out_type IS RECORD
124
        alu_result      : std_ulogic_vector(CFG_DMEM_WIDTH - 1 DOWNTO 0);
125
        dat_d           : std_ulogic_vector(CFG_DMEM_WIDTH - 1 DOWNTO 0);
126
        branch          : std_ulogic;
127
        program_counter : std_ulogic_vector(CFG_IMEM_SIZE - 1 DOWNTO 0);
128
        flush_id        : std_ulogic;
129
        ctrl_mem        : ctrl_memory;
130
        ctrl_wb         : forward_type;
131
    END RECORD;
132
 
133
    TYPE execute_in_type IS RECORD
134
        reg_a           : std_ulogic_vector(CFG_GPRF_SIZE  - 1 DOWNTO 0);
135
        dat_a           : std_ulogic_vector(CFG_DMEM_WIDTH - 1 DOWNTO 0);
136
        reg_b           : std_ulogic_vector(CFG_GPRF_SIZE  - 1 DOWNTO 0);
137
        dat_b           : std_ulogic_vector(CFG_DMEM_WIDTH - 1 DOWNTO 0);
138
        dat_d           : std_ulogic_vector(CFG_DMEM_WIDTH - 1 DOWNTO 0);
139
        imm             : std_ulogic_vector(CFG_DMEM_WIDTH - 1 DOWNTO 0);
140
        program_counter : std_ulogic_vector(CFG_IMEM_SIZE - 1 DOWNTO 0);
141
        fwd_dec         : forward_type;
142
        fwd_dec_result  : std_ulogic_vector(CFG_DMEM_WIDTH - 1 DOWNTO 0);
143
        fwd_mem         : forward_type;
144
        ctrl_ex         : ctrl_execution;
145
        ctrl_mem        : ctrl_memory;
146
        ctrl_wb         : forward_type;
147
        ctrl_mem_wb     : ctrl_memory_writeback_type;
148
        mem_result      : std_ulogic_vector(CFG_DMEM_WIDTH - 1 DOWNTO 0);
149
        alu_result      : std_ulogic_vector(CFG_DMEM_WIDTH - 1 DOWNTO 0);
150
 
151
    END RECORD;
152
 
153
    TYPE mem_in_type IS RECORD
154
        dat_d           : std_ulogic_vector(CFG_DMEM_WIDTH - 1 DOWNTO 0);
155
        alu_result      : std_ulogic_vector(CFG_DMEM_WIDTH - 1 DOWNTO 0);
156
        mem_result      : std_ulogic_vector(CFG_DMEM_WIDTH - 1 DOWNTO 0);
157
        program_counter : std_ulogic_vector(CFG_IMEM_SIZE - 1 DOWNTO 0);
158
        branch          : std_ulogic;
159
        ctrl_mem        : ctrl_memory;
160
        ctrl_wb         : forward_type;
161
    END RECORD;
162
 
163
    TYPE mem_out_type IS RECORD
164
        alu_result  : std_ulogic_vector(CFG_DMEM_WIDTH - 1 DOWNTO 0);
165
        ctrl_wb     : forward_type;
166
        ctrl_mem_wb : ctrl_memory_writeback_type;
167
    END RECORD;
168
 
169
    TYPE dmem_in_type IS RECORD
170
        dat_i : std_ulogic_vector(CFG_DMEM_WIDTH - 1 DOWNTO 0);
171
        ena_i : std_ulogic;
172
    END RECORD;
173
 
174
    TYPE dmem_out_type IS RECORD
175
        dat_o : std_ulogic_vector(CFG_DMEM_WIDTH - 1 DOWNTO 0);
176
        adr_o : std_ulogic_vector(CFG_DMEM_SIZE - 1 DOWNTO 0);
177
        sel_o : std_ulogic_vector(3 DOWNTO 0);
178
        we_o  : std_ulogic;
179
        ena_o : std_ulogic;
180
    END RECORD;
181
 
182
    TYPE dmem_in_array_type IS ARRAY(NATURAL RANGE <>) OF dmem_in_type;
183
    TYPE dmem_out_array_type IS ARRAY(NATURAL RANGE <>) OF dmem_out_type;
184
 
185
    -- WB-master inputs from the wb-slaves
186
    TYPE wb_mst_in_type IS RECORD
187
        clk_i : std_ulogic;                      -- master clock input
188
        rst_i : std_ulogic;                      -- synchronous active high reset
189
        dat_i : std_ulogic_vector(CFG_DMEM_WIDTH - 1 DOWNTO 0); -- databus input
190
        ack_i : std_ulogic;                      -- buscycle acknowledge input
191
        int_i : std_ulogic;                      -- interrupt request input
192
    END RECORD;
193
 
194
    -- WB-master outputs to the wb-slaves
195
    TYPE wb_mst_out_type IS RECORD
196
        adr_o : std_ulogic_vector(CFG_DMEM_SIZE - 1 DOWNTO 0);  -- address bits
197
        dat_o : std_ulogic_vector(CFG_DMEM_WIDTH - 1 DOWNTO 0); -- databus output
198
        we_o  : std_ulogic;                      -- write enable output
199
        stb_o : std_ulogic;                      -- strobe signals
200
        sel_o : std_ulogic_vector(3 DOWNTO 0);   -- select output array
201
        cyc_o : std_ulogic;                      -- valid BUS cycle output
202
    END RECORD;
203
 
204
    -- WB-slave inputs, from the WB-master
205
    TYPE wb_slv_in_type IS RECORD
206
        clk_i : std_ulogic;                     -- master clock input
207
        rst_i : std_ulogic;                     -- synchronous active high reset
208
        adr_i : std_ulogic_vector(CFG_DMEM_SIZE - 1 DOWNTO 0); -- address bits
209
        dat_i : std_ulogic_vector(CFG_DMEM_WIDTH - 1 DOWNTO 0); -- Databus input
210
        we_i  : std_ulogic;                     -- Write enable input
211
        stb_i : std_ulogic;                     -- strobe signals / core select signal
212
        sel_i : std_ulogic_vector(3 DOWNTO 0);   -- select output array
213
        cyc_i : std_ulogic;                     -- valid BUS cycle input
214
    END RECORD;
215
 
216
    -- WB-slave outputs to the WB-master
217
    TYPE wb_slv_out_type IS RECORD
218
        dat_o : std_ulogic_vector(CFG_DMEM_WIDTH - 1 DOWNTO 0); -- Databus output
219
        ack_o : std_ulogic;                     -- Bus cycle acknowledge output
220
        int_o : std_ulogic;                     -- interrupt request output
221
    END RECORD;
222
 
223
----------------------------------------------------------------------------------------------
224
-- COMPONENTS USED IN MB-LITE
225
----------------------------------------------------------------------------------------------
226
 
227
    COMPONENT core GENERIC
228
    (
229
        G_INTERRUPT  : boolean := CFG_INTERRUPT;
230
        G_USE_HW_MUL : boolean := CFG_USE_HW_MUL;
231
        G_USE_BARREL : boolean := CFG_USE_BARREL;
232
        G_DEBUG      : boolean := CFG_DEBUG
233
    );
234
    PORT
235
    (
236
        imem_o : OUT imem_out_type;
237
        dmem_o : OUT dmem_out_type;
238
        imem_i : IN imem_in_type;
239
        dmem_i : IN dmem_in_type;
240
        int_i  : IN std_ulogic;
241
        rst_i  : IN std_ulogic;
242
        clk_i  : IN std_ulogic
243
    );
244
    END COMPONENT;
245
 
246
    COMPONENT core_wb GENERIC
247
    (
248
        G_INTERRUPT  : boolean := CFG_INTERRUPT;
249
        G_USE_HW_MUL : boolean := CFG_USE_HW_MUL;
250
        G_USE_BARREL : boolean := CFG_USE_BARREL;
251
        G_DEBUG      : boolean := CFG_DEBUG
252
    );
253
    PORT
254
    (
255
        imem_o : OUT imem_out_type;
256
        wb_o   : OUT wb_mst_out_type;
257
        imem_i : IN imem_in_type;
258
        wb_i   : IN wb_mst_in_type
259
    );
260
    END COMPONENT;
261
 
262
    COMPONENT core_wb_adapter PORT
263
    (
264
        dmem_i : OUT dmem_in_type;
265
        wb_o   : OUT wb_mst_out_type;
266
        dmem_o : IN dmem_out_type;
267
        wb_i   : IN wb_mst_in_type
268
    );
269
    END COMPONENT;
270
 
271
    COMPONENT core_wb_async_adapter PORT
272
    (
273
        dmem_i : OUT dmem_in_type;
274
        wb_o   : OUT wb_mst_out_type;
275
        dmem_o : IN dmem_out_type;
276
        wb_i   : IN wb_mst_in_type
277
    );
278
    END COMPONENT;
279
 
280
    COMPONENT fetch PORT
281
    (
282
        fetch_o : OUT fetch_out_type;
283
        imem_o  : OUT imem_out_type;
284
        fetch_i : IN fetch_in_type;
285
        rst_i   : IN std_ulogic;
286
        ena_i   : IN std_ulogic;
287
        clk_i   : IN std_ulogic
288
    );
289
    END COMPONENT;
290
 
291
    COMPONENT decode GENERIC
292
    (
293
        G_INTERRUPT  : boolean := CFG_INTERRUPT;
294
        G_USE_HW_MUL : boolean := CFG_USE_HW_MUL;
295
        G_USE_BARREL : boolean := CFG_USE_BARREL;
296
        G_DEBUG      : boolean := CFG_DEBUG
297
    );
298
    PORT
299
    (
300
        decode_o : OUT decode_out_type;
301
        gprf_o   : OUT gprf_out_type;
302
        decode_i : IN decode_in_type;
303
        ena_i    : IN std_ulogic;
304
        rst_i    : IN std_ulogic;
305
        clk_i    : IN std_ulogic
306
    );
307
    END COMPONENT;
308
 
309
    COMPONENT gprf PORT
310
    (
311
        gprf_o : OUT gprf_out_type;
312
        gprf_i : IN gprf_in_type;
313
        ena_i  : IN std_ulogic;
314
        clk_i  : IN std_ulogic
315
    );
316
    END COMPONENT;
317
 
318
    COMPONENT execute GENERIC
319
    (
320
        G_USE_HW_MUL : boolean := CFG_USE_HW_MUL;
321
        G_USE_BARREL : boolean := CFG_USE_BARREL
322
    );
323
    PORT
324
    (
325
        exec_o : OUT execute_out_type;
326
        exec_i : IN execute_in_type;
327
        ena_i  : IN std_ulogic;
328
        rst_i  : IN std_ulogic;
329
        clk_i  : IN std_ulogic
330
    );
331
    END COMPONENT;
332
 
333
    COMPONENT mem PORT
334
    (
335
        mem_o  : OUT mem_out_type;
336
        dmem_o : OUT dmem_out_type;
337
        mem_i  : IN mem_in_type;
338
        ena_i  : IN std_ulogic;
339
        rst_i  : IN std_ulogic;
340
        clk_i  : IN std_ulogic
341
    );
342
    END COMPONENT;
343
 
344
    COMPONENT core_address_decoder GENERIC
345
    (
346
        G_NUM_SLAVES : positive := CFG_NUM_SLAVES
347
    );
348
    PORT
349
    (
350
        m_dmem_i : OUT dmem_in_type;
351
        s_dmem_o : OUT dmem_out_array_type;
352
        m_dmem_o : IN dmem_out_type;
353
        s_dmem_i : IN dmem_in_array_type;
354
        clk_i    : IN std_ulogic
355
    );
356
    END COMPONENT;
357
----------------------------------------------------------------------------------------------
358
-- FUNCTIONS USED IN MB-LITE
359
----------------------------------------------------------------------------------------------
360
 
361
    FUNCTION select_register_data(reg_dat, reg, wb_dat : std_ulogic_vector; write : std_ulogic) RETURN std_ulogic_vector;
362
    FUNCTION forward_condition(reg_write : std_ulogic; reg_a, reg_d : std_ulogic_vector) RETURN std_ulogic;
363
    FUNCTION align_mem_load(data : std_ulogic_vector; size : transfer_size; address : std_ulogic_vector) RETURN std_ulogic_vector;
364
    FUNCTION align_mem_store(data : std_ulogic_vector; size : transfer_size) RETURN std_ulogic_vector;
365
    FUNCTION decode_mem_store(address : std_ulogic_vector(1 DOWNTO 0); size : transfer_size) RETURN std_ulogic_vector;
366
 
367
END core_Pkg;
368
 
369
PACKAGE BODY core_Pkg IS
370
 
371
    -- This function select the register value:
372
    --      A) zero
373
    --      B) bypass value read from register file
374
    --      C) value from register file
375
    FUNCTION select_register_data(reg_dat, reg, wb_dat : std_ulogic_vector; write : std_ulogic) RETURN std_ulogic_vector IS
376
        VARIABLE tmp : std_ulogic_vector(CFG_DMEM_WIDTH - 1 DOWNTO 0);
377
    BEGIN
378
        IF CFG_REG_FORCE_ZERO = true AND is_zero(reg) = '1' THEN
379
            tmp := (OTHERS => '0');
380
        ELSIF CFG_REG_FWD_WB = true AND write = '1' THEN
381
            tmp := wb_dat;
382
        ELSE
383
            tmp := reg_dat;
384
        END IF;
385
        RETURN tmp;
386
    END select_register_data;
387
 
388
    -- This function checks if a forwarding condition is met. The condition is met of register A and D match
389
    -- and the signal needs to be written back to the register file.
390
    FUNCTION forward_condition(reg_write : std_ulogic; reg_a, reg_d : std_ulogic_vector ) RETURN std_ulogic IS
391
    BEGIN
392
        RETURN reg_write AND compare(reg_a, reg_d);
393
    END forward_condition;
394
 
395
    -- This function aligns the memory load operation. The load byte-order is defined here.
396
    FUNCTION align_mem_load(data : std_ulogic_vector; size : transfer_size; address : std_ulogic_vector ) RETURN std_ulogic_vector IS
397
    BEGIN
398
        IF CFG_BYTE_ORDER = false THEN
399
            -- Little endian decoding
400
            CASE size IS
401
                WHEN byte =>
402
                    CASE address(1 DOWNTO 0) IS
403
                        WHEN "00"   => RETURN "000000000000000000000000" & data(CFG_DMEM_WIDTH/4 - 1 DOWNTO 0);
404
                        WHEN "01"   => RETURN "000000000000000000000000" & data(CFG_DMEM_WIDTH/2 - 1 DOWNTO CFG_DMEM_WIDTH/4);
405
                        WHEN "10"   => RETURN "000000000000000000000000" & data(3*CFG_DMEM_WIDTH/4 - 1 DOWNTO CFG_DMEM_WIDTH/2);
406
                        WHEN "11"   => RETURN "000000000000000000000000" & data(CFG_DMEM_WIDTH - 1 DOWNTO 3*CFG_DMEM_WIDTH/4);
407
                        WHEN OTHERS => RETURN "00000000000000000000000000000000";
408
                    END CASE;
409
                WHEN halfword =>
410
                    CASE address(1 DOWNTO 0) IS
411
                        WHEN "00"   => RETURN "0000000000000000" & data(CFG_DMEM_WIDTH/2 - 1 DOWNTO 0);
412
                        WHEN "10"   => RETURN "0000000000000000" & data(CFG_DMEM_WIDTH - 1 DOWNTO CFG_DMEM_WIDTH/2);
413
                        WHEN OTHERS => RETURN "00000000000000000000000000000000";
414
                    END CASE;
415
                WHEN OTHERS =>
416
                    RETURN data;
417
            END CASE;
418
        ELSE
419
            -- Big endian decoding
420
            CASE size IS
421
                WHEN byte =>
422
                    CASE address(1 DOWNTO 0) IS
423
                        WHEN "00"   => RETURN "000000000000000000000000" & data(CFG_DMEM_WIDTH - 1 DOWNTO 3*CFG_DMEM_WIDTH/4);
424
                        WHEN "01"   => RETURN "000000000000000000000000" & data(3*CFG_DMEM_WIDTH/4 - 1 DOWNTO CFG_DMEM_WIDTH/2);
425
                        WHEN "10"   => RETURN "000000000000000000000000" & data(CFG_DMEM_WIDTH/2 - 1 DOWNTO CFG_DMEM_WIDTH/4);
426
                        WHEN "11"   => RETURN "000000000000000000000000" & data(CFG_DMEM_WIDTH/4 - 1 DOWNTO 0);
427
                        WHEN OTHERS => RETURN "00000000000000000000000000000000";
428
                    END CASE;
429
                WHEN halfword =>
430
                    CASE address(1 DOWNTO 0) IS
431
                        WHEN "00"   => RETURN "0000000000000000" & data(CFG_DMEM_WIDTH - 1 DOWNTO CFG_DMEM_WIDTH/2);
432
                        WHEN "10"   => RETURN "0000000000000000" & data(CFG_DMEM_WIDTH/2 - 1 DOWNTO 0);
433
                        WHEN OTHERS => RETURN "00000000000000000000000000000000";
434
                    END CASE;
435
                WHEN OTHERS =>
436
                    RETURN data;
437
            END CASE;
438
        END IF;
439
    END align_mem_load;
440
 
441
    -- This function repeats the operand to all positions memory store operation.
442
    FUNCTION align_mem_store(data : std_ulogic_vector; size : transfer_size) RETURN std_ulogic_vector IS
443
    BEGIN
444
        CASE size IS
445
            WHEN byte     => RETURN data( 7 DOWNTO 0) & data( 7 DOWNTO 0) & data(7 DOWNTO 0) & data(7 DOWNTO 0);
446
            WHEN halfword => RETURN data(15 DOWNTO 0) & data(15 DOWNTO 0);
447
            WHEN OTHERS   => RETURN data;
448
        END CASE;
449
    END align_mem_store;
450
 
451
    -- This function selects the correct bytes for memory writes. The store byte-order (MSB / LSB) can be defined here.
452
    FUNCTION decode_mem_store(address : std_ulogic_vector(1 DOWNTO 0); size : transfer_size) RETURN std_ulogic_vector IS
453
    BEGIN
454
        IF CFG_BYTE_ORDER = false THEN
455
            -- Little endian encoding
456
            CASE size IS
457
                WHEN BYTE =>
458
                    CASE address IS
459
                        WHEN "00"   => RETURN "0001";
460
                        WHEN "01"   => RETURN "0010";
461
                        WHEN "10"   => RETURN "0100";
462
                        WHEN "11"   => RETURN "1000";
463
                        WHEN OTHERS => RETURN "0000";
464
                    END CASE;
465
                WHEN HALFWORD =>
466
                    CASE address IS
467
                        WHEN "00"   => RETURN "0011";
468
                        WHEN "10"   => RETURN "1100";
469
                        WHEN OTHERS => RETURN "0000";
470
                    END CASE;
471
                WHEN OTHERS =>
472
                    RETURN "1111";
473
            END CASE;
474
        ELSE
475
            -- Big endian encoding
476
            CASE size IS
477
                WHEN BYTE =>
478
                    CASE address IS
479
                        WHEN "00"   => RETURN "1000";
480
                        WHEN "01"   => RETURN "0100";
481
                        WHEN "10"   => RETURN "0010";
482
                        WHEN "11"   => RETURN "0001";
483
                        WHEN OTHERS => RETURN "0000";
484
                    END CASE;
485
                WHEN HALFWORD =>
486
                    CASE address IS
487
                        -- Big endian encoding
488
                        WHEN "10"   => RETURN "0011";
489
                        WHEN "00"   => RETURN "1100";
490
                        WHEN OTHERS => RETURN "0000";
491
                    END CASE;
492
                WHEN OTHERS =>
493
                    RETURN "1111";
494
            END CASE;
495
        END IF;
496
    END decode_mem_store;
497
 
498
END core_Pkg;

powered by: WebSVN 2.1.0

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