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

Subversion Repositories System68

[/] [System68/] [trunk/] [vhdl/] [System68_tb.vhd] - Blame information for rev 8

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 6 dilbert57
--===========================================================================--
2
--
3
--  S Y N T H E Z I A B L E    System68   System On a Chip
4
--
5
--  This core adheres to the GNU public license  
6
--
7
-- File name      : system68_tb.vhd
8
--
9
-- Purpose        : Top level file for a 6800 compatible system on a chip
10
--                  Designed for the Burch ED B5-Spartan IIe board with
11
--                  X2S300e FPGA,
12
--                  128K x 16 Word SRAM module (Modified B3_SRAM)
13
--                  CPU I/O module
14
--                  B5 Compact Flash Module
15
--                  Using mimiUart from open cores modified to look like a 6850
16
--                  This version of System68 boots the monitor program
17
--                  from LBA sectors $F478 / $F479 from a 32 Mbyte Compact Flash
18
--                  On Reset the Boot ROM is mapped for read at $E000,
19
--                  and Writes to $E000-$FFFF write to RAM
20
--                  Writing 0 to location $8030 disables the boot ROM and
21
--                  maps RAM for Read only at $E000 and Writes go to the DAT.
22
--                  
23
-- Dependencies   : ieee.Std_Logic_1164
24
--                  ieee.std_logic_unsigned
25
--                  ieee.std_logic_arith
26
--                  ieee.numeric_std
27
--
28
-- Uses           : miniuart.vhd, rxunit.vhd, tx_unit.vhd, clkunit.vhd
29
--                  swtbug.vhd (6800 SWTBUG ROM)
30
--                  datram.vhd (Dynamic address translation registers)
31
--                  cpu68.vhd  (6800 compatible CPU core)
32
--                  timer.vhd  (timer module)
33
--
34
-- Author         : John E. Kent      
35
--
36
--===========================================================================----
37
--
38
-- Revision History:
39
--===========================================================================--
40
--
41
-- Date:                Revision   Author
42
-- 22 September 2002    0.1        John Kent
43
-- Initial design.
44
-- 31 March 2003        0.2        John Kent
45
-- Removed Parallel I/O port
46
-- Added Compact Flash Interface
47
-- Added IO register to commit unused inputs
48
-- Used 16 byte port mapping
49
-- 28th June 2003
50
-- updated CPU to include Halt and Hold signals
51
-------------------------------------------------------------------------------
52
--
53
-- Memory Map:
54
--
55
-- $0000 - $7FFF RAM
56
-- $8000 - $9FFF IO
57
--     $8000 - $800F MiniUart / Acia
58
--     $8010 - $801F Compact Flash
59
--     $8020 - $802F Timer
60
--     $8030 - $803F IO register / Map switch
61
-- $A000 - $DFFF RAM
62
-- $E000 - $FFFF ROM (read) & DAT (write)
63
--
64
library ieee;
65
   use ieee.std_logic_1164.all;
66
   use IEEE.STD_LOGIC_ARITH.ALL;
67
   use IEEE.STD_LOGIC_UNSIGNED.ALL;
68
   use ieee.numeric_std.all;
69
 
70
entity System68 is
71
  port(
72
    -- Memory Interface signals B3-SRAM
73
    ram_csn     : out Std_Logic;  -- RAM Chip select (active low)
74
    ram_wrln    : out Std_Logic;  -- lower byte write strobe (active low)
75
    ram_wrun    : out Std_Logic;  -- upper byte write strobe (active low)
76
    ram_addr    : out Std_Logic_Vector(16 downto 0);   -- RAM Address bus
77
    ram_data    : inout Std_Logic_Vector(15 downto 0); -- RAM Data bus
78
 
79
         -- Signals defined on B3-CPU-IO Module
80
    LED         : out std_logic;  -- Diagnostic LED Flasher
81
 
82
         -- Uart Interface
83
    rxbit       : in  Std_Logic; -- UART receive data
84
         txbit       : out Std_Logic; -- UART transmit data
85
    rts_n       : out Std_Logic; -- Request to send (active low)
86
    cts_n       : in  Std_Logic; -- Clear to send (active low)
87
 
88
         -- CRTC output signals
89
--         v_drive     : out Std_Logic;
90
--    h_drive     : out Std_Logic;
91
--    blue_lo     : out std_logic;
92
--    blue_hi     : out std_logic;
93
--    green_lo    : out std_logic;
94
--    green_hi    : out std_logic;
95
--    red_lo      : out std_logic;
96
--    red_hi      : out std_logic;
97
--         buzzer      : out std_logic;
98
 
99
    -- Compact Flash B5-CF Module
100
    cf_rst_n     : out std_logic;
101
         cf_cs0_n     : out std_logic;
102
         cf_cs1_n     : out std_logic;
103
    cf_rd_n      : out std_logic;
104
    cf_wr_n      : out std_logic;
105
         cf_cs16_n    : out std_logic;
106
    cf_a         : out std_logic_vector(2 downto 0);
107
    cf_d         : inout std_logic_vector(15 downto 0);
108
--    cf_intrq     : in std_logic;
109
--    cf_iordy     : in std_logic;
110
--      cf_dase      : in std_logic;
111
--         cf_pdiag     : in std_logic;
112
--         cf_present   : in std_logic;
113
 
114
-- Test Pins
115
         test_alu    : out std_logic_vector(15 downto 0); -- ALU output for timing constraints
116
         test_cc     : out std_logic_vector(7 downto 0)   -- Condition Code Outputs for timing constraints
117
         );
118
end;
119
 
120
-------------------------------------------------------------------------------
121
-- Architecture for memio Controller Unit
122
-------------------------------------------------------------------------------
123
architecture my_computer of System68 is
124
  -----------------------------------------------------------------------------
125
  -- Signals
126
  -----------------------------------------------------------------------------
127
  Signal SysClk    : std_logic;
128
  signal reset_n   : std_logic;
129
 
130
  -- Compact Flash BOOT ROM
131
--  signal boot_cs          : Std_Logic;
132
--  signal boot_data_out    : Std_Logic_Vector(7 downto 0);
133
 
134
  -- SWTBUG in Slices
135
  signal monitor_cs       : Std_Logic;
136
  signal monitor_data_out : Std_Logic_Vector(7 downto 0);
137
 
138
  -- SWTBUG in Block RAM
139
  signal swtbug_cs        : Std_Logic;
140
  signal swtbug_hold      : Std_Logic;
141
  signal swtbug_data_out  : Std_Logic_Vector(7 downto 0);
142
 
143
  -- UART Interface signals
144
  signal uart_cs       : Std_Logic;
145
  signal uart_data_out : Std_Logic_Vector(7 downto 0);
146
  signal uart_irq      : Std_Logic;
147
 
148
  -- timer
149
  signal timer_cs       : std_logic;
150
  signal timer_data_out : std_logic_vector(7 downto 0);
151
  signal timer_irq      : std_logic;
152
  signal timer_out      : std_logic;
153
 
154
  -- trap
155
--  signal trap_cs       : std_logic;
156
--  signal trap_data_out : std_logic_vector(7 downto 0);
157
--  signal trap_irq      : std_logic;
158
 
159
  -- compact flash port
160
  signal cf_cs       : std_logic;
161
  signal cf_rd       : std_logic;
162
  signal cf_wr       : std_logic;
163
  signal cf_data_out : std_logic_vector(7 downto 0);
164
 
165
  -- RAM
166
  signal ram_cs       : std_logic; -- memory chip select
167
  signal ram_wrl      : std_logic; -- memory write lower
168
  signal ram_wru      : std_logic; -- memory write upper
169
  signal ram_data_out : std_logic_vector(7 downto 0);
170
 
171
  -- CPU Interface signals
172
  signal cpu_reset    : Std_Logic;
173
  signal cpu_rw       : std_logic;
174
  signal cpu_vma      : std_logic;
175
  signal cpu_halt     : std_logic;
176
  signal cpu_hold     : std_logic;
177
  signal cpu_irq      : std_logic;
178
  signal cpu_nmi      : std_logic;
179
  signal cpu_addr     : Std_Logic_Vector(15 downto 0);
180
  signal cpu_data_in  : Std_Logic_Vector(7 downto 0);
181
  signal cpu_data_out : Std_Logic_Vector(7 downto 0);
182
 
183
  -- test signals
184
--  signal test_alu     : std_logic_vector(15 downto 0); -- ALU output for timing constraints
185
--  signal test_cc      : std_logic_vector(7 downto 0);   -- Condition Code Outputs for timing constraints
186
 
187
  -- Dynamic Address Translation RAM
188
  signal dat_cs       : std_logic;
189
  signal dat_addr     : std_logic_vector(7 downto 0);
190
 
191
  -- Boot ROM map Switch
192
--  signal map_cs       : std_logic;
193
--  signal map_sw       : std_logic; -- reset high for ROM. Write low for RAM
194
 
195
  -- Clock Generator
196
--  signal CpuClk       : std_logic;     -- unbuffered clock - SysClk / 4
197
--  signal cpu_clk      : std_logic;     -- buffered clock
198
--  signal clk_divider  : std_logic_vector(1 downto 0); -- divide by 4 counter
199
 
200
  -- Flashing Led test signals
201
  signal countL       : std_logic_vector(23 downto 0);
202
 
203
-----------------------------------------------------------------
204
--
205
-- CPU68 CPU core
206
--
207
-----------------------------------------------------------------
208
 
209
component cpu68
210
  port (
211
         clk:        in std_logic;
212
    rst:             in std_logic;
213
    rw:      out        std_logic;              -- Asynchronous memory interface
214
    vma:             out        std_logic;
215
    address:  out       std_logic_vector(15 downto 0);
216
    data_in:  in        std_logic_vector(7 downto 0);
217
         data_out: out std_logic_vector(7 downto 0);
218
         hold:     in  std_logic;
219
         halt:     in  std_logic;
220
         irq:      in  std_logic;
221
         nmi:      in  std_logic;
222
         test_alu: out std_logic_vector(15 downto 0);
223
         test_cc:  out std_logic_vector(7 downto 0)
224
  );
225
end component;
226
 
227
-----------------------------------------------------------------
228
--
229
-- Open Cores Mini UART
230
--
231
-----------------------------------------------------------------
232
 
233
component miniUART
234
  port (
235
     clk      : in  Std_Logic;  -- System Clock
236
     rst      : in  Std_Logic;  -- Reset input
237
     cs       : in  Std_Logic;
238
     rw       : in  Std_Logic;
239
     RxD      : in  Std_Logic;
240
     TxD      : out Std_Logic;
241
     CTS_n    : in  Std_Logic;
242
     RTS_n    : out Std_Logic;
243
     Irq      : out Std_logic;
244
     Addr     : in  Std_Logic;
245
     DataIn   : in  Std_Logic_Vector(7 downto 0); -- 
246
     DataOut  : out Std_Logic_Vector(7 downto 0)); -- 
247
end component;
248
 
249
 
250
----------------------------------------
251
--
252
-- Timer module
253
--
254
----------------------------------------
255
 
256
component timer
257
  port (
258
     clk       : in std_logic;
259
          rst       : in std_logic;
260
          cs        : in std_logic;
261
          rw        : in std_logic;
262
          addr      : in std_logic;
263
          data_in   : in std_logic_vector(7 downto 0);
264
          data_out  : out std_logic_vector(7 downto 0);
265
          irq       : out std_logic;
266
     timer_in  : in std_logic;
267
          timer_out : out std_logic
268
          );
269
end component;
270
 
271
--component trap
272
--      port (  
273
--       clk        : in  std_logic;
274
--    rst        : in  std_logic;
275
--    cs         : in  std_logic;
276
--    rw         : in  std_logic;
277
--    vma        : in  std_logic;
278
--    addr       : in  std_logic_vector(15 downto 0);
279
--    data_in    : in  std_logic_vector(7 downto 0);
280
--       data_out   : out std_logic_vector(7 downto 0);
281
--       irq        : out std_logic
282
--  );
283
--end component trap;
284
 
285
component dat_ram
286
  port (
287
    clk:      in  std_logic;
288
         rst:      in  std_logic;
289
         cs:       in  std_logic;
290
         rw:       in  std_logic;
291
         addr_lo:  in  std_logic_vector(3 downto 0);
292
         addr_hi:  in  std_logic_vector(3 downto 0);
293
    data_in:  in  std_logic_vector(7 downto 0);
294
         data_out: out std_logic_vector(7 downto 0)
295
         );
296
end component;
297
 
298
--component boot_rom
299
--  port (
300
--       cs    : in  std_logic;
301
--    addr  : in  Std_Logic_Vector(7 downto 0);  -- 256 byte cf boot rom
302
--       data  : out Std_Logic_Vector(7 downto 0)
303
--  );
304
--end component boot_rom;
305
 
306
--
307
-- SWTBug Monitor ROM at $E000
308
--
309
component monitor_rom
310
  port (
311
         cs    : in  std_logic;
312
    addr  : in  Std_Logic_Vector(9 downto 0);  -- 1K byte boot rom
313
         data  : out Std_Logic_Vector(7 downto 0)
314
  );
315
end component;
316
 
317
 
318
component BUFG
319
  port (
320
     i: in std_logic;
321
          o: out std_logic
322
  );
323
end component;
324
 
325
--
326
-- SWTBUG Monitor in Block RAM
327
--
328
component swtbug_rom
329
  port (
330
    clk    : in  std_logic;
331
         rst    : in  std_logic;
332
         cs     : in  std_logic;
333
         hold   : out std_logic;
334
         rw     : in  std_logic;
335
    addr   : in  std_logic_vector (9 downto 0);
336
    wdata  : in  std_logic_vector (7 downto 0);
337
    rdata  : out std_logic_vector (7 downto 0)
338
   );
339
end component;
340
 
341
begin
342
  -----------------------------------------------------------------------------
343
  -- Instantiation of internal components
344
  -----------------------------------------------------------------------------
345
 
346
my_cpu : cpu68  port map (
347
         clk         => SysClk,
348
--    clk       => cpu_clk,
349
    rst       => cpu_reset,
350
    rw       => cpu_rw,
351
    vma       => cpu_vma,
352
    address   => cpu_addr(15 downto 0),
353
    data_in   => cpu_data_in,
354
         data_out  => cpu_data_out,
355
         hold      => cpu_hold,
356
         halt      => cpu_halt,
357
         irq       => cpu_irq,
358
         nmi       => cpu_nmi,
359
         test_alu  => test_alu,
360
         test_cc   => test_cc
361
  );
362
 
363
my_uart  : miniUART port map (
364
         clk         => SysClk,
365
--    clk       => cpu_clk,
366
         rst       => cpu_reset,
367
    cs        => uart_cs,
368
         rw        => cpu_rw,
369
         RxD       => rxbit,
370
         TxD       => txbit,
371
         CTS_n     => cts_n,
372
         RTS_n     => rts_n,
373
    Irq       => uart_irq,
374
    Addr      => cpu_addr(0),
375
         Datain    => cpu_data_out,
376
         DataOut   => uart_data_out
377
         );
378
 
379
my_timer  : timer port map (
380
         clk         => SysClk,
381
--    clk       => cpu_clk,
382
         rst       => cpu_reset,
383
    cs        => timer_cs,
384
         rw        => cpu_rw,
385
    addr      => cpu_addr(0),
386
         data_in   => cpu_data_out,
387
         data_out  => timer_data_out,
388
    irq       => timer_irq,
389
         timer_in  => CountL(5),
390
         timer_out => timer_out
391
    );
392
 
393
--my_trap : trap port map (     
394
--       clk        => cpu_clk,
395
--    rst        => cpu_reset,
396
--    cs         => trap_cs,
397
--    rw         => cpu_rw,
398
--       vma        => cpu_vma,
399
--    addr       => cpu_addr,
400
--    data_in    => cpu_data_out,
401
--       data_out   => trap_data_out,
402
--       irq        => trap_irq
403
--  );
404
 
405
my_dat : dat_ram port map (
406
         clk         => SysClk,
407
--    clk       => cpu_clk,
408
         rst        => cpu_reset,
409
         cs         => dat_cs,
410
         rw         => cpu_rw,
411
         addr_hi    => cpu_addr(15 downto 12),
412
         addr_lo    => cpu_addr(3 downto 0),
413
    data_in    => cpu_data_out,
414
         data_out   => dat_addr(7 downto 0)
415
         );
416
 
417
--my_boot_rom : boot_rom port map (
418
--    cs         => boot_cs,
419
--       addr       => cpu_addr(7 downto 0),
420
--    data       => boot_data_out
421
--       );
422
 
423
--
424
-- SWTBUG Monitor
425
--
426
my_monitor_rom : monitor_rom port map (
427
    cs       => monitor_cs,
428
         addr     => cpu_addr(9 downto 0),
429
    data     => monitor_data_out
430
         );
431
 
432
--
433
-- SWTBUG Monitor using BLOCKRAM
434
--
435
my_swtbug_rom : swtbug_rom port map (
436
    clk      => SysClk,
437
         rst      => cpu_reset,
438
    cs       => swtbug_cs,
439
    hold     => swtbug_hold,
440
    rw       => cpu_rw,
441
    addr     => cpu_addr(9 downto 0),
442
    wdata    => cpu_data_out,
443
    rdata    => swtbug_data_out
444
    );
445
 
446
 
447
--clock_buffer : BUFG port map (
448
--     i       => CpuClk,
449
--        o       => cpu_clk
450
--  );
451
 
452
----------------------------------------------------------------------
453
--
454
--  Processes to decode the CPU address
455
--
456
----------------------------------------------------------------------
457
 
458
decode: process( cpu_addr, cpu_rw, cpu_vma, cpu_data_in,
459
--                 boot_cs, boot_data_out,
460
                                          monitor_cs, monitor_data_out,
461
                                     ram_cs, ram_data_out,
462
                                     swtbug_cs, swtbug_data_out,
463
                                     uart_cs, uart_data_out,
464
                                     cf_cs, cf_data_out,
465
                                     timer_cs, timer_data_out,
466
--                                   trap_cs, trap_data_out,
467
--                                        map_cs, map_sw,
468
                                     dat_cs )
469
begin
470
    --
471
         -- Memory Map
472
         --
473
      case cpu_addr(15 downto 13) is
474
                when "111" => -- $E000 - $FFFF
475
                   cpu_data_in <= monitor_data_out;            -- read ROM
476
                   monitor_cs <= cpu_vma;
477
                   swtbug_cs  <= '0';
478
--                      boot_cs    <= '0';
479
                        dat_cs     <= cpu_vma;                      -- write DAT
480
                        ram_cs     <= '0';
481
                        uart_cs    <= '0';
482
                        cf_cs      <= '0';
483
                        timer_cs   <= '0';
484
--                      trap_cs    <= '0';
485
--                      map_cs     <= '0';
486
--              when "1101" => -- $D000 - $DFFF
487
--                 monitor_cs <= '0';
488
--                 swtbug_cs  <= '0';
489
--                 if map_sw = '1' then
490
--                   cpu_data_in <= boot_data_out;             -- read ROM
491
--                        boot_cs     <= cpu_vma;                   -- boot rom read only
492
--                        dat_cs      <= '0';                       -- disable write to DAT
493
--                        ram_cs      <= cpu_vma;                   -- enable write to RAM
494
--                      else
495
--                        cpu_data_in <= ram_data_out;              -- read RAM
496
--                        boot_cs     <= '0';                       -- disable boot rom
497
--                        dat_cs      <= cpu_vma;                   -- enable write DAT
498
--                        ram_cs      <= cpu_vma and cpu_rw;        -- disable write to RAM
499
--                      end if;
500
--                      uart_cs    <= '0';
501
--                      cf_cs      <= '0';
502
--                      timer_cs   <= '0';
503
--                      trap_cs    <= '0';
504
--                      map_cs     <= '0';
505
                when "110" => -- $C000 - $DFFF
506
                   cpu_data_in <= swtbug_data_out;
507
                   monitor_cs <= '0';
508
                   swtbug_cs  <= cpu_vma;
509
--                      boot_cs    <= '0';
510
                        dat_cs     <= '0';
511
                        ram_cs     <= '0';
512
                        uart_cs    <= '0';
513
                        cf_cs      <= '0';
514
                        timer_cs   <= '0';
515
--                      trap_cs    <= '0';
516
--                      map_cs     <= '0';
517
                when "100" => -- $8000 - $9FFF
518
                   monitor_cs <= '0';
519
                   swtbug_cs  <= '0';
520
--                      boot_cs    <= '0';
521
                        dat_cs     <= '0';
522
                        ram_cs     <= '0';
523
                   case cpu_addr(6 downto 4) is
524
                        --
525
                        -- UART
526
                        --
527
                        when "000" => -- ($8000 - $800F)
528
                     cpu_data_in <= uart_data_out;
529
                          uart_cs     <= cpu_vma;
530
                          cf_cs       <= '0';
531
                          timer_cs    <= '0';
532
--                        trap_cs     <= '0';
533
--                        map_cs      <= '0';
534
                        --
535
                        -- Compact Flash
536
                        --
537
                        when "001" => -- ($8010 - $801F)
538
           cpu_data_in <= cf_data_out;
539
                          uart_cs     <= '0';
540
           cf_cs       <= cpu_vma;
541
                          timer_cs    <= '0';
542
--                        trap_cs     <= '0';
543
--                        map_cs      <= '0';
544
                        --
545
                        -- Timer
546
                        --
547
                        when "010" => -- ($8020 - $802F)
548
           cpu_data_in <= timer_data_out;
549
                          uart_cs     <= '0';
550
                          cf_cs       <= '0';
551
           timer_cs    <= cpu_vma;
552
--                        trap_cs     <= '0';
553
--                        map_cs      <= '0';
554
                        --
555
                        -- Memory Map switch
556
                        --
557
                        when "011" => -- ($8030 - $803F)
558
           cpu_data_in <= "00000000";
559
                          uart_cs     <= '0';
560
                          cf_cs       <= '0';
561
           timer_cs    <= '0';
562
--                        trap_cs     <= '0';
563
--                        map_cs      <= cpu_vma;
564
                        --
565
                        -- Trap hardware
566
                        --
567
--                      when "100" => -- ($8040 - $804F)
568
--           cpu_data_in <= trap_data_out;
569
--                        uart_cs     <= '0';
570
--                        cf_cs       <= '0';
571
--          timer_cs    <= '0';
572
--                        trap_cs     <= cpu_vma;
573
--                        map_cs      <= '0';
574
                        --
575
                        -- Null devices
576
                        --
577
                        when others => -- $8050 to $9FFF
578
           cpu_data_in <= "00000000";
579
                          uart_cs     <= '0';
580
                          cf_cs       <= '0';
581
                          timer_cs    <= '0';
582
--                        trap_cs     <= '0';
583
--                        map_cs      <= '0';
584
                   end case;
585
                 when "000" |  -- $0000 - $1FFF
586
                 "001" |  -- $2000 - $3FFF
587
                           "010" |  -- $4000 - $5FFF
588
                           "011" |  -- $6000 - $7FFF
589
                      "101" => -- $A000 - $BFFF
590
                   cpu_data_in <= ram_data_out;
591
                   monitor_cs <= '0';
592
                   swtbug_cs  <= '0';
593
--                      boot_cs    <= '0';
594
                   ram_cs     <= cpu_vma;
595
                   dat_cs     <= '0';
596
                   uart_cs    <= '0';
597
                   cf_cs      <= '0';
598
                   timer_cs   <= '0';
599
--                 trap_cs    <= '0';
600
--                 map_cs     <= '0';
601
                 when others =>
602
                   cpu_data_in <= "00000000";
603
                   monitor_cs <= '0';
604
                   swtbug_cs  <= '0';
605
--                      boot_cs    <= '0';
606
                   ram_cs     <= '0';
607
                   dat_cs     <= '0';
608
                   uart_cs    <= '0';
609
                   cf_cs      <= '0';
610
                   timer_cs   <= '0';
611
--                 trap_cs    <= '0';
612
--                 map_cs     <= '0';
613
            end case;
614
end process;
615
 
616
 
617
----------------------------------------------------------------------
618
--
619
--  Processes to read and write B3_SRAM
620
--
621
----------------------------------------------------------------------
622
b3_sram: process( SysClk,   Reset_n,
623
                  cpu_addr, cpu_rw,   cpu_data_out,
624
                  ram_cs,   ram_wrl,  ram_wru,
625
                                   dat_cs,   dat_addr, ram_data_out )
626
begin
627
    ram_csn <= not( ram_cs and Reset_n);
628
         ram_wrl  <= dat_addr(5) and (not cpu_rw) and SysClk;
629
         ram_wrln <= not ram_wrl;
630
    ram_wru  <= (not dat_addr(5)) and (not cpu_rw) and SysClk;
631
         ram_wrun <= not ram_wru;
632
         ram_addr(16 downto 12) <= dat_addr(4 downto 0);
633
         ram_addr(11 downto 0 ) <= cpu_addr(11 downto 0);
634
 
635
    if ram_wrl = '1' then
636
                ram_data(7 downto 0) <= cpu_data_out;
637
         else
638
      ram_data(7 downto 0)  <= "ZZZZZZZZ";
639
         end if;
640
 
641
         if ram_wru = '1' then
642
                ram_data(15 downto 8) <= cpu_data_out;
643
         else
644
      ram_data(15 downto 8)  <= "ZZZZZZZZ";
645
    end if;
646
 
647
         if dat_addr(5) = '0' then
648
      ram_data_out <= ram_data(15 downto 8);
649
         else
650
      ram_data_out <= ram_data(7 downto 0);
651
    end if;
652
 
653
end process;
654
 
655
--
656
-- B5-CF Compact Flash Control
657
--
658
b5_cf: process( Reset_n,
659
                cpu_addr, cpu_rw, cpu_data_out,
660
                                         cf_cs, cf_rd, cf_wr, cf_d )
661
begin
662
         cf_rst_n  <= Reset_n;
663
         cf_cs0_n  <= not( cf_cs ) or cpu_addr(3);
664
         cf_cs1_n  <= not( cf_cs and cpu_addr(3));
665
         cf_cs16_n <= '1';
666
         cf_wr     <= cf_cs and (not cpu_rw);
667
         cf_rd     <= cf_cs and cpu_rw;
668
         cf_wr_n   <= not cf_wr;
669
         cf_rd_n   <= not cf_rd;
670
         cf_a      <= cpu_addr(2 downto 0);
671
         if cf_wr = '1' then
672
           cf_d(7 downto 0) <= cpu_data_out;
673
         else
674
           cf_d(7 downto 0) <= "ZZZZZZZZ";
675
         end if;
676
         cf_data_out <= cf_d(7 downto 0);
677
         cf_d(15 downto 8) <= "ZZZZZZZZ";
678
end process;
679
 
680
--
681
-- ROM Map switch
682
-- The Map switch output is initially set
683
-- On a Write to the Map Switch port, clear the Map Switch
684
-- and map the RAM in place of the boot ROM.
685
--
686
--map_proc : process( SysClk, Reset_n, map_cs, cpu_rw )
687
--begin
688
--  if Sysclk'event and Sysclk = '1' then
689
--    if Reset_n = '0' then
690
--          map_sw <= '1';
691
--       else
692
--          if (map_cs = '1') and (cpu_rw = '0') then
693
--                 map_sw <= '0';
694
--               else
695
--                 map_sw <= map_sw;
696
--               end if;
697
--       end if;
698
--  end if;
699
--end process;
700
 
701
--
702
-- Interrupts and Reset.
703
--
704
interrupts : process( Reset_n, cpu_vma,
705
--                                                       trap_irq,
706
                                                         swtbug_hold,
707
                                                    timer_irq, uart_irq )
708
begin
709
    cpu_halt  <= '0';
710
         cpu_hold  <= swtbug_hold;
711
--       cpu_hold  <= '0';
712
    cpu_irq   <= uart_irq or timer_irq;
713
--       cpu_nmi   <= trap_irq;
714
         cpu_nmi   <= '0';
715
         cpu_reset <= not Reset_n; -- CPU reset is active high
716
end process;
717
 
718
--
719
-- Divide by 4 clock generator
720
--
721
--clock_gen: process (SysClk, clk_divider )
722
--begin
723
--    if(SysClk'event and SysClk = '0') then
724
--      clk_divider <= clk_divider + "01";                       
725
--    end if;
726
--       CpuClk <= clk_divider(1);
727
--end process;
728
 
729
--
730
-- flash led to indicate code is working
731
--
732
flash: process (SysClk, CountL )
733
begin
734
    if(SysClk'event and SysClk = '0') then
735
      countL <= countL + 1;
736
    end if;
737
         LED <= countL(21);
738
end process;
739
 
740
-- *** Test Bench - User Defined Section ***
741
tb : PROCESS
742
        variable count : integer;
743
   BEGIN
744
 
745
        SysClk <= '0';
746
        Reset_n <= '0';
747
 
748
                for count in 0 to 512 loop
749
                        SysClk <= '0';
750
                        if count = 0 then
751
                                Reset_n <= '0';
752
                        elsif count = 1 then
753
                                Reset_n <= '1';
754
                        end if;
755
                        wait for 100 ns;
756
                        SysClk <= '1';
757
                        wait for 100 ns;
758
                end loop;
759
 
760
      wait; -- will wait forever
761
   END PROCESS;
762
 
763
end my_computer; --===================== End of architecture =======================--
764
 

powered by: WebSVN 2.1.0

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