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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [processor/] [VHDL/] [scarts_core/] [scarts_core_pkg.vhd] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 jlechner
-----------------------------------------------------------------------
2
-- This file is part of SCARTS.
3
-- 
4
-- SCARTS is free software: you can redistribute it and/or modify
5
-- it under the terms of the GNU General Public License as published by
6
-- the Free Software Foundation, either version 3 of the License, or
7
-- (at your option) any later version.
8
-- 
9
-- SCARTS is distributed in the hope that it will be useful,
10
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
11
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
-- GNU General Public License for more details.
13
-- 
14
-- You should have received a copy of the GNU General Public License
15
-- along with SCARTS.  If not, see <http://www.gnu.org/licenses/>.
16
-----------------------------------------------------------------------
17
 
18
 
19
library ieee;
20
use ieee.std_logic_1164.all;
21
 
22
use work.scarts_pkg.all;
23
use work.scarts_amba_pkg.all;
24
 
25
package scarts_core_pkg is
26
 
27
  constant INSTR_W            : integer := 16;
28
  constant ALUFLAG_W          : integer := 5;
29
  constant REGADDR_W          : integer := 4;
30
  constant EXCADDR_W          : integer := 5;
31
 
32
  constant EXCVECTAB_S        : integer  := 2**EXCADDR_W;
33
  constant REGFILE_S          : integer  := 2**REGADDR_W;
34
 
35
  constant EXCRETREG          : integer := REGFILE_S-1;
36
  constant SUBRETREG          : integer := REGFILE_S-2;
37
 
38
  subtype INSTR   is std_logic_vector(INSTR_W-1 downto 0);
39
  subtype ALUFLAG is std_logic_vector(ALUFLAG_W-1 downto 0);
40
  subtype REGADDR is std_logic_vector(REGADDR_W-1 downto 0);
41
 
42
 
43
  constant SLEEP_ACT          : std_ulogic := '1';
44
  constant HOLD_ACT           : std_ulogic := '1';
45
  constant EXC_ACT            : std_ulogic := '0';
46
  constant JMP_EXE            : std_ulogic := '1';
47
  constant TRAP_ACT           : std_ulogic := '1';
48
  constant BROM_SEL           : std_ulogic := '0';
49
  constant ILLOP              : std_ulogic := '1';
50
  constant REGF_WR            : std_ulogic := '1';
51
  constant STA_EN             : std_ulogic := '1';
52
  constant MEM_WR             : std_ulogic := '1';
53
  constant MEM_EN             : std_ulogic := '1';
54
  constant VECTAB_WR          : std_ulogic := '1';
55
  constant COND_INSTR         : std_ulogic := '1';
56
 
57
  constant PR_UPDATE          : std_logic     := '1';
58
  constant NOP                : INSTR := "1111111000000000";
59
 
60
  constant SIGNED_AC          : std_ulogic := '1';
61
 
62
  type MEMACCESSTYPE is (MEM_DISABLE, BYTE_A, HWORD_A, WORD_A);
63
 
64
  type ALUSRCCTRL is (REGF_SRC, EXE_SRC, WB_SRC, DEC_SRC);
65
 
66
  type WBSRCCTRL is (ALU_SRC, MEM_SRC);
67
 
68
  type CARRYCTRL is (CARRY_IN, CARRY_NOT, CARRY_ZERO, CARRY_ONE);
69
 
70
  type JMPCTRL is (NO_SAVE, SAVE_JMP, SAVE_EXC);
71
 
72
  type STACTRL is (SET_FLAG, SET_COND, SAVE_SR, REST_SR);
73
 
74
 
75
 
76
  constant GIE    : integer := 7;
77
  constant SLEEP  : integer := 6;
78
  --  constant CPROT0 : integer := 5;
79
  constant COND   : integer := 4;
80
  constant ZERO   : integer := 3;
81
  constant NEG    : integer := 2;
82
  constant CARRY  : integer := 1;
83
  constant OVER   : integer := 0;
84
 
85
  type ALUCTRL is (ALU_NOP, ALU_LDLIU, ALU_LDHI,
86
                   ALU_AND, ALU_OR, ALU_EOR, ALU_ADD,
87
                   ALU_SUB, ALU_CMPEQ, ALU_CMPUGT, ALU_CMPULT,
88
                   ALU_CMPGT, ALU_CMPLT,
89
                   ALU_NOT, ALU_NEG,
90
                   ALU_SL, ALU_SR, ALU_SRA, ALU_RRC, ALU_BYPR1,
91
                   ALU_BYPR2, ALU_BYPEXC);
92
 
93
  component scarts_core is
94
    generic (
95
      CONF : scarts_conf_type);
96
    port (
97
      clk   : in  std_ulogic;
98
      sysrst : in  std_ulogic;
99
      hold  : in  std_ulogic;
100
 
101
      iramo_rdata       : in INSTR;
102
      irami_wdata       : out INSTR;
103
      irami_waddr       : out std_logic_vector(CONF.instr_ram_size-1 downto 0);
104
      irami_wen         : out std_ulogic;
105
      irami_raddr       : out std_logic_vector(CONF.instr_ram_size-1 downto 0);
106
 
107
      regfi_wdata       : out std_logic_vector(CONF.word_size-1 downto 0);
108
      regfi_waddr       : out std_logic_vector(REGADDR_W-1 downto 0);
109
      regfi_wen         : out std_ulogic;
110
      regfi_raddr1      : out std_logic_vector(REGADDR_W-1 downto 0);
111
      regfi_raddr2      : out std_logic_vector(REGADDR_W-1 downto 0);
112
      regfo_rdata1      : in  std_logic_vector(CONF.word_size-1 downto 0);
113
      regfo_rdata2      : in  std_logic_vector(CONF.word_size-1 downto 0);
114
 
115
      corei_interruptin : in  std_logic_vector(15 downto 0);
116
      corei_extdata     : in  std_logic_vector(CONF.word_size-1 downto 0);
117
      coreo_extwr       : out std_ulogic;
118
      coreo_signedac    : out std_ulogic;
119
      coreo_extaddr     : out std_logic_vector(CONF.word_size-1 downto 0);
120
      coreo_extdata     : out std_logic_vector(CONF.word_size-1 downto 0);
121
      coreo_memaccess   : out MEMACCESSTYPE;
122
      coreo_memen       : out std_ulogic;
123
      coreo_illop       : out std_ulogic;
124
 
125
      bromi_addr        : out std_logic_vector(CONF.word_size-1 downto 0);
126
      bromo_data        : in  INSTR;
127
 
128
      vecti_data_in     : out std_logic_vector(CONF.word_size-1 downto 0);
129
      vecti_interruptnr : out std_logic_vector(EXCADDR_W-2 downto 0);
130
      vecti_trapnr      : out std_logic_vector(EXCADDR_W-1 downto 0);
131
      vecti_wrvecnr     : out std_logic_vector(EXCADDR_W-1 downto 0);
132
      vecti_intcmd      : out std_ulogic;
133
      vecti_wrvecen     : out std_ulogic;
134
      vecto_data_out    : in  std_logic_vector(CONF.word_size-1 downto 0);
135
 
136
      sysci_staen       : out std_ulogic;
137
      sysci_stactrl     : out STACTRL;
138
      sysci_staflag     : out std_logic_vector(ALUFLAG_W-1 downto 0);
139
      sysci_interruptin : out std_logic_vector(15 downto 0);
140
      sysci_fptrwnew    : out std_logic_vector(CONF.word_size-1 downto 0);
141
      sysci_fptrxnew    : out std_logic_vector(CONF.word_size-1 downto 0);
142
      sysci_fptrynew    : out std_logic_vector(CONF.word_size-1 downto 0);
143
      sysci_fptrznew    : out std_logic_vector(CONF.word_size-1 downto 0);
144
 
145
      sysco_condflag    : in  std_ulogic;
146
      sysco_carryflag   : in  std_ulogic;
147
      sysco_interruptnr : in  std_logic_vector(EXCADDR_W-2 downto 0);
148
      sysco_intcmd      : in  std_ulogic;
149
      sysco_fptrw       : in  std_logic_vector(CONF.word_size-1 downto 0);
150
      sysco_fptrx       : in  std_logic_vector(CONF.word_size-1 downto 0);
151
      sysco_fptry       : in  std_logic_vector(CONF.word_size-1 downto 0);
152
      sysco_fptrz       : in  std_logic_vector(CONF.word_size-1 downto 0);
153
 
154
      progo_instrsrc    : in  std_ulogic;
155
      progo_prupdate    : in  std_ulogic;
156
      progo_praddr      : in  std_logic_vector(CONF.instr_ram_size-1 downto 0);
157
      progo_prdata      : in  INSTR);
158
  end component scarts_core;
159
 
160
 
161
  component scarts_iram
162
    generic (
163
      CONF : scarts_conf_type);
164
    port (
165
      wclk        : in  std_ulogic;
166
      rclk        : in  std_ulogic;
167
      hold        : in  std_ulogic;
168
      wdata       : in  INSTR;
169
      waddr       : in  std_logic_vector(CONF.instr_ram_size-1 downto 0);
170
      wen         : in  std_ulogic;
171
      raddr       : in  std_logic_vector(CONF.instr_ram_size-1 downto 0);
172
      rdata       : out INSTR);
173
  end component;
174
 
175
  component scarts_regfram
176
    generic (
177
      CONF : scarts_conf_type);
178
    port (
179
      wclk        : in  std_ulogic;
180
      rclk        : in  std_ulogic;
181
      enable      : in  std_ulogic;
182
 
183
      wdata       : in  std_logic_vector(CONF.word_size-1 downto 0);
184
      waddr       : in  std_logic_vector(REGADDR_W-1 downto 0);
185
      wen         : in  std_ulogic;
186
      raddr       : in  std_logic_vector(REGADDR_W-1 downto 0);
187
      rdata       : out std_logic_vector(CONF.word_size-1 downto 0));
188
  end component;
189
 
190
  component scarts_regf
191
    generic (
192
      CONF : scarts_conf_type);
193
    port (
194
      wclk        : in  std_ulogic;
195
      rclk        : in  std_ulogic;
196
      hold        : in  std_ulogic;
197
 
198
      wdata       : in  std_logic_vector(CONF.word_size-1 downto 0);
199
      waddr       : in  std_logic_vector(REGADDR_W-1 downto 0);
200
      wen         : in  std_ulogic;
201
      raddr1      : in  std_logic_vector(REGADDR_W-1 downto 0);
202
      raddr2      : in  std_logic_vector(REGADDR_W-1 downto 0);
203
 
204
      rdata1      : out std_logic_vector(CONF.word_size-1 downto 0);
205
      rdata2      : out std_logic_vector(CONF.word_size-1 downto 0));
206
  end component;
207
 
208
  component scarts_brom
209
    generic (
210
      CONF : scarts_conf_type);
211
    port (
212
      clk     : in  std_ulogic;
213
      hold    : in  std_ulogic;
214
      addr    : in  std_logic_vector(CONF.word_size-1 downto 0);
215
      data    : out INSTR);
216
  end component;
217
 
218
  component scarts_vectab is
219
    generic (
220
      CONF : scarts_conf_type);
221
    port (
222
      clk         : in  std_ulogic;
223
      hold        : in  std_ulogic;
224
      data_in     : in  std_logic_vector(CONF.word_size-1 downto 0);
225
      interruptnr : in  std_logic_vector(EXCADDR_W-2 downto 0);
226
      trapnr      : in  std_logic_vector(EXCADDR_W-1 downto 0);
227
      wrvecnr     : in  std_logic_vector(EXCADDR_W-1 downto 0);
228
      intcmd      : in  std_ulogic;
229
      wrvecen     : in  std_ulogic;
230
      data_out    : out std_logic_vector(CONF.word_size-1 downto 0));
231
  end component;
232
 
233
  component scarts_sysc
234
    generic (
235
      CONF : scarts_conf_type);
236
    port (
237
      clk               : in  std_ulogic;
238
      extrst            : in  std_ulogic;
239
      sysrst            : out std_ulogic;
240
      hold              : in  std_ulogic;
241
      cpu_halt          : out std_ulogic;
242
      extsel            : in  std_ulogic;
243
      exti              : in  module_in_type;
244
      exto              : out module_out_type;
245
 
246
 
247
      staen       : in  std_ulogic;
248
      stactrl     : in  STACTRL;
249
      staflag     : in  std_logic_vector(ALUFLAG_W-1 downto 0);
250
      interruptin : in  std_logic_vector(15 downto 0);
251
      fptrwnew    : in  std_logic_vector(CONF.word_size-1 downto 0);
252
      fptrxnew    : in  std_logic_vector(CONF.word_size-1 downto 0);
253
      fptrynew    : in  std_logic_vector(CONF.word_size-1 downto 0);
254
      fptrznew    : in  std_logic_vector(CONF.word_size-1 downto 0);
255
 
256
      condflag    : out std_ulogic;
257
      carryflag   : out std_ulogic;
258
      interruptnr : out std_logic_vector(EXCADDR_W-2 downto 0);
259
      intcmd      : out std_ulogic;
260
      fptrw       : out std_logic_vector(CONF.word_size-1 downto 0);
261
      fptrx       : out std_logic_vector(CONF.word_size-1 downto 0);
262
      fptry       : out std_logic_vector(CONF.word_size-1 downto 0);
263
      fptrz       : out std_logic_vector(CONF.word_size-1 downto 0));
264
  end component;
265
 
266
  component scarts_prog
267
    generic (
268
      CONF : scarts_conf_type);
269
    port (
270
      clk         : in  std_ulogic;
271
      extrst      : in  std_ulogic;
272
      progrst     : out std_ulogic;
273
      hold        : in  std_ulogic;
274
      extsel      : in  std_ulogic;
275
      exti        : in  module_in_type;
276
      exto        : out module_out_type;
277
 
278
      instrsrc    : out std_ulogic;
279
      prupdate    : out std_ulogic;
280
      praddr      : out std_logic_vector(CONF.instr_ram_size-1 downto 0);
281
      prdata      : out INSTR);
282
  end component;
283
 
284
  component scarts_byteram
285
    generic (
286
      CONF : scarts_conf_type);
287
    port (
288
      wclk        : in  std_ulogic;
289
      rclk        : in  std_ulogic;
290
      enable      : in  std_ulogic;
291
 
292
      wdata       : in  std_logic_vector(7 downto 0);
293
      waddr       : in  std_logic_vector((CONF.data_ram_size-3) downto 0);
294
      wen         : in  std_ulogic;
295
      raddr       : in  std_logic_vector((CONF.data_ram_size-3) downto 0);
296
      rdata       : out std_logic_vector(7 downto 0)
297
      );
298
  end component;
299
 
300
  component scarts_dram
301
    generic (
302
      CONF : scarts_conf_type);
303
    port (
304
      clk     : in  std_ulogic;
305
      hold    : in  std_ulogic;
306
      dramsel : in  std_ulogic;
307
 
308
      write_en  : in  std_ulogic;
309
      byte_en   : in  std_logic_vector(3 downto 0);
310
      data_in   : in  std_logic_vector(31 downto 0);
311
      addr      : in  std_logic_vector(CONF.data_ram_size-1 downto 2);
312
 
313
      data_out  : out std_logic_vector(31 downto 0));
314
  end component;
315
 
316
  --
317
  --  ALTERA components
318
  --
319
  component altera_boot_rom
320
    generic (
321
      CONF : scarts_conf_type);
322
    port(
323
      address   : in  std_logic_vector(15 DOWNTO 0);
324
      clken       : in  std_logic;
325
      clock       : in  std_logic;
326
      q           : out std_logic_vector(15 DOWNTO 0)
327
      );
328
  end component;
329
 
330
--
331
--  XILINX components
332
--
333
--  component xilinx_instr_rom
334
--    port(
335
--      clk     : in  std_ulogic;
336
--      enable  : in  std_ulogic;
337
--      addr    : in  std_logic_vector(15 downto 0);
338
--      data    : out std_logic_vector(15 downto 0)
339
--      );
340
--  end component;
341
 
342
--  component xilinx_vectab_ram
343
--    port(
344
--      clk     : in  std_ulogic;
345
--      enable  : in  std_ulogic;
346
--      raddr   : in  std_logic_vector(EXCADDR_W-1 downto 0);
347
--      rdata   : out std_logic_vector(WORD_W-1 downto 0);
348
--      waddr   : in  std_logic_vector(EXCADDR_W-1 downto 0);
349
--      wdata   : in  std_logic_vector(WORD_W-1 downto 0);
350
--      wen     : in  std_ulogic
351
--      );
352
--  end component;
353
 
354
--  component xilinx_data_ram
355
--    port(
356
--      clk     : in  std_ulogic;
357
--      enable  : in  std_ulogic;
358
--      ram0i   : in  byteram_in_type;
359
--      ram0o   : out byteram_out_type;
360
--      ram1i   : in  byteram_in_type;
361
--      ram1o   : out byteram_out_type;
362
--      ram2i   : in  byteram_in_type;
363
--      ram2o   : out byteram_out_type;
364
--      ram3i   : in  byteram_in_type;
365
--      ram3o   : out byteram_out_type
366
--      );
367
--  end component;
368
 
369
 
370
  component ext_breakpoint
371
    generic (
372
      CONF : scarts_conf_type);
373
    port (
374
      clk              : IN  std_logic;
375
      extsel           : in  std_ulogic;
376
      exti             : in  module_in_type;
377
      exto             : out module_out_type;
378
      -- Modul specific interface (= Pins)
379
      debugo_wdata     : in  INSTR;
380
      debugo_waddr     : in  std_logic_vector(CONF.instr_ram_size-1 downto 0);
381
      debugo_wen       : in  std_ulogic;
382
      debugo_raddr     : in  std_logic_vector(CONF.instr_ram_size-1 downto 0);
383
      debugo_rdata     : in  INSTR;
384
      debugo_read_en   : in  std_ulogic;
385
      debugo_hi_addr   : in  std_logic_vector(CONF.word_size-1 downto 15);
386
      debugi_rdata     : out INSTR;
387
      watchpoint_act   : in std_ulogic);
388
    end component;
389
 
390
  component ext_watchpoint
391
    generic (
392
      CONF : scarts_conf_type);
393
    port (
394
      clk     : IN  std_logic;
395
      extsel  : in  std_ulogic;
396
      exti    : in  module_in_type;
397
      exto    : out module_out_type;
398
      -- Modul specific interface (= Pins) 
399
      read_en : in std_ulogic;
400
      hi_addr : in std_logic_vector(CONF.word_size-1 downto 15) --lower 15 bits in exti.addr
401
      );
402
  end component;
403
 
404
 
405
 
406
  -------------------------------------------------------------------------------
407
  -- AMBA Part
408
  -------------------------------------------------------------------------------
409
 
410
  -- Position of Registers of the 32-bit Generic Interface
411
  constant STATUSREG_GEN   : integer := 0;
412
  constant STATUSREG_CUST  : integer := 1;
413
  constant CONFIGREG_GEN   : integer := 2;
414
  constant CONFIGREG_CUST  : integer := 3;
415
  constant SLOT1_CONFIG    : integer := 4;
416
  constant SLOT1_MEMOFFSET : integer := 5;
417
  constant SLOT2_CONFIG    : integer := 6;
418
  constant SLOT2_MEMOFFSET : integer := 7;
419
  constant SLOT1_AMBAADDR  : integer := 8;
420
  constant SLOT2_AMBAADDR  : integer := 12;
421
 
422
  -- Bitposition of flags in corresponding register
423
  constant CFG_READ_WRITE  : integer := 5;
424
  constant CFG_START       : integer := 4;
425
  constant CFG_MASKINT     : integer := 3;
426
  constant CFG_ACCTYPE     : integer := 0;
427
  constant CFG_MEMOFFSET   : integer := 0;
428
  constant STA_READY_1     : integer := 7;
429
  constant STA_SUCCESS_1   : integer := 6;
430
  constant STA_ERROR_1     : integer := 5;
431
  constant STA_READY_2     : integer := 4;
432
  constant STA_SUCCESS_2   : integer := 3;
433
  constant STA_ERROR_2     : integer := 2;
434
  constant STA_SUCCESS_T   : integer := 1;
435
  constant STA_ERROR_T     : integer := 0;
436
 
437
  -- Bridge Signalflow SCARTS to AMBA
438
  type brg_scarts_to_amba_type is record
439
    sHBUSREQ : STD_LOGIC;
440
    sBADDR : STD_LOGIC_VECTOR (31 downto 0);
441
    sHADDR : STD_LOGIC_VECTOR (31 downto 0);
442
    sMRDATA : STD_LOGIC_VECTOR (31 downto 0);
443
    sHWRITE : STD_LOGIC;
444
    sHSIZE : STD_LOGIC_VECTOR (2 downto 0);
445
    sWAIT : STD_LOGIC;
446
  end record;
447
 
448
  -- Bridge Signalflow AMBA to AMBA
449
  type brg_amba_to_scarts_type is record
450
    sMADDR : STD_LOGIC_VECTOR (31 downto 0);
451
    sMWDATA : STD_LOGIC_VECTOR (31 downto 0);
452
    sMWRITE : STD_LOGIC;
453
    sByteEn : STD_LOGIC_VECTOR (3 downto 0);
454
    sERROR : STD_LOGIC;
455
    sFinished : STD_LOGIC;
456
    sBusRequest : STD_LOGIC;
457
    sIRQ : STD_LOGIC_VECTOR (7 downto 0);
458
  end record;
459
 
460
  -- component declaration for shared memory byte ram
461
  component AMBA_sharedmem_byteram is
462
    generic (
463
      CONF : scarts_conf_type);
464
    port (
465
      wclk        : in  std_ulogic;
466
      rclk        : in  std_ulogic;
467
 
468
      wdata       : in  std_logic_vector(7 downto 0);
469
      waddr       : in  std_logic_vector((CONF.amba_shm_size - CONF.amba_word_size/16-1) downto 0);
470
      wen         : in  std_ulogic;
471
      raddr       : in  std_logic_vector((CONF.amba_shm_size - CONF.amba_word_size/16-1) downto 0);
472
 
473
      rdata       : out std_logic_vector(7 downto 0));
474
  end component AMBA_sharedmem_byteram;
475
 
476
 
477
  -- component declaration for shared memory dram
478
  component AMBA_sharedmem_dram is
479
    generic (
480
      CONF : scarts_conf_type);
481
    port (
482
      clk     : in  std_ulogic;
483
      dramsel : in  std_ulogic;
484
 
485
      write_en  : in  std_ulogic;
486
      byte_en   : in  std_logic_vector(3 downto 0);
487
      data_in   : in  std_logic_vector(CONF.word_size-1 downto 0);
488
      addr      : in  std_logic_vector(CONF.amba_shm_size-1 downto CONF.amba_word_size/16);
489
      data_out  : out std_logic_vector(CONF.word_size-1 downto 0));
490
  end component AMBA_sharedmem_dram;
491
 
492
  -- component declaration for shared memory
493
  component ext_AMBA_sharedmem is
494
    generic (
495
      CONF : scarts_conf_type);
496
    port (
497
      clk          : in  std_ulogic;
498
      rst          : in  std_ulogic;
499
      --ren          : in  std_ulogic;
500
      ambadramsel  : in  std_ulogic;
501
      ambadramlock : in  std_ulogic;
502
      exti         : in  module_in_type;
503
      exto         : out module_out_type;
504
 
505
      adrami_write_en  : in  std_ulogic;
506
      adrami_byte_en   : in  std_logic_vector(3 downto 0);
507
      adrami_data_in   : in  std_logic_vector(CONF.word_size-1 downto 0);
508
      adrami_addr      : in  std_logic_vector(CONF.amba_shm_size-1 downto CONF.amba_word_size/16);
509
      adramo_data_out  : out std_logic_vector(CONF.word_size-1 downto 0));
510
  end component;
511
 
512
  -- Componentdeclaration for AMBA Extension-Module
513
  component ext_AMBA
514
    generic(
515
      CONF       : scarts_conf_type;
516
      DRAMOffset : bit_vector(31 downto 8) := (others => '0')
517
      );
518
    port(
519
      -- normal signals
520
      clk          : in  STD_ULOGIC;
521
      rst          : in  STD_ULOGIC;
522
      extsel       : in  STD_ULOGIC;
523
      ambadramlock : out STD_ULOGIC;
524
      transmode    : in  STD_ULOGIC;
525
      -- Extension-Module Interface
526
      exti         : in  module_in_type;
527
      exto         : out module_out_type;
528
      addr_high    : in  std_logic_vector(31 downto 15);
529
      -- Gaisler Interrupt
530
      gIRQ         : out STD_ULOGIC;
531
      -- stall processor
532
      scarts_hold    : out STD_ULOGIC;
533
      -- AMBA-Interface
534
      AMBAI        : in  ahb_master_in_type;
535
      AMBAO        : out ahb_master_out_type;
536
      -- DRAM-Interface
537
      --ambadram_ren : out STD_ULOGIC;
538
 
539
      AtD_write_en  : out std_ulogic;
540
      AtD_byte_en   : out std_logic_vector(3 downto 0);
541
      AtD_data_in   : out std_logic_vector(CONF.word_size-1 downto 0);
542
      AtD_addr      : out std_logic_vector(CONF.amba_shm_size-1 downto CONF.amba_word_size/16);
543
      DtA_data_out  : in  std_logic_vector(CONF.word_size-1 downto 0)
544
      );
545
  end component;
546
 
547
  -- Componentdeclaration for AMBA-Statemachine
548
  component AMBA_AHBMasterStatemachine
549
    port(HRESET : in STD_ULOGIC;
550
         HCLK  : in STD_ULOGIC;
551
         -- AHB Master Input
552
         AMBAI : in ahb_master_in_type;
553
         -- AHB Master Output
554
         AMBAO : out ahb_master_out_type;
555
         -- Bridge Signalflow SCARTS to AMBA
556
         BStA  : in brg_scarts_to_amba_type;
557
         -- Bridge Signalflow AMBA to SCARTS
558
         BAtS  : out brg_amba_to_scarts_type);
559
  end component;
560
 
561
  -------------------------------------------------------------------------------
562
  -- MiniUART
563
  -------------------------------------------------------------------------------  
564
  constant DATA_W        : integer := 16;
565
  constant EXTREG_S      : integer := 8;
566
 
567
  constant EXT_ACT : std_logic := '1';
568
 
569
-------------------------------------------------------------------------------
570
-------------------------------------------------------------------------------
571
--                             KONSTANTEN
572
-------------------------------------------------------------------------------  
573
-------------------------------------------------------------------------------
574
 
575
  -- globale Konstanten TODO: nur für einzelne Tests!
576
  --constant EXT_ACT         : std_logic := '1';
577
  constant OUTD_ACT : std_logic := '1';  -- Output Disable
578
  constant FAILSAFE : std_logic := '1';  -- Failsafestate
579
 
580
--  constant MINIUART_BASE : integer := 51;  --TODO: richtige BaseAddr herausfinden!!!
581
--  constant MINIUART_INTVEC : std_logic_vector(16-1 downto 0) := (others => '0');
582
 
583
  -- Register allgemein
584
--   constant DATA0        : integer := 2;
585
--   constant DATA1        : integer := 3;
586
--   constant DATA2        : integer := 4;
587
--   constant DATA3        : integer := 5;
588
--   constant DATA4        : integer := 6;
589
--   constant DATA5        : integer := 7;
590
  constant MSGREG_LOW   : integer := 6;--DATA2;   -- Message register
591
  constant MSGREG_HIGH  : integer := 7;--DATA2;   -- Message register
592
  constant UBRSREG_LOW  : integer := 4;--DATA5;  -- UART Baud Rate Selection Register
593
  constant UBRSREG_HIGH : integer := 5;--DATA5;  -- UART Baud Rate Selection Register
594
 
595
  --constant STATUSREG_CUST      : integer := 1; -- Already defined
596
--  constant CONFIGREG_CUST      : integer := 3; -- Already defined
597
  -- Statusregister
598
--constant EXTSTATUS    : integer := 0;
599
--  constant EXTSTATUS_CUST    : integer := 1;
600
  constant STA_TRANSERR  : integer := 6;--14;
601
  constant STA_PARERR    : integer := 5;--13;f
602
  constant STA_EVF       : integer := 4;--12;
603
  constant STA_OVF       : integer := 3;--11;
604
  constant STA_RBR       : integer := 2;--10;
605
  constant STA_TBR       : integer := 1;--9;     
606
--constant ST_LOOR      : integer := 7;
607
--constant ST_FSS       : integer := 4;
608
--constant ST_BUSY      : integer := 3;
609
--constant ST_ERR       : integer := 2;
610
--constant ST_RDY       : integer := 1;
611
--constant ST_INT       : integer := 0;
612
 
613
  -- Configregister
614
--constant EXTCONFIG      : integer := 1;
615
--constant EXTCONF_LOOW    : integer := 7;
616
--constant EXTCONF_EFSS    : integer := 4;
617
constant EXTCONF_OUTD    : integer := 3;
618
--constant EXTCONF_SRES    : integer := 2;
619
--constant EXTCONF_ID      : integer := 1;
620
--constant EXTCONF_INTA    : integer := 0;
621
 
622
  -- UARTConfigregister
623
  constant EXTUARTCONF         : integer := CONFIGREG_CUST;--4; --DATA0;
624
  constant EXTCONF_PARENA      : integer := 7;--15;
625
  constant EXTCONF_PARODD      : integer := 6;--14;
626
  constant EXTCONF_STOP        : integer := 5;--13;
627
  constant EXTCONF_TRCTRL      : integer := 4;--12;
628
  constant EXTCONF_MSGL_H      : integer := 3;--11;
629
  constant EXTCONF_MSGL_L      : integer := 0;--8;
630
 
631
  -- Commandregister
632
  constant EXTCMD          : integer := 8;--DATA1;  
633
  constant EXTCMD_ERRI    : integer := 7;
634
  constant EXTCMD_EI      : integer := 6;
635
  constant EXTCMD_ASA_H   : integer := 5;
636
  constant EXTCMD_ASA_L   : integer := 3;
637
  constant EXTCMD_EVS_H   : integer := 2;
638
  constant EXTCMD_EVS_L   : integer := 1;
639
 
640
  -- Config & Statusbits
641
  constant PARITY_ENABLE : std_logic := '1';  -- Parity enabled
642
  constant SECOND_STOPBIT : std_logic := '1';  -- Zweites Stopbit enabled
643
  constant RB_READY : std_logic := '1';  -- Receive Buffer Ready
644
  constant TB_READY : std_logic := '1';  -- Transmit Buffer Ready
645
  constant FRAME_ERROR : std_logic := '1';  -- !!!ACHTUNG: FE ist immer 1!!!
646
  constant PARITY_ERROR : std_logic := '1';  -- Parity Error
647
  constant OVERFLOW : std_logic := '1';  -- Overflow occured
648
  constant TRCTRL_ENA : std_logic := '1';  -- Error Control enabled
649
 
650
 
651
  -- Transmitter
652
  constant TRANS_COMP : std_logic := '1';  -- Transmission Complete
653
 
654
  -- Receiver
655
  constant RECEIVER_ENABLED : std_logic := '1';  -- !!!ACHTUNG: muss 1 sein!!!
656
  constant REC_BUSY : std_logic := '1';  -- Receiving / Startbit detected
657
  constant REC_COMPLETE : std_logic := '1';  -- komplette Nachricht empfangen
658
 
659
  -- Busdriver
660
  constant BUSDRIVER_ON : std_logic := '1';  -- Einschaltsignal für Busdriver
661
 
662
  -- Baud Rate Generator
663
  constant BRG_ON : std_logic := '1';     -- Einschaltsignal für BRG
664
 
665
  -- Events
666
  constant EV_NONE  : std_logic_vector(1 downto 0) := "00";  -- no event
667
  constant EV_SBD   : std_logic_vector(1 downto 0) := "01";  -- Startbitdetection
668
  constant EV_RCOMP : std_logic_vector(1 downto 0) := "10";  -- Receive completion
669
  constant EV_TCOMP : std_logic_vector(1 downto 0) := "11";  -- Transmit completion
670
  constant EV_OCC : std_logic := '1';     -- Event occured (muß 1 sein!!!)
671
  constant EV_INT : std_logic := '1';   -- Event Interrupt enable
672
 
673
  -- Assigned Actions
674
  constant ASA_STRANS : std_logic_vector(2 downto 0) := "011";  -- start transmission
675
  constant ASA_EREC : std_logic_vector(2 downto 0) := "100";  -- enable receiver
676
  constant ASA_DREC : std_logic_vector(2 downto 0) := "101";  -- disable receiver
677
 
678
 
679
-------------------------------------------------------------------------------
680
-------------------------------------------------------------------------------
681
--                               TYPES
682
-------------------------------------------------------------------------------  
683
-------------------------------------------------------------------------------
684
 
685
  -- Messagelength Signaltyp
686
  subtype MsgLength_type is std_logic_vector((EXTCONF_MSGL_H - EXTCONF_MSGL_L) downto 0);
687
 
688
  -- Nachricht
689
  subtype Data_type is std_logic_vector(15 downto 0);
690
 
691
-------------------------------------------------------------------------------
692
-------------------------------------------------------------------------------
693
--                             KOMPONENTEN
694
-------------------------------------------------------------------------------  
695
-------------------------------------------------------------------------------
696
 
697
  component ext_miniUART IS
698
         PORT(   ---------------------------------------------------------------
699
                -- Generic Ports
700
                ---------------------------------------------------------------
701
                clk           : IN  std_logic;
702
                extsel        : in  std_logic;
703
                Exti          : in module_in_type;
704
                Exto          : out module_out_type;
705
 
706
                ---------------------------------------------------------------
707
                -- Module Specific Ports
708
                ---------------------------------------------------------------
709
                RxD           : IN std_logic;  -- Empfangsleitung
710
                TxD           : OUT std_logic  --;  -- Sendeleitung
711
                );
712
  END component;
713
 
714
 
715
  component miniUART_control
716
    port (
717
      clk : in std_logic;
718
      reset : in std_logic;
719
--      MsgLength : in MsgLength_type;      
720
      ParEna : in std_logic;              -- Parity?
721
      Odd : in std_logic;                 -- Odd or Even Parity?
722
      AsA : in std_logic_vector(2 downto 0);  -- Assigned Action
723
      EvS : in std_logic_vector(1 downto 0);  -- Event Selector
724
      Data_r : in Data_type;              -- received Data
725
      ParBit_r : in std_logic;            -- empfangenes Paritybit
726
      FrameErr : in std_logic;
727
      RecComp : in std_logic;             -- Receive Complete
728
      RecBusy : in std_logic;             -- Reciever Busy (Startbit detected)        
729
      TransComp : in std_logic;           -- Transmission complete
730
      EnaRec : out std_logic;             -- Enable receiver
731
      Data_r_out : out Data_type;         -- empfangene Daten
732
      FrameErr_out : out std_logic;
733
      ParityErr : out std_logic;
734
      RBR : out std_logic;                -- Receive Buffer Ready (Rec Complete)
735
      StartTrans : out std_logic;         -- Start Transmitter (halten bis TrComp!)
736
      TBR : out std_logic;                -- Transmit Buffer Ready (MSGREG read,
737
                                          -- transmitter started)
738
      event : out std_logic               -- Selected Event occured!
739
      );
740
  end component;
741
 
742
 
743
  component miniUART_transmitter
744
    port (
745
      clk : in std_logic;
746
      reset : in std_logic;
747
      MsgLength : in MsgLength_type;
748
      Stop2 : in std_logic;               -- Zweites Stopbit?
749
      ParEna : in std_logic;              -- Parity?
750
      ParBit : in std_logic;              -- Vorberechnetes Paritybit
751
      Data : in Data_type;
752
      tp : in std_logic;                  -- Transmitpulse vom BRG
753
      TransEna : out std_logic;           -- Busdriver einschalten
754
      TrComp : out std_logic;              -- Transmission complete
755
      TxD : out std_logic                 -- Sendeausgang
756
      );
757
  end component;
758
 
759
 
760
  component miniUART_receiver
761
    port (
762
      clk : in std_logic;
763
      reset : in std_logic;
764
      enable : in std_logic;              -- Receiver eingeschaltet?
765
      MsgLength : in MsgLength_type;
766
      Stop2 : in std_logic;               -- Zweites Stopbit?
767
      ParEna : in std_logic;              -- Parity?
768
      rp : in std_logic;                  -- Receivepulse vom BRG
769
      RxD : in std_logic;                 -- Empfangseingang
770
      Data : out Data_type;
771
      ParBit : out std_logic;             -- Empfangenes Paritybit
772
      RecEna : out std_logic;             -- Busdriver einschalten
773
      StartRecPulse : out std_logic;      -- Receivepulse generieren
774
      busy : out std_logic;               -- Receiving / Startbit detected
775
      RecComplete : out std_logic;        -- komplettes Frame empfangen
776
      FrameErr : out std_logic
777
      );
778
  end component;
779
 
780
 
781
  component miniUART_BRG
782
    port (
783
      clk : in std_logic;
784
      reset : in std_logic;
785
      StartTrans : in std_logic;          -- Transmitterpulse eingeschaltet?
786
      StartRec : in std_logic;            -- Receiverpulse eingeschaltet?
787
      UBRS : in std_logic_vector(15 downto 0);  -- Baud Rate Selection Register 
788
                                                -- (12bit ganzzahlig, 4bit fraction)
789
      tp : out std_logic;                 -- Transmitterpulse
790
      rp : out std_logic                  -- Receiverpulse
791
      );
792
  end component;
793
 
794
 
795
  component miniUART_busdriver
796
    port (
797
      clk : in std_logic;
798
      reset : in std_logic;
799
      OutD : in std_logic;                -- Output disable
800
      TransEna : in std_logic;            -- Einschalten, von Transmitter
801
      RecEna : in std_logic;              -- Einschalten, von Receiver
802
      Data_t : in std_logic;              -- zu sendendes Bit
803
      Data_r : out std_logic;             -- empfangenes Bit
804
      TxD : out std_logic;                -- Sendeleitung
805
      RxD : in std_logic                  -- Empfangsleitung
806
      );
807
  end component;
808
 
809
 
810
end scarts_core_pkg;

powered by: WebSVN 2.1.0

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