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

Subversion Repositories plasma_fpu

[/] [plasma_fpu/] [trunk/] [src/] [plasma_pack.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 __alexs__
-- --------------------------------------------------------------------------
2
-- >>>>>>>>>>>>>>>>>>>>>>>>>>>> COPYRIGHT NOTICE <<<<<<<<<<<<<<<<<<<<<<<<<<<<
3
-- --------------------------------------------------------------------------
4
-- TITLE:       Plasma Misc. Package
5
-- AUTHOR:      Alex Schoenberger (Alex.Schoenberger@ies.tu-darmstadt.de)
6
--
7
-- www.ies.tu-darmstadt.de
8
-- TU Darmstadt
9
-- Institute for Integrated Systems
10
-- Merckstr. 25
11
-- 
12
-- 64283 Darmstadt - GERMANY
13
-- --------------------------------------------------------------------------
14
-- PROJECT:       Plasma CPU core with FPU
15
-- FILENAME:      plasma_pack.vhd
16
-- --------------------------------------------------------------------------
17
-- COPYRIGHT: 
18
--  This project is distributed by GPLv2.0
19
--  Software placed into the public domain by the author.
20
--  Software 'as is' without warranty.  Author liable for nothing.
21
-- --------------------------------------------------------------------------
22
-- DESCRIPTION:
23
--    constants, file types, ports and debugging signals for main core
24
----------------------------------------------------------------------------
25
-- Revision History
26
-- --------------------------------------------------------------------------
27
-- Revision   Date    Author     CHANGES
28
-- 1.0      4/2014    AS         initial
29
-- --------------------------------------------------------------------------
30
library IEEE;
31
  use IEEE.std_logic_1164.ALL;
32
  use IEEE.numeric_std.ALL;
33
 
34
--pragma translate_off
35
   use IEEE.std_logic_textIO.ALL;
36
 
37
library STD;
38
  use STD.textio.ALL;
39
--pragma translate_on
40
 
41
library PLASMA;
42
  use PLASMA.mips_instruction_set.ALL;
43
 
44
package plasma_pack is
45
  -- ------------------------------------------------------------------------------------------------------------------
46
  --   _____ ______ _   _ ______ _____            _         _____ ____  _   _  _____ _______       _   _ _______ _____ 
47
  --  / ____|  ____| \ | |  ____|  __ \     /\   | |       / ____/ __ \| \ | |/ ____|__   __|/\   | \ | |__   __/ ____|
48
  -- | |  __| |__  |  \| | |__  | |__) |   /  \  | |      | |   | |  | |  \| | (___    | |  /  \  |  \| |  | | | (___  
49
  -- | | |_ |  __| | . ` |  __| |  _  /   / /\ \ | |      | |   | |  | | . ` |\___ \   | | / /\ \ | . ` |  | |  \___ \ 
50
  -- | |__| | |____| |\  | |____| | \ \  / ____ \| |____  | |___| |__| | |\  |____) |  | |/ ____ \| |\  |  | |  ____) |
51
  --  \_____|______|_| \_|______|_|  \_\/_/    \_\______|  \_____\____/|_| \_|_____/   |_/_/    \_\_| \_|  |_| |_____/ 
52
  -- ------------------------------------------------------------------------------------------------------------------
53
  --
54
  -- DATA AND ADDRESS WIDTH 
55
  --
56
  constant PLASMA_DATA_WIDTH              : natural         := 32;                    -- data width
57
  constant PLASMA_ADDR_WIDTH              : natural         := PLASMA_DATA_WIDTH;     -- address width equal data width
58
 
59
  --
60
  -- REGISTERS 
61
  --
62
  constant PLASMA_REG_ADDR_WIDTH          : natural         := 5;                     -- 2**5 = 32 registers
63
 
64
  --
65
  -- MEMORY
66
  --
67
  constant PLASMA_MEM_CELL_WIDTH          : natural         := 8;                     -- width of memory cell
68
 
69
  -- ------------------------------------------------------------------------------------------------------------------
70
  --  __  __ _____ _____   _____       _____ ____  _   _  _____ _______       _   _ _______ _____ 
71
  -- |  \/  |_   _|  __ \ / ____|     / ____/ __ \| \ | |/ ____|__   __|/\   | \ | |__   __/ ____|
72
  -- | \  / | | | | |__) | (___      | |   | |  | |  \| | (___    | |  /  \  |  \| |  | | | (___  
73
  -- | |\/| | | | |  ___/ \___ \     | |   | |  | | . ` |\___ \   | | / /\ \ | . ` |  | |  \___ \ 
74
  -- | |  | |_| |_| |     ____) |    | |___| |__| | |\  |____) |  | |/ ____ \| |\  |  | |  ____) |
75
  -- |_|  |_|_____|_|    |_____/      \_____\____/|_| \_|_____/   |_/_/    \_\_| \_|  |_| |_____/ 
76
  -- ------------------------------------------------------------------------------------------------------------------
77
  --
78
  -- SHIFTER WIDTH
79
  --
80
  constant PLASMA_SHIFTER_WIDTH           : natural         := 5;                     -- 2**5 = 32 is maximal number of possible shifts
81
 
82
  --
83
  -- READ/WRITE MASK
84
  --
85
  constant PLASMA_MASK_WIDTH              : natural         := 4;                     -- maks for byte, short und int
86
 
87
  -- ------------------------------------------------------------------------------------------------------------------
88
  ---  _____ ______ _   _ ______ _____            _        _________     _______  ______  _____ 
89
  --  / ____|  ____| \ | |  ____|  __ \     /\   | |      |__   __\ \   / /  __ \|  ____|/ ____|
90
  -- | |  __| |__  |  \| | |__  | |__) |   /  \  | |         | |   \ \_/ /| |__) | |__  | (___  
91
  -- | | |_ |  __| | . ` |  __| |  _  /   / /\ \ | |         | |    \   / |  ___/|  __|  \___ \ 
92
  -- | |__| | |____| |\  | |____| | \ \  / ____ \| |____     | |     | |  | |    | |____ ____) |
93
  --  \_____|______|_| \_|______|_|  \_\/_/    \_\______|    |_|     |_|  |_|    |______|_____/ 
94
  -- ------------------------------------------------------------------------------------------------------------------
95
  --
96
  -- MAIN DATA TYPE
97
  --
98
  subtype t_plasma_word                   is  std_logic_vector(PLASMA_DATA_WIDTH  - 1 downto 0);
99
  subtype t_plasma_dword                  is  std_logic_vector(2*PLASMA_DATA_WIDTH- 1 downto 0);
100
 
101
  --
102
  -- REGISTER BANK
103
  --
104
  type t_reg_bank                         is  array(2**PLASMA_REG_ADDR_WIDTH      - 1 downto 0)  of  t_plasma_word;
105
  type t_reg_addr is
106
    record
107
      we                                  : std_logic;                -- write enable
108
      rs                                  : t_mips_reg_addr;          -- 1. operand address
109
      rt                                  : t_mips_reg_addr;          -- 2. operand address
110
      rd                                  : t_mips_reg_addr;          -- destinationa address
111
    end record;
112
 
113
  --
114
  -- memory
115
  --
116
  subtype t_plasma_mem_word               is std_logic_vector(PLASMA_MEM_CELL_WIDTH    - 1 downto 0);
117
 
118
  --
119
  -- MASK FOR BYTE, SHORT AND INT
120
  --
121
  subtype t_plasma_mask                   is std_logic_vector(PLASMA_MASK_WIDTH   - 1 downto 0);
122
 
123
  -- ____ ___ ____ _    _       _    ____ ____ _ ____ 
124
  -- [__   |  |__| |    |       |    |  | | __ | |    
125
  -- ___]  |  |  | |___ |___    |___ |__| |__] | |___ 
126
  --
127
  -- STALL SOURCES
128
  --
129
  type t_stall_source is
130
    record
131
      pc                                  : std_logic;                  -- programm counter should be stalled
132
      data                                : std_logic;                  -- data access is stalled
133
      unit                                : std_logic;                  -- calulation unit is busy
134
    end record;
135
 
136
  --
137
  -- SUBUNITS STALLS
138
  --
139
  type t_unit_busy is
140
    record
141
      mult                                : std_logic;
142
      fpu                                 : std_logic;
143
    end record;
144
 
145
  -- ____ ___  _  _    ____ ____ ____ ____ 
146
  -- |___ |__] |  |    |___ |    [__  |__/ 
147
  -- |    |    |__|    |    |___ ___] |  \ 
148
  --
149
  -- control and status register of the FPU
150
  --
151
  --
152
  -- FPU FLAGS
153
  --
154
  type t_fpu_flags is
155
    record
156
      v                                   : std_logic;                  -- invalid operation
157
      z                                   : std_logic;                  -- devide by zero
158
      o                                   : std_logic;                  -- overflow
159
      u                                   : std_logic;                  -- underflow
160
      i                                   : std_logic;                  -- inexact
161
    end record;
162
 
163
  --
164
  -- FPU ROUND MODE
165
  --
166
  subtype t_fpu_rm                        is std_logic_vector(1 downto 0);
167
 
168
  --
169
  -- REGISTER FIELDS
170
  --
171
  type t_fpu_fcsr is
172
    record
173
      fcc                                 : std_logic_vector(7 downto 0);
174
      fs                                  : std_logic;
175
      unused                              : std_logic_vector(4 downto 0);
176
      cause_e                             : std_logic;
177
      cause                               : t_fpu_flags;
178
      enables                             : t_fpu_flags;
179
      flags                               : t_fpu_flags;
180
      rm                                  : std_logic_vector(1 downto 0);
181
    end record;
182
 
183
  -- --------------------------------------------------------------------
184
  -- _  _ _  _ _  _    ____ ____ _  _ ___  _ _  _ ____ 
185
  -- |\/| |  |  \/     |    |  | |\ | |  \ | |\ | | __ 
186
  -- |  | |__| _/\_    |___ |__| | \| |__/ | | \| |__] 
187
  --
188
  -- SOURCE MUXES
189
  --
190
  type t_src_select is (
191
      SRC_REG,                                -- register bank
192
      SRC_OP_OUT,                             -- operation unit output -> from ex-stage
193
      SRC_MEM_OUT,                            -- memory access output -> from memory
194
      SRC_WB_OUT                              -- register write store -> directly from register input
195
  );
196
 
197
  --
198
  -- IMMEDIATE VALUE
199
  --
200
  type t_imm_select is (
201
      IMM_SIGN,                               -- default value, signed extended
202
      IMM_UNSIGN,                             -- unsigned extended
203
      IMM_HIGH,                               -- for high load
204
      IMM_SHAMT,                              -- shifter amount value
205
      IMM_BRANCH,                             -- branch value
206
      IMM_JUMP                                -- absolute jump value
207
  );
208
 
209
  --
210
  -- MEMORY DATA VALUE
211
  --
212
  type t_b_imm_select is (
213
      B_IMM_ON,                               -- enable immediate value for source B
214
      B_IMM_OF                                -- disable immediate value for source B
215
  );
216
 
217
  --
218
  -- COPROCESSOR  MUX 
219
  --
220
  type t_cop_select is(
221
      COP_SELECT_CORE,                        -- regular core
222
      COP_SELECT_COP0,                        -- interrupt handler
223
      COP_SELECT_COP1                         -- FPU
224
  );
225
 
226
  --
227
  -- COPROCESSOR 1 (FPU) MUX
228
  --
229
  type t_fpu_select is (
230
      FPU_DATA_INTERN,                        -- intern data
231
      FPU_DATA_CORE                           -- data from main core
232
  );
233
 
234
  --
235
  -- RESULT MUX
236
  --
237
  type t_src_out_select is (
238
      SRC_OUT_ALU,                            -- ALU output
239
      SRC_OUT_MULT,                           -- MUL/DIV modul output
240
      SRC_OUT_SHIFT,                          -- SHIFTER output
241
      SRC_OUT_PC,                             -- PC value
242
      SRC_OUT_MEM_DATA                        -- data from MEMORY DATA path (for FPU)
243
  );
244
 
245
  --
246
  -- REGISTER DATA MUX
247
  --
248
  type t_wb_select is (
249
      WB_OP_UNIT,                             -- data from operation units
250
      WB_MEMORY                               -- data from memory
251
  );
252
 
253
  -- --------------------------------------------------------------------
254
  -- ____ ____ _  _ ___ ____ ____ _       ____ ____ ___  _ _  _ ____ 
255
  -- |    |  | |\ |  |  |__/ |  | |       |    |  | |  \ | |\ | | __ 
256
  -- |___ |__| | \|  |  |  \ |__| |___    |___ |__| |__/ | | \| |__] 
257
  --
258
  -- PROGRAM COUNTER
259
  --
260
  type t_pc_function is (
261
      PLASMA_PC_INC,                          -- increment PC value (default)
262
      PLASMA_PC_IMM,                          -- set PC to immediate value
263
      PLASMA_PC_REG,                          -- set PC to register value
264
      PLASMA_PC_BRANCH                        -- set PC to branch immediate value
265
  );
266
 
267
  --
268
  -- FPU OPERATION MODES
269
  --
270
  type t_fpu_mode is (
271
      FPU_MODE_NONE,                          -- nothing to do
272
      FPU_MODE_ALU,                           -- FPU alu operation
273
      FPU_MODE_FGR,                           -- access to FPU registers
274
      FPU_MODE_CTC,                           -- access to FPU control register
275
      FPU_MODE_C                              -- access to CC bit
276
    );
277
 
278
  -- --------------------------------------------------------------------
279
  -- _  _ ____ _  _ ____ ____ _   _    ____ ____ ___  _ _  _ ____ 
280
  -- |\/| |___ |\/| |  | |__/  \_/     |    |  | |  \ | |\ | | __ 
281
  -- |  | |___ |  | |__| |  \   |      |___ |__| |__/ | | \| |__] 
282
  --
283
  -- READ
284
  --
285
  constant PLASMA_MASK_READ32             : t_plasma_mask         := b"1111";
286
  constant PLASMA_MASK_READ32L            : t_plasma_mask         := b"1110";
287
  constant PLASMA_MASK_READ32R            : t_plasma_mask         := b"0111";
288
  constant PLASMA_MASK_READ16             : t_plasma_mask         := b"0011";
289
  constant PLASMA_MASK_READ8              : t_plasma_mask         := b"0001";
290
  constant PLASMA_MASK_ZERO               : t_plasma_mask         := b"0000";
291
 
292
  --
293
  -- WRITE
294
  --                                                           
295
  constant PLASMA_MASK_WRITE32            : t_plasma_mask         := b"1111";
296
  constant PLASMA_MASK_WRITE32L           : t_plasma_mask         := b"1110";
297
  constant PLASMA_MASK_WRITE32R           : t_plasma_mask         := b"0111";
298
  constant PLASMA_MASK_WRITE16            : t_plasma_mask         := b"0011";
299
  constant PLASMA_MASK_WRITE8             : t_plasma_mask         := b"0001";
300
 
301
  -- ____ ___  _  _    ____ ____ _  _ _  _ ___     _  _ ____ ___  ____ 
302
  -- |___ |__] |  |    |__/ |  | |  | |\ | |  \    |\/| |  | |  \ |___ 
303
  -- |    |    |__|    |  \ |__| |__| | \| |__/    |  | |__| |__/ |___ 
304
  constant PLASMA_FPU_RM_RN               : t_fpu_rm              := b"00";             -- round to nearest
305
  constant PLASMA_FPU_RM_RZ               : t_fpu_rm              := b"01";             -- round toward zero
306
  constant PLASMA_FPU_RM_RP               : t_fpu_rm              := b"10";             -- round towards plus infinity
307
  constant PLASMA_FPU_RM_RM               : t_fpu_rm              := b"11";             -- round towards minus infinity
308
 
309
  -- _  _ ____ _    ___     ____ ____ _  _ ____ ___ ____ _  _ ___ ____ 
310
  -- |__| |___ |    |__]    |    |  | |\ | [__   |  |__| |\ |  |  [__  
311
  -- |  | |___ |___ |       |___ |__| | \| ___]  |  |  | | \|  |  ___] 
312
  constant PLASMA_ZERO_WORD               : t_plasma_word     := (others => '0');
313
  constant PLASMA_ONES_WORD               : t_plasma_word     := (others => '1');
314
  constant PLASMA_SET_WORD                : t_plasma_word     := PLASMA_ZERO_WORD(PLASMA_DATA_WIDTH - 1 downto 1) & '1';
315
  constant PLASMA_INC_WORD                : t_plasma_word     := PLASMA_ZERO_WORD(PLASMA_DATA_WIDTH - 1 downto 3) & b"100";
316
 
317
  -- ------------------------------------------------------------------------------------------------------------------
318
  --  _____ _   _ _______ ______ _____  ______      _____ ______  _____ 
319
  -- |_   _| \ | |__   __|  ____|  __ \|  ____/\   / ____|  ____|/ ____|
320
  --   | | |  \| |  | |  | |__  | |__) | |__ /  \ | |    | |__  | (___  
321
  --   | | | . ` |  | |  |  __| |  _  /|  __/ /\ \| |    |  __|  \___ \ 
322
  --  _| |_| |\  |  | |  | |____| | \ \| | / ____ \ |____| |____ ____) |
323
  -- |_____|_| \_|  |_|  |______|_|  \_\_|/_/    \_\_____|______|_____/ 
324
  -- ------------------------------------------------------------------------------------------------------------------
325
  --
326
  -- GENERAL CONTROL INTERFACE
327
  --
328
  type t_main_control is
329
    record
330
      clk                                 : std_logic;                  -- clock signal
331
      rst                                 : std_logic;                  -- reset signal
332
    end record;
333
 
334
  --
335
  -- FPU CONTROL
336
  --
337
  type t_fpu_ctrl is
338
    record
339
      c_reg                               : std_logic;                  -- control register access
340
      fix                                 : std_logic;                  -- fixpoint flag
341
      double                              : std_logic;                  -- double flag
342
      mode                                : t_fpu_mode;                 -- write mode
343
      operation                           : t_mips_function;            -- operation mode
344
    end record;
345
 
346
  --
347
  -- operation units control (no FPU)
348
  --
349
  type t_plasma_subunits_ctrl is
350
    record
351
      pc_func                             : t_pc_function;              -- program counter
352
      alu_func                            : t_mips_function;            -- ALU
353
      shift_func                          : t_mips_function;            -- shifter
354
      mult_func                           : t_mips_function;            -- multiplier
355
      comp_func                           : t_mips_opcode;              -- comparator
356
    end record;
357
 
358
  --
359
  -- basic multiplexer control
360
  --
361
  type t_plasma_mux_ctrl is
362
    record
363
      src_a                               : t_src_select;               -- source mux
364
      src_b                               : t_src_select;               -- target mux
365
      src_imm                             : t_imm_select;               -- immediate value
366
      src_b_imm                           : t_b_imm_select;             -- immediate pass
367
      src_out                             : t_src_out_select;           -- memory stage input
368
      wb                                  : t_wb_select;                -- write back stage input
369
    end record;
370
 
371
  --
372
  -- additional muxes with FPU
373
  --  
374
  type t_plasma_mux_fpu is
375
    record
376
      cop                                 : t_cop_select;               -- data from coprocessor
377
      fpu_id                              : t_fpu_select;               -- ID stage of FPU
378
      fpu_mem                             : t_fpu_select;               -- MEM stage of FPU
379
    end record;
380
 
381
  --
382
  -- program counter output
383
  --
384
  type t_plasma_pc_out is
385
    record
386
      pc_out_inc                          : t_plasma_word;              -- incremented value -> next instr address
387
      pc_out_branch                       : t_plasma_word;              -- pc + immediate value -> branch taken address
388
      pc_out                              : t_plasma_word;              -- current address
389
    end record;
390
 
391
  -- ------------------------------------------------------------------------------------------------------------------
392
  --   _____ ____  __  __ _____   ____  _   _ ______ _   _ _______ _____ 
393
  --  / ____/ __ \|  \/  |  __ \ / __ \| \ | |  ____| \ | |__   __/ ____|
394
  -- | |   | |  | | \  / | |__) | |  | |  \| | |__  |  \| |  | | | (___  
395
  -- | |   | |  | | |\/| |  ___/| |  | | . ` |  __| | . ` |  | |  \___ \ 
396
  -- | |___| |__| | |  | | |    | |__| | |\  | |____| |\  |  | |  ____) |
397
  --  \_____\____/|_|  |_|_|     \____/|_| \_|______|_| \_|  |_| |_____/ 
398
  -- ------------------------------------------------------------------------------------------------------------------
399
  -- ___  ____ ____ _ ____ 
400
  -- |__] |__| [__  | |    
401
  -- |__] |  | ___] | |___ 
402
  --
403
  -- REGISTER BANK
404
  --
405
  component plasma_reg_bank is
406
    generic(
407
      core_idx                : natural := 0;
408
      DEBUG_FLAG              : string := "OF"
409
    );
410
    port(
411
      control                 : in  t_main_control;
412
      reg_addr                : in  t_reg_addr;
413
      reg_dest_new            : in  t_plasma_word;
414
      reg_source_out          : out t_plasma_word;
415
      reg_target_out          : out t_plasma_word
416
    );
417
  end component plasma_reg_bank;
418
 
419
  --
420
  -- ALU
421
  --
422
  component plasma_alu is
423
    port(
424
      alu_a_in                : in  t_plasma_word;
425
      alu_b_in                : in  t_plasma_word;
426
      alu_func                : in  t_mips_function;
427
      alu_out                 : out t_plasma_word
428
    );
429
  end component plasma_alu;
430
 
431
  --
432
  -- SHIFTER
433
  --
434
  component plasma_shifter is
435
    port(
436
      shift_in                : in  t_plasma_word;
437
      shift_amount            : in  t_mips_shamt;
438
      shift_func              : in  t_mips_function;
439
      shift_out               : out t_plasma_word
440
    );
441
  end component plasma_shifter;
442
 
443
  --
444
  -- MULTIPLICATOR
445
  --
446
  component plasma_mult is
447
    port(
448
      control                 : in  t_main_control;
449
      mult_a_in               : in  t_plasma_word;
450
      mult_b_in               : in  t_plasma_word;
451
      mult_func               : in  t_mips_function;
452
      mult_busy               : out std_logic;
453
      mult_out                : out t_plasma_word
454
    );
455
  end component plasma_mult;
456
 
457
  --
458
  -- COMPARATOR
459
  --
460
  component plasma_comparator is
461
    port(
462
      comp_a_in               : in  t_plasma_word;
463
      comp_b_in               : in  t_plasma_word;
464
      comp_func               : in  t_mips_opcode;
465
      comp_out                : out std_logic
466
    );
467
  end component plasma_comparator;
468
 
469
  -- ___  ____ ____ ____ ____ ____ _  _    ____ ____ _  _ _  _ ___ ____ ____ 
470
  -- |__] |__/ |  | | __ |__/ |__| |\/|    |    |  | |  | |\ |  |  |___ |__/ 
471
  -- |    |  \ |__| |__] |  \ |  | |  |    |___ |__| |__| | \|  |  |___ |  \ 
472
  --
473
  -- PROGRAM COUNTER
474
  --                
475
  component plasma_pc is
476
    port(
477
      control                 : in  t_main_control;
478
      stall                   : in  std_logic;
479
      pc_new_value            : in  t_plasma_word;
480
      pc_imm_in               : in  t_plasma_word;
481
      pc_out                  : out t_plasma_pc_out
482
    );
483
  end component plasma_pc;
484
 
485
  -- ____ ___  _  _ 
486
  -- |___ |__] |  | 
487
  -- |    |    |__| 
488
  --
489
  -- FPU REGISTER BANK
490
  --
491
  component plasma_fpu_reg_bank is
492
    generic(
493
      DEBUG_FLAG              : string := "OF"
494
    );
495
    port(
496
      control                 : in  t_main_control;
497
      reg_addr                : in  t_reg_addr;
498
      fpu_ctrl                : in  t_fpu_ctrl;
499
      alu_cause               : in  t_fpu_flags;
500
      comp_out                : in  std_logic;
501
      cc_out                  : out std_logic;
502
      reg_dest_new            : in  t_plasma_dword;
503
      reg_source_out          : out t_plasma_dword;
504
      reg_target_out          : out t_plasma_dword
505
    );
506
  end component plasma_fpu_reg_bank;
507
 
508
  --
509
  -- FPU ALU
510
  --
511
  component plasma_fpu_alu is
512
  port (
513
    control                   : in  t_main_control;
514
    -- INPUT
515
    alu_a_in                  : in  t_plasma_dword;
516
    alu_b_in                  : in  t_plasma_dword;
517
 
518
    -- CONTROL
519
    fpu_ctrl                  : in  t_fpu_ctrl;
520
    round_mode                : in  t_fpu_rm;
521
 
522
    -- STATUS
523
    cause_e                   : out std_logic;
524
    cause                     : out t_fpu_flags;
525
 
526
    -- OUTPUT
527
    alu_out                   : out t_plasma_dword
528
  );
529
  end component plasma_fpu_alu;
530
 
531
  --
532
  -- FPU COMPARATOR
533
  --
534
  component plasma_fpu_comparator is
535
  port (
536
    comp_a_in                 : in  t_plasma_dword;
537
    comp_b_in                 : in  t_plasma_dword;
538
    fpu_ctrl                  : in  t_fpu_ctrl;
539
    comp_out                  : out std_logic
540
  );
541
  end component plasma_fpu_comparator;
542
 
543
  --
544
  -- PLASMA FPU TOP
545
  --
546
  component plasma_fpu is
547
    generic(
548
      DEBUG_FLAG              : string  := "OF"
549
    );
550
    port(
551
      -- general
552
      control                 : in  t_main_control;
553
      -- operation and regbank
554
      fpu_reg_addr            : in  t_reg_addr;
555
      fpu_ctrl                : in  t_fpu_ctrl;
556
      -- status
557
      busy                    : out std_logic;
558
      cc_out                  : out std_logic;
559
      -- data muxes
560
      fpu_id_sel              : in  t_fpu_select;
561
      fpu_mem_sel             : in  t_fpu_select;
562
      -- data
563
      -- IF/ID stage
564
      data_to_fpu             : in  t_plasma_word;
565
      data_from_fpu           : out t_plasma_word;
566
      -- MEM stage
567
      data_to_fpu_mem         : in  t_plasma_word
568
    );
569
  end component plasma_fpu;
570
 
571
  -- ____ ____ _  _ ___ ____ ____ _    
572
  -- |    |  | |\ |  |  |__/ |  | |    
573
  -- |___ |__| | \|  |  |  \ |__| |___ 
574
  --
575
  -- MIPS-I without FPU
576
  --
577
  component plasma_control_MIPSI is
578
    generic(
579
      core_idx                : natural := 0
580
    );
581
    port(
582
      control                 : in  t_main_control;
583
      instr_in                : in  t_plasma_word;       -- input instruction
584
      -- memory stalls
585
      prog_stall              : in  std_logic;
586
      data_stall              : in  std_logic;
587
      -- control flags
588
      comp_out                : in  std_logic;          -- comparator output
589
      unit_busy               : in  t_unit_busy;        -- busy flags of units      
590
      -- register bank control
591
      reg_addr                : out t_reg_addr;         -- register bank
592
      mux_ctrl                : out t_plasma_mux_ctrl;  -- datapath muxes
593
      stall_src               : out t_stall_source;     -- control registers of datapath
594
      unit_ctrl               : out t_plasma_subunits_ctrl;
595
      -- memory access control
596
      mem_func                : out t_mips_opcode
597
    );
598
  end component plasma_control_MIPSI;
599
 
600
  --
601
  -- MIPS-I with FPU
602
  --
603
  component plasma_control_MIPSI_FPU is
604
    generic(
605
      core_idx                : natural := 0
606
    );
607
    port(
608
      control                 : in  t_main_control;
609
      instr_in                : in  t_plasma_word;       -- input instruction
610
      -- memory stalls
611
      prog_stall              : in  std_logic;
612
      data_stall              : in  std_logic;
613
      -- control flags
614
      comp_out                : in  std_logic;          -- comparator output
615
      fpu_cc                  : in  std_logic;          -- FPU comparator output
616
      unit_busy               : in  t_unit_busy;        -- busy flags of units      
617
      -- register bank control
618
      reg_addr                : out t_reg_addr;         -- register bank
619
      fpu_reg_addr            : out t_reg_addr;         -- FPU register bank
620
      mux_ctrl                : out t_plasma_mux_ctrl;  -- datapath muxes
621
      mux_fpu                 : out t_plasma_mux_fpu;   -- additional FPU muxes
622
      stall_src               : out t_stall_source;     -- control registers of datapath
623
      unit_ctrl               : out t_plasma_subunits_ctrl;
624
      fpu_ctrl                : out t_fpu_ctrl;
625
      -- memory access control
626
      mem_func                : out t_mips_opcode
627
    );
628
  end component plasma_control_MIPSI_FPU;
629
 
630
  -- ___  ____ ___ ____ ___  ____ ___ _  _ 
631
  -- |  \ |__|  |  |__| |__] |__|  |  |__| 
632
  -- |__/ |  |  |  |  | |    |  |  |  |  | 
633
  --
634
  -- MIPS-I without FPU
635
  --
636
  component plasma_datapath_MIPSI is
637
    generic(
638
      core_idx                : natural := 0;
639
      SIM_FLAG                : string  := "ON";
640
      DEBUG_FLAG              : string  := "OF"
641
      );
642
    port(
643
      control                 : in  t_main_control;
644
      -- input control mux and registers
645
      reg_addr                : in  t_reg_addr;
646
      mux_ctrl                : in  t_plasma_mux_ctrl;
647
      stall_src               : in  t_stall_source;
648
      -- output feedback signals
649
      comp_out                : out std_logic;
650
      unit_busy               : out t_unit_busy;
651
      -- operation units control
652
      unit_ctrl               : in  t_plasma_subunits_ctrl;
653
      -- data
654
      instr_addr              : out t_plasma_word;
655
      data_addr               : out t_plasma_word;
656
 
657
      instr_in                : in  t_plasma_word;
658
      data_from_mem           : in  t_plasma_word;
659
      data_to_mem             : out t_plasma_word
660
    );
661
  end component plasma_datapath_MIPSI;
662
 
663
  --
664
  -- MIPS-I with FPU
665
  --
666
  component plasma_datapath_MIPSI_FPU is
667
    generic(
668
      core_idx                : natural := 0;
669
      SIM_FLAG                : string  := "ON";
670
      DEBUG_FLAG              : string  := "OF"
671
      );
672
    port(
673
      control                 : in  t_main_control;
674
      -- input control mux and registers
675
      reg_addr                : in  t_reg_addr;
676
      fpu_reg_addr            : in  t_reg_addr;
677
      mux_ctrl                : in  t_plasma_mux_ctrl;
678
      mux_fpu                 : in  t_plasma_mux_fpu;
679
      stall_src               : in  t_stall_source;
680
      -- output feedback signals
681
      comp_out                : out std_logic;
682
      fpu_cc                  : out std_logic;
683
      unit_busy               : out t_unit_busy;
684
      -- operation units control
685
      unit_ctrl               : in  t_plasma_subunits_ctrl;
686
      fpu_ctrl                : in  t_fpu_ctrl;
687
      -- data
688
      instr_addr              : out t_plasma_word;
689
      data_addr               : out t_plasma_word;
690
 
691
      instr_in                : in  t_plasma_word;
692
      data_from_mem           : in  t_plasma_word;
693
      data_to_mem             : out t_plasma_word
694
    );
695
  end component plasma_datapath_MIPSI_FPU;
696
 
697
  -- _  _ ____ _  _ ____ ____ _   _    ____ ____ _  _ ___ ____ ____ _    
698
  -- |\/| |___ |\/| |  | |__/  \_/     |    |  | |\ |  |  |__/ |  | |    
699
  -- |  | |___ |  | |__| |  \   |      |___ |__| | \|  |  |  \ |__| |___ 
700
  component plasma_mem_ctrl is
701
    port(
702
      clk                     : in  std_logic;
703
      reset                   : in  std_logic;
704
 
705
      -- INPUT FROM PLASMA
706
      mem_func                : in  t_mips_opcode;
707
      prog_addr_in            : in  t_plasma_word;
708
      data_addr_in            : in  t_plasma_word;
709
      data_w_in               : in  t_plasma_word;
710
 
711
      -- INPUT FROM MEMORY
712
      prog_stall_in           : in  std_logic;
713
      data_stall_In           : in  std_logic;
714
      prog_in                 : in t_plasma_word;
715
      data_r_in               : in t_plasma_word;
716
 
717
      -- OUTPUT TO PLASMA
718
      prog_stall_out          : out std_logic;
719
      data_stall_out          : out std_logic;
720
      prog_out                : out t_plasma_word;
721
      data_r_out              : out t_plasma_word;
722
 
723
      -- OUTPUT TO MEMORY
724
      prog_addr_out           : out t_plasma_word;
725
      data_addr_out           : out t_plasma_word;
726
      wr_mask_out             : out t_plasma_mask;
727
      rd_mask_out             : out t_plasma_mask;
728
      data_w_out              : out t_plasma_word
729
    );
730
  end component plasma_mem_ctrl;
731
 
732
  -- ___  _    ____ ____ _  _ ____ 
733
  -- |__] |    |__| [__  |\/| |__| 
734
  -- |    |___ |  | ___] |  | |  | 
735
  component plasma is
736
    generic(
737
      core_idx                : natural := 0;
738
      FPU_FLAG                : string  := "OF";
739
      SIM_FLAG                : string  := "ON";
740
      DEBUG_FLAG              : string  := "OF"
741
    );
742
    port(
743
      clk                     : in  std_logic;
744
      rst                     : in  std_logic;
745
      instr_addr              : out std_logic_vector(31 downto 0);
746
      data_addr               : out std_logic_vector(31 downto 0);
747
      rd_mask                 : out std_logic_vector(3  downto 0);
748
      wr_mask                 : out std_logic_vector(3  downto 0);
749
      instr_stall             : in  std_logic;
750
      data_stall              : in  std_logic;
751
      instr_in                : in  std_logic_vector(31 downto 0);
752
      data_to_cpu             : in  std_logic_vector(31 downto 0);
753
      data_from_cpu           : out std_logic_vector(31 downto 0)
754
    );
755
  end component plasma;
756
 
757
  -- ------------------------------------------------------------------------------------------------------------------
758
  --  _____  ______ ____  _    _  _____  _____ _____ _   _  _____ 
759
  -- |  __ \|  ____|  _ \| |  | |/ ____|/ ____|_   _| \ | |/ ____|
760
  -- | |  | | |__  | |_) | |  | | |  __| |  __  | | |  \| | |  __ 
761
  -- | |  | |  __| |  _ <| |  | | | |_ | | |_ | | | | . ` | | |_ |
762
  -- | |__| | |____| |_) | |__| | |__| | |__| |_| |_| |\  | |__| |
763
  -- |_____/|______|____/ \____/ \_____|\_____|_____|_| \_|\_____|
764
  -- ------------------------------------------------------------------------------------------------------------------  
765
-- synthesis translate_off
766
  function sv2string( input : std_logic_vector ) return string;
767
  function sv2reg(    input : t_mips_reg_addr  ) return string;
768
 
769
  -- ____ ____ ____    ___  ____ _  _ _  _ 
770
  -- |__/ |___ | __    |__] |__| |\ | |_/  
771
  -- |  \ |___ |__]    |__] |  | | \| | \_ 
772
  type t_v is array(0 to 1) of t_plasma_word;
773
  type t_a is array(0 to 3) of t_plasma_word;
774
  type t_t is array(0 to 9) of t_plasma_word;
775
  type t_s is array(0 to 8) of t_plasma_word;
776
  type t_k is array(0 to 1) of t_plasma_word;
777
 
778
  type t_plasma_rf is
779
    record
780
      we    : std_logic;
781
      zero  : t_plasma_word;
782
      at    : t_plasma_word;
783
      v     : t_v;
784
      a     : t_a;
785
      t     : t_t;
786
      s     : t_s;
787
      k     : t_k;
788
      gp    : t_plasma_word;
789
      sp    : t_plasma_word;
790
      ra    : t_plasma_word;
791
    end record;
792
 
793
  type t_noc_bank is array(0 to 2) of t_plasma_rf;
794
  signal plasma_rbank       : t_noc_bank;
795
 
796
  signal plasma_fpu_bank    : t_reg_bank;
797
  signal debug_prog_addr    : t_plasma_word;
798
 
799
  -- ____ _ _  _    ____ ____ _  _ ___ ____ ____ _    
800
  -- [__  | |\/|    |    |  | |\ |  |  |__/ |  | |    
801
  -- ___] | |  |    |___ |__| | \|  |  |  \ |__| |___ 
802
  type t_sim_control is
803
    record
804
      sim_message           : std_logic_vector(3 downto 0);
805
      sim_stop              : std_logic;
806
      print_message         : std_logic;
807
      sim_finish            : std_logic;
808
      track_en              : std_logic_vector(3 downto 0);
809
      track_mark            : std_logic;
810
  end record;
811
 
812
  signal i_sim_control      : t_sim_control;
813
-- synthesis translate_on
814
 
815
end package plasma_pack;
816
 
817
 
818
package body plasma_pack is
819
 
820
-- synthesis translate_off
821
  function sv2string( input : std_logic_vector ) return string
822
  is
823
    variable l : line;
824
  begin
825
    hwrite( l, input, RIGHT, 6 );
826
    return l.all;
827
  end sv2string;
828
 
829
  function sv2reg( input : t_mips_reg_addr ) return string
830
  is
831
  begin
832
    case input is
833
      when "00000"  => return "zero";
834
      when "00001"  => return "at";
835
      when "00010"  => return "v0";
836
      when "00011"  => return "v1";
837
      when "00100"  => return "a0";
838
      when "00101"  => return "a1";
839
      when "00110"  => return "a2";
840
      when "00111"  => return "a3";
841
      when "01000"  => return "t0";
842
      when "01001"  => return "t1";
843
      when "01010"  => return "t2";
844
      when "01011"  => return "t3";
845
      when "01100"  => return "t4";
846
      when "01101"  => return "t5";
847
      when "01110"  => return "t6";
848
      when "01111"  => return "t7";
849
      when "10000"  => return "s0";
850
      when "10001"  => return "s1";
851
      when "10010"  => return "s2";
852
      when "10011"  => return "s3";
853
      when "10100"  => return "s4";
854
      when "10101"  => return "s5";
855
      when "10110"  => return "s6";
856
      when "10111"  => return "s7";
857
      when "11000"  => return "t8";
858
      when "11001"  => return "t9";
859
      when "11010"  => return "k0";
860
      when "11011"  => return "k1";
861
      when "11100"  => return "gp";
862
      when "11101"  => return "sp";
863
      when "11110"  => return "s8";
864
      when "11111"  => return "ra";
865
      when others   => return "unknown";
866
    end case;
867
  end sv2reg;
868
-- synthesis translate_on
869
 
870
end package body plasma_pack;

powered by: WebSVN 2.1.0

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