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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [processor/] [VHDL/] [scarts_core/] [scarts.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
use ieee.numeric_std.all;
22
 
23
use work.scarts_core_pkg.all;
24
use work.scarts_pkg.all;
25
 
26
entity scarts is
27
  generic (
28
    CONF : scarts_conf_type := (
29
      tech => ALTERA,
30
      word_size => 32,
31
      boot_rom_size => 8,
32
      instr_ram_size => 13,
33
      data_ram_size => 13,
34
      use_iram => true,
35
      use_amba => false,
36
      amba_shm_size => 8,
37
      amba_word_size => 32,
38
      gdb_mode => 0,
39
      bootrom_base_address => 15
40
      ));
41
  port (
42
    clk       : in  std_ulogic;
43
    extrst    : in  std_ulogic;
44
    sysrst   : out std_ulogic;
45
    --Extensiom Module Interface
46
    scarts_i    : in  scarts_in_type;
47
    scarts_o    : out scarts_out_type;
48
    -- Debug Interface
49
    debugi_if : IN  debug_if_in_type;
50
    debugo_if : OUT debug_if_out_type
51
    );
52
end scarts;
53
 
54
architecture behaviour of scarts is
55
 
56
  constant WORD_W    : natural                              := CONF.word_size;
57
  subtype WORD is std_logic_vector(WORD_W-1 downto 0);
58
  constant EXTMODACT : std_logic_vector(WORD_W-1 downto 15) := (others => '1');
59
 
60
  type reg_type is record
61
    extdata       : std_logic_vector(31 downto 0);
62
    old_memaccess : MEMACCESSTYPE;
63
    old_signedac : std_ulogic;
64
    old_address  : std_logic_vector(1 downto 0);
65
    ext_mod_sel  : std_ulogic;
66
    transmode    : std_ulogic;
67
  end record;
68
 
69
  type scarts_ext_type is record
70
    data     : std_logic_vector(31 downto 0);
71
    addr     : std_logic_vector(14 downto 0);
72
    byte_en  : std_logic_vector(3 downto 0);
73
    write_en : std_ulogic;
74
  end record;
75
 
76
  signal r_next : reg_type;
77
 
78
  signal r : reg_type :=
79
    (
80
      extdata       => (others => '0'),
81
      old_memaccess => MEM_DISABLE,
82
      old_signedac  => '0',
83
      old_address   => (others => '0'),
84
      ext_mod_sel   => '0',
85
      transmode     => '0'
86
      );
87
 
88
 
89
  -- internal scarts Core Signals 
90
  signal intrst    : std_ulogic;
91
  signal exthold   : std_ulogic;
92
  signal cpu_halt  : std_ulogic;
93
  signal progrst   : std_ulogic;
94
 
95
  signal regfi_wdata       : std_logic_vector(CONF.word_size-1 downto 0);
96
  signal regfi_waddr       : std_logic_vector(REGADDR_W-1 downto 0);
97
  signal regfi_wen         : std_ulogic;
98
  signal regfi_raddr1      : std_logic_vector(REGADDR_W-1 downto 0);
99
  signal regfi_raddr2      : std_logic_vector(REGADDR_W-1 downto 0);
100
  signal regfo_rdata1      : std_logic_vector(CONF.word_size-1 downto 0);
101
  signal regfo_rdata2      : std_logic_vector(CONF.word_size-1 downto 0);
102
 
103
  signal corei_interruptin : std_logic_vector(15 downto 0);
104
  signal corei_extdata     : std_logic_vector(CONF.word_size-1 downto 0);
105
  signal coreo_extwr       : std_ulogic;
106
  signal coreo_signedac    : std_ulogic;
107
  signal coreo_extaddr     : std_logic_vector(CONF.word_size-1 downto 0);
108
  signal coreo_extdata     : std_logic_vector(CONF.word_size-1 downto 0);
109
  signal coreo_memaccess   : MEMACCESSTYPE;
110
  signal coreo_memen       : std_ulogic;
111
  signal coreo_illop       : std_ulogic;
112
 
113
  signal bromi_addr        : std_logic_vector(CONF.word_size-1 downto 0);
114
  signal bromo_data        : INSTR;
115
 
116
  signal vecti_data_in     : std_logic_vector(CONF.word_size-1 downto 0);
117
  signal vecti_interruptnr : std_logic_vector(EXCADDR_W-2 downto 0);
118
  signal vecti_trapnr      : std_logic_vector(EXCADDR_W-1 downto 0);
119
  signal vecti_wrvecnr     : std_logic_vector(EXCADDR_W-1 downto 0);
120
  signal vecti_intcmd      : std_ulogic;
121
  signal vecti_wrvecen     : std_ulogic;
122
  signal vecto_data_out    : std_logic_vector(CONF.word_size-1 downto 0);
123
 
124
  signal sysci_staen       : std_ulogic;
125
  signal sysci_stactrl     : STACTRL;
126
  signal sysci_staflag     : std_logic_vector(ALUFLAG_W-1 downto 0);
127
  signal sysci_interruptin : std_logic_vector(15 downto 0);
128
  signal sysci_fptrwnew    : std_logic_vector(CONF.word_size-1 downto 0);
129
  signal sysci_fptrxnew    : std_logic_vector(CONF.word_size-1 downto 0);
130
  signal sysci_fptrynew    : std_logic_vector(CONF.word_size-1 downto 0);
131
  signal sysci_fptrznew    : std_logic_vector(CONF.word_size-1 downto 0);
132
 
133
  signal sysco_condflag    : std_ulogic;
134
  signal sysco_carryflag   : std_ulogic;
135
  signal sysco_interruptnr : std_logic_vector(EXCADDR_W-2 downto 0);
136
  signal sysco_intcmd      : std_ulogic;
137
  signal sysco_fptrw       : std_logic_vector(CONF.word_size-1 downto 0);
138
  signal sysco_fptrx       : std_logic_vector(CONF.word_size-1 downto 0);
139
  signal sysco_fptry       : std_logic_vector(CONF.word_size-1 downto 0);
140
  signal sysco_fptrz       : std_logic_vector(CONF.word_size-1 downto 0);
141
 
142
  signal progo_instrsrc    : std_ulogic;
143
  signal progo_prupdate    : std_ulogic;
144
  signal progo_praddr      : std_logic_vector(CONF.instr_ram_size-1 downto 0);
145
  signal progo_prdata      : INSTR;
146
 
147
 
148
  signal drami_write_en  : std_ulogic;
149
  signal drami_byte_en   : std_logic_vector(3 downto 0);
150
  signal drami_data_in   : std_logic_vector(31 downto 0);
151
  signal drami_addr      : std_logic_vector(CONF.data_ram_size-1 downto 2);
152
  signal dramo_data_out  : std_logic_vector(31 downto 0);
153
 
154
  signal syscsel   : std_ulogic;
155
  signal progexto  : module_out_type;
156
  signal progsel   : std_ulogic;
157
  signal syscexto  : module_out_type;
158
  signal exti      : module_in_type;
159
  signal dramsel   : std_ulogic;
160
  signal scarts_ext : scarts_ext_type;
161
 
162
  -- signals required for debug unit
163
  signal miniUARTsel      : std_ulogic;
164
  signal miniUARTexto     : module_out_type;
165
  signal D_RxD, D_TxD     : std_ulogic;
166
  signal breakpointsel    : std_ulogic;
167
  signal breakpointexto   : module_out_type;
168
  signal watchpointsel    : std_ulogic;
169
  signal watchpointexto   : module_out_type;
170
  signal s_watchpoint_act : std_ulogic;
171
 
172
  signal s_debugo_wdata      : INSTR;
173
  signal s_debugo_waddr      : std_logic_vector(CONF.instr_ram_size-1 downto 0);
174
  signal s_debugo_wen        : std_ulogic;
175
  signal s_debugo_raddr      : std_logic_vector(CONF.instr_ram_size-1 downto 0);
176
  signal s_debugo_rdata      : INSTR;
177
  signal s_debugo_read_en    : std_ulogic;
178
  signal s_debugo_hi_addr    : std_logic_vector(CONF.word_size-1 downto 15);
179
  signal s_debugi_rdata      : INSTR;
180
 
181
  -- signal for stalling scarts
182
  signal scarts_hold    : std_ulogic;
183
 
184
begin
185
 
186
  s_debugo_read_en <= coreo_memen;
187
  s_debugo_hi_addr <= coreo_extaddr(WORD_W-1 downto 15);
188
 
189
  core_unit : scarts_core
190
  generic map(
191
    CONF => CONF)
192
  port map(
193
    clk               => clk,
194
    sysrst            => intrst,
195
    hold              => cpu_halt,
196
 
197
    iramo_rdata       => s_debugi_rdata,
198
    irami_wdata       => s_debugo_wdata,
199
    irami_waddr       => s_debugo_waddr,
200
    irami_wen         => s_debugo_wen,
201
    irami_raddr       => s_debugo_raddr,
202
 
203
    regfi_wdata       => regfi_wdata,
204
    regfi_waddr       => regfi_waddr,
205
    regfi_wen         => regfi_wen,
206
    regfi_raddr1      => regfi_raddr1,
207
    regfi_raddr2      => regfi_raddr2,
208
    regfo_rdata1      => regfo_rdata1,
209
    regfo_rdata2      => regfo_rdata2,
210
 
211
    corei_interruptin => corei_interruptin,
212
    corei_extdata     => corei_extdata,
213
    coreo_extwr       => coreo_extwr,
214
    coreo_signedac    => coreo_signedac,
215
    coreo_extaddr     => coreo_extaddr,
216
    coreo_extdata     => coreo_extdata,
217
    coreo_memaccess   => coreo_memaccess,
218
    coreo_memen       => coreo_memen,
219
    coreo_illop       => coreo_illop,
220
 
221
    bromi_addr        => bromi_addr,
222
    bromo_data        => bromo_data,
223
 
224
    vecti_data_in     => vecti_data_in,
225
    vecti_interruptnr => vecti_interruptnr,
226
    vecti_trapnr      => vecti_trapnr,
227
    vecti_wrvecnr     => vecti_wrvecnr,
228
    vecti_intcmd      => vecti_intcmd,
229
    vecti_wrvecen     => vecti_wrvecen,
230
    vecto_data_out    => vecto_data_out,
231
 
232
    sysci_staen       => sysci_staen,
233
    sysci_stactrl     => sysci_stactrl,
234
    sysci_staflag     => sysci_staflag,
235
    sysci_interruptin => sysci_interruptin,
236
    sysci_fptrwnew    => sysci_fptrwnew,
237
    sysci_fptrxnew    => sysci_fptrxnew,
238
    sysci_fptrynew    => sysci_fptrynew,
239
    sysci_fptrznew    => sysci_fptrznew,
240
 
241
    sysco_condflag    => sysco_condflag,
242
    sysco_carryflag   => sysco_carryflag,
243
    sysco_interruptnr => sysco_interruptnr,
244
    sysco_intcmd      => sysco_intcmd,
245
    sysco_fptrw       => sysco_fptrw,
246
    sysco_fptrx       => sysco_fptrx,
247
    sysco_fptry       => sysco_fptry,
248
    sysco_fptrz       => sysco_fptrz,
249
 
250
    progo_instrsrc    => progo_instrsrc,
251
    progo_prupdate    => progo_prupdate,
252
    progo_praddr      => progo_praddr,
253
    progo_prdata      => progo_prdata);
254
 
255
  regf_unit : scarts_regf
256
    generic map (
257
      CONF => CONF)
258
    port map(
259
      wclk  => clk,
260
      rclk  => clk,
261
      hold  => cpu_halt,
262
 
263
      wdata       => regfi_wdata,
264
      waddr       => regfi_waddr,
265
      wen         => regfi_wen,
266
      raddr1      => regfi_raddr1,
267
      raddr2      => regfi_raddr2,
268
      rdata1      => regfo_rdata1,
269
      rdata2      => regfo_rdata2);
270
 
271
  dram_unit : scarts_dram
272
    generic map (
273
      CONF => CONF)
274
    port map(
275
      clk     => clk,
276
      hold    => cpu_halt,
277
      dramsel => dramsel,
278
 
279
      write_en => drami_write_en,
280
      byte_en  => drami_byte_en,
281
      data_in  => drami_data_in,
282
      addr     => drami_addr,
283
 
284
      data_out => dramo_data_out);
285
 
286
  brom_unit : scarts_brom
287
    generic map (
288
      CONF => CONF)
289
    port map(
290
      clk   => clk,
291
      hold  => cpu_halt,
292
      addr        => bromi_addr,
293
      data        => bromo_data);
294
 
295
  vect_unit : scarts_vectab
296
    generic map (
297
      CONF => CONF)
298
    port map(
299
      clk   => clk,
300
      hold  => cpu_halt,
301
 
302
      data_in     => vecti_data_in,
303
      interruptnr => vecti_interruptnr,
304
      trapnr      => vecti_trapnr,
305
      wrvecnr     => vecti_wrvecnr,
306
      intcmd      => vecti_intcmd,
307
      wrvecen     => vecti_wrvecen,
308
      data_out    => vecto_data_out);
309
 
310
  sysc_unit : scarts_sysc
311
    generic map (
312
      CONF => CONF)
313
    port map(
314
      clk      => clk,
315
      extrst   => progrst,
316
      sysrst   => intrst,
317
      hold     => exthold,
318
      cpu_halt => cpu_halt,
319
      extsel   => syscsel,
320
      exti     => exti,
321
      exto     => syscexto,
322
 
323
      staen       => sysci_staen,
324
      stactrl     => sysci_stactrl,
325
      staflag     => sysci_staflag,
326
      interruptin => sysci_interruptin,
327
      fptrwnew    => sysci_fptrwnew,
328
      fptrxnew    => sysci_fptrxnew,
329
      fptrynew    => sysci_fptrynew,
330
      fptrznew    => sysci_fptrznew,
331
 
332
      condflag    => sysco_condflag,
333
      carryflag   => sysco_carryflag,
334
      interruptnr => sysco_interruptnr,
335
      intcmd      => sysco_intcmd,
336
      fptrw       => sysco_fptrw,
337
      fptrx       => sysco_fptrx,
338
      fptry       => sysco_fptry,
339
      fptrz       => sysco_fptrz);
340
 
341
-------------------------------------------------------------------------------
342
-- Begin: Configurable SCARTS Modules
343
-------------------------------------------------------------------------------
344
 
345
 
346
-------------------------------------------------------------------------------
347
-- Instruction RAM Configuration
348
-------------------------------------------------------------------------------
349
  use_prog_gen : if (CONF.use_iram = true) generate
350
    iram_unit : scarts_iram
351
      generic map (
352
        CONF => CONF)
353
      port map (
354
        wclk  => clk,
355
        rclk  => clk,
356
        hold  => cpu_halt,
357
 
358
        wdata => s_debugo_wdata,
359
        waddr => s_debugo_waddr,
360
        wen   => s_debugo_wen,
361
        raddr => s_debugo_raddr,
362
        rdata => s_debugo_rdata);
363
 
364
    prog_unit : scarts_prog
365
      generic map (
366
        CONF => CONF)
367
      port map(
368
        clk     => clk,
369
        extrst  => extrst,
370
        progrst => progrst,
371
        hold    => cpu_halt,
372
        extsel  => progsel,
373
        exti    => exti,
374
        exto    => progexto,
375
 
376
        instrsrc    => progo_instrsrc,
377
        prupdate    => progo_prupdate,
378
        praddr      => progo_praddr,
379
        prdata      => progo_prdata);
380
  end generate;
381
 
382
  no_prog_gen : if (CONF.use_iram = false) generate
383
    s_debugo_rdata <= (others => '0');
384
    progo_instrsrc <= '0';
385
    progo_prupdate <= '0';
386
    progo_praddr   <= (others => '0');
387
    progo_prdata   <= (others => '0');
388
    progexto       <= ((others           => '0'), '0');
389
    progrst        <= extrst;
390
  end generate;
391
 
392
-------------------------------------------------------------------------------
393
-- Debug Unit configuration
394
-------------------------------------------------------------------------------              
395
 
396
 
397
  ext_miniUART_unit : ext_miniUART
398
    port map (
399
      clk    => clk,
400
      extsel => miniUARTsel,
401
      exti   => exti,
402
      exto   => miniUARTexto,
403
      RxD    => D_RxD,
404
      TxD    => D_TxD);
405
 
406
  use_debug_gen : if (CONF.gdb_mode = 1) generate
407
 
408
    ext_breakpoint_unit : ext_breakpoint
409
      generic map (
410
        CONF => CONF)
411
      port map (
412
        clk            => clk,
413
        extsel         => breakpointsel,
414
        exti           => exti,
415
        exto           => breakpointexto,
416
 
417
        debugo_wdata   => s_debugo_wdata,
418
        debugo_waddr   => s_debugo_waddr,
419
        debugo_wen     => s_debugo_wen,
420
        debugo_raddr   => s_debugo_raddr,
421
        debugo_rdata   => s_debugo_rdata,
422
        debugo_read_en => s_debugo_read_en,
423
        debugo_hi_addr => s_debugo_hi_addr,
424
        debugi_rdata   => s_debugi_rdata,
425
        watchpoint_act => s_watchpoint_act
426
        );
427
 
428
    ext_watchpoint_unit : ext_watchpoint
429
      generic map (
430
        CONF => CONF)
431
      port map (
432
        clk     => clk,
433
        extsel  => watchpointsel,
434
        exti    => exti,
435
        exto    => watchpointexto,
436
        read_en => s_debugo_read_en,
437
        hi_addr => s_debugo_hi_addr       --lower 15 bits in exti.addr
438
        );
439
 
440
  end generate;
441
 
442
 
443
  no_debug_gen : if (CONF.gdb_mode = 0) generate
444
  --  miniUARTexto        <= ((others => '0'), '0');
445
    breakpointexto      <= ((others => '0'), '0');
446
    watchpointexto      <= ((others => '0'), '0');
447
    s_debugi_rdata <= s_debugo_rdata;
448
 
449
 --   D_TxD               <= '1';
450
  end generate;
451
 
452
  scarts_hold     <= not HOLD_ACT;
453
 
454
-------------------------------------------------------------------------------
455
-- End Configurable SCARTS Modules
456
-------------------------------------------------------------------------------
457
 
458
 
459
  comb : process(r, scarts_i, scarts_hold, dramo_data_out, syscexto, progexto, breakpointexto, miniUARTexto,
460
                 debugi_if, D_TxD, watchpointexto,
461
                 coreo_extwr, coreo_signedac, coreo_extaddr, coreo_extdata, coreo_memaccess, coreo_memen,
462
                 scarts_ext, intrst, cpu_halt)  --erweitern!
463
    variable v              : reg_type;
464
    variable v_aligned_data : std_logic_vector(31 downto 0);
465
  begin
466
    v := r;
467
 
468
    scarts_ext.data     <= (others => '0');
469
    scarts_ext.addr     <= coreo_extaddr(14 downto 0);
470
    scarts_ext.byte_en  <= (others => '0');
471
    scarts_ext.write_en <= coreo_extwr;
472
    if (CONF.use_amba = true and CONF.word_size = 32) then
473
      addr_high(31 downto 15) <= coreo_extaddr(31 downto 15);
474
    else
475
      addr_high(31 downto 15) <= (others => '0');
476
    end if;
477
    --
478
    -- write access
479
    --
480
    case coreo_memaccess is
481
      when BYTE_A =>
482
        scarts_ext.data(7 downto 0)   <= coreo_extdata(7 downto 0);
483
        scarts_ext.data(15 downto 8)  <= coreo_extdata(7 downto 0);
484
        scarts_ext.data(23 downto 16) <= coreo_extdata(7 downto 0);
485
        scarts_ext.data(31 downto 24) <= coreo_extdata(7 downto 0);
486
        case coreo_extaddr(1 downto 0) is
487
          when "00" =>
488
            scarts_ext.byte_en(0) <= '1';
489
          when "01" =>
490
            scarts_ext.byte_en(1) <= '1';
491
          when "10" =>
492
            scarts_ext.byte_en(2) <= '1';
493
          when "11" =>
494
            scarts_ext.byte_en(3) <= '1';
495
          when others =>
496
            null;
497
        end case;
498
      when HWORD_A =>
499
        scarts_ext.data(15 downto 0)  <= coreo_extdata(15 downto 0);
500
        scarts_ext.data(31 downto 16) <= coreo_extdata(15 downto 0);
501
        case coreo_extaddr(1) is
502
          when '0' =>
503
            scarts_ext.byte_en(1 downto 0) <= "11";
504
          when '1' =>
505
            scarts_ext.byte_en(3 downto 2) <= "11";
506
          when others =>
507
            null;
508
        end case;
509
      when WORD_A =>
510
        if (CONF.word_size = 32) then
511
          scarts_ext.data                <= coreo_extdata;
512
          scarts_ext.byte_en(3 downto 0) <= "1111";
513
        else
514
          null;
515
        end if;
516
      when others =>
517
        null;
518
    end case;
519
 
520
    --
521
    -- read access
522
    --
523
    v.old_memaccess := coreo_memaccess;
524
    v.old_signedac  := coreo_signedac;
525
    v.old_address   := coreo_extaddr(1 downto 0);
526
 
527
    v_aligned_data := (others => '0');
528
    if r.ext_mod_sel = '1' then
529
      v_aligned_data := r.extdata;
530
    else
531
      v_aligned_data := dramo_data_out;
532
    end if;
533
 
534
    case r.old_address is
535
      when "00" =>
536
        v_aligned_data := v_aligned_data;
537
      when "01" =>
538
        v_aligned_data(7 downto 0) := v_aligned_data(15 downto 8);
539
      when "10" =>
540
        v_aligned_data(15 downto 0) := v_aligned_data(31 downto 16);
541
      when "11" =>
542
        v_aligned_data(7 downto 0) := v_aligned_data(31 downto 24);
543
      when others =>
544
        null;
545
    end case;
546
 
547
    case r.old_memaccess is
548
      when BYTE_A =>
549
        if (r.old_signedac = SIGNED_AC) then
550
          v_aligned_data(31 downto 8) := (others => v_aligned_data(7));
551
        else
552
          v_aligned_data(31 downto 8) := (others => '0');
553
        end if;
554
      when HWORD_A =>
555
        if (r.old_signedac = SIGNED_AC) then
556
          v_aligned_data(31 downto 16) := (others => v_aligned_data(15));
557
        else
558
          v_aligned_data(31 downto 16) := (others => '0');
559
        end if;
560
      when others =>
561
        null;
562
    end case;
563
 
564
    corei_extdata <= v_aligned_data(WORD_W-1 downto 0);
565
 
566
    syscsel       <= '0';
567
    progsel       <= '0';
568
    scarts_o.extsel <= '0';
569
    dramsel       <= '0';
570
    miniUARTsel   <= '0';
571
    breakpointsel <= '0';
572
    watchpointsel <= '0';
573
 
574
    --
575
    -- module selection
576
    --
577
    v.ext_mod_sel := '0';
578
    if (coreo_extaddr(WORD_W-1 downto 15) = EXTMODACT) then
579
      v.ext_mod_sel := '1';
580
      case coreo_extaddr(14 downto 5) is
581
        when "1111111111" =>            -- (-32)
582
          --SYSC Module
583
          syscsel <= coreo_extwr or coreo_memen;
584
        when "1111111110" =>            -- (-64)
585
          --PROG Module
586
          if (CONF.use_iram = true) then
587
            progsel <= coreo_extwr or coreo_memen;
588
          end if;
589
 
590
     -- when "1111111110" => -- Reserved for Protection Unit  (-96)
591
 
592
        when "1111111100" => -- (-128)
593
          --miniUART Module for debug purpose
594
 
595
            miniUARTsel <= coreo_extwr or coreo_memen;
596
 
597
        when "1111111011" =>  -- (-160)
598
          --breakpoint Module
599
          if (CONF.gdb_mode = 1) then
600
            breakpointsel <= coreo_extwr or coreo_memen;
601
          end if;
602
        when "1111111010" =>  -- (-192)
603
          --watchpoint Module
604
          if (CONF.gdb_mode = 1) then
605
            watchpointsel <= coreo_extwr or coreo_memen;
606
          end if;
607
 
608
        when others =>
609
          null;
610
      end case;
611
      scarts_o.extsel <= coreo_extwr or coreo_memen;
612
    else
613
      if (CONF.word_size = 32) then
614
        if coreo_extaddr(31)='1' then
615
          v.ext_mod_sel := '1';
616
        else
617
          dramsel <= coreo_extwr or coreo_memen;
618
        end if;
619
      else
620
        dramsel <= coreo_extwr or coreo_memen;
621
      end if;
622
    end if;
623
 
624
    --
625
    -- build write back bus
626
    --
627
    v.extdata := (others => '0');
628
    for i in v.extdata'left downto v.extdata'right loop
629
      v.extdata(i) := scarts_i.data(i) or syscexto.data(i) or progexto.data(i) or breakpointexto.data(i) or watchpointexto.data(i) or miniUARTexto.data(i);
630
    end loop;
631
 
632
    --
633
    -- for external modules
634
    --
635
    scarts_o.data     <= scarts_ext.data;
636
    scarts_o.addr     <= scarts_ext.addr(14 downto 0);
637
    scarts_o.byte_en  <= scarts_ext.byte_en;
638
    scarts_o.write_en <= scarts_ext.write_en;
639
    scarts_o.reset    <= intrst;
640
 
641
    --
642
    -- for sys-ctrl-unit  programmer-unit breakpoint-unit and watchpoint-unit 
643
    --
644
    exti.data        <= scarts_ext.data;
645
    exti.addr        <= scarts_ext.addr(14 downto 0);
646
    exti.byte_en     <= scarts_ext.byte_en;
647
    exti.write_en    <= scarts_ext.write_en;
648
 
649
    -- common reset not used for sysctrl- and programmer-module
650
    exti.reset       <= intrst;         --'0';
651
    s_watchpoint_act <= watchpointexto.intreq;
652
    D_RxD            <= debugi_if.D_RxD;
653
    debugo_if.D_TxD  <= D_TxD;
654
 
655
 
656
    --
657
    -- for internal data memory
658
    --
659
    drami_data_in  <= scarts_ext.data;
660
    drami_addr     <= coreo_extaddr(CONF.data_ram_size-1 downto 2);
661
    drami_byte_en  <= scarts_ext.byte_en;
662
    drami_write_en <= scarts_ext.write_en;
663
 
664
    sysrst <= intrst;
665
    exthold         <= scarts_i.hold;
666
    scarts_o.cpu_halt <= cpu_halt;
667
 
668
    if (CONF.use_amba = true) then
669
      exthold <= scarts_hold or scarts_i.hold;
670
    else
671
      exthold <= scarts_i.hold;
672
    end if;
673
 
674
    r_next <= v;
675
  end process;
676
 
677
 
678
  reg : process(clk)                    --, intrst)
679
  begin
680
    if rising_edge(clk) then
681
      if intrst = RST_ACT then
682
        r.extdata       <= (others => '0');
683
        r.old_memaccess <= MEM_DISABLE;
684
        r.old_signedac  <= '0';
685
        r.old_address   <= (others => '0');
686
        r.ext_mod_sel   <= '0';
687
        r.transmode <= '0';
688
      else
689
        if (cpu_halt = not HOLD_ACT) then
690
          r <= r_next;
691
        end if;
692
      end if;
693
    end if;
694
  end process;
695
 
696
 
697
  process(coreo_illop, syscexto, progexto, miniUARTexto, breakpointexto, scarts_i)
698
  begin  -- process
699
    corei_interruptin(15 downto 0) <= (others => '0');
700
 
701
    -- internal interrupt sources
702
    corei_interruptin(15) <= coreo_illop;
703
    corei_interruptin(14) <= syscexto.intreq;
704
    corei_interruptin(13) <= progexto.intreq;
705
    corei_interruptin(12)  <= '0'; --Reserved for Protection CTRL Unit
706
    corei_interruptin(11)  <= miniUARTexto.intreq or breakpointexto.intreq;
707
 
708
    -- external interrupt sources   
709
    corei_interruptin(7 downto 0) <= scarts_i.interruptin;
710
 
711
  end process;
712
 
713
end behaviour;

powered by: WebSVN 2.1.0

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