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

Subversion Repositories System68

[/] [System68/] [tags/] [arelease/] [vhdl/] [System68.vhd] - Blame information for rev 4

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

Line No. Rev Author Line
1 4 dilbert57
--===========================================================================--
2
--
3
--  S Y N T H E Z I A B L E    System68   System On a Chip
4
--
5
--  www.OpenCores.Org - December 2002
6
--  This core adheres to the GNU public license  
7
--
8
-- File name      : system68.vhd
9
--
10
-- Purpose        : Top level file for a 6800 compatible system on a chip
11
--                  Designed for the Burch ED B3-Spartan II board with
12
--                  X2S200 FPGA, 128 x 16 Word SRAM module and CPU I/O module
13
--                  Using mimiUart from open cores modified to look like a 6850
14
--                  
15
-- Dependencies   : ieee.Std_Logic_1164
16
--                  ieee.std_logic_unsigned
17
--                  ieee.std_logic_arith
18
--                  ieee.numeric_std
19
--
20
-- Uses           : miniuart.vhd, rxunit.vhd, tx_unit.vhd, clkunit.vhd
21
--                  swtbug.vhd (6800 SWTBUG ROM)
22
--                  datram.vhd (Dynamic address translation registers)
23
--                  ioport.vhd (4 x 8 port parallel I/O )
24
--                  cpu68.vhd  (6800 compatible CPU core)
25
--                  timer.vhd  (timer module)
26
--
27
-- Author         : John E. Kent      
28
--
29
--===========================================================================----
30
--
31
-- Revision History:
32
--===========================================================================--
33
--
34
-- Date:                Revision   Author
35
-- 22 September 2002    0.1        John Kent
36
-- Initial design.
37
--
38
-------------------------------------------------------------------------------
39
--
40
-- Memory Map:
41
--
42
-- $0000 - $7FFF RAM
43
-- $8000 - $9FFF IO
44
--     $8000 - $8003 Timer
45
--     $8004 - $8007 MiniUart / Acia
46
--     $8008 - $800F IO Port
47
-- $A000 - $DFFF RAM
48
-- $E000 - $FFFF ROM (read) & DAT (write)
49
--
50
library ieee;
51
   use ieee.std_logic_1164.all;
52
   use IEEE.STD_LOGIC_ARITH.ALL;
53
   use IEEE.STD_LOGIC_UNSIGNED.ALL;
54
   use ieee.numeric_std.all;
55
 
56
entity System68 is
57
  port(
58
    SysClk      : in  Std_Logic;  -- System Clock input
59
         Reset_n     : in  Std_logic;  -- Master Reset input (active low)
60
    LED         : out std_logic;  -- Diagnostic LED Flasher
61
 
62
    -- Memory Interface signals
63
    ram_csn     : out Std_Logic;  -- RAM Chip select (active low)
64
    ram_wrln    : out Std_Logic;  -- lower byte write strobe (active low)
65
    ram_wrun    : out Std_Logic;  -- upper byte write strobe (active low)
66
    ram_addr    : out Std_Logic_Vector(16 downto 0);   -- RAM Address bus
67
    ram_data    : inout Std_Logic_Vector(15 downto 0); -- RAM Data bus
68
 
69
         -- Stuff on the peripheral board
70
--  aux_clock   : in  Std_Logic;  -- FPGA-CPU-IO clock
71
 
72
         -- PS/2 Mouse interface
73
--       mouse_clock : in  Std_Logic;
74
--       mouse_data  : in  Std_Logic;
75
 
76
         -- Uart Interface
77
    rxbit       : in  Std_Logic; -- UART receive data
78
         txbit       : out Std_Logic; -- UART transmit data
79
    rts_n       : out Std_Logic; -- Request to send (active low)
80
    cts_n       : in  Std_Logic; -- Clear to send (active low)
81
 
82
         -- CRTC output signals
83
         -- Signal defined on B3-CPU-IO Module
84
         -- Not currently used.
85
         v_drive     : out Std_Logic;
86
    h_drive     : out Std_Logic;
87
    blue_lo     : out std_logic;
88
    blue_hi     : out std_logic;
89
    green_lo    : out std_logic;
90
    green_hi    : out std_logic;
91
    red_lo      : out std_logic;
92
    red_hi      : out std_logic;
93
         buzzer      : out std_logic;
94
 
95
-- I/O Ports
96
    PortA        : inout std_logic_vector(7 downto 0);
97
    PortB        : inout std_logic_vector(7 downto 0);
98
    PortC        : inout std_logic_vector(7 downto 0);
99
    PortD        : inout std_logic_vector(7 downto 0);
100
 
101
-- Timer I/O
102
         timer_out    : out std_logic;
103
 
104
-- Test Pins
105
    uart_csn    : out std_logic;  -- Uart chip select out (active low)
106
    test_rw     : out std_logic;  -- Read / Write signal
107
         test_d0     : out std_logic;  -- Uart Chip select ANDed with Receive Data Ready bit
108
         test_d1     : out std_logic;  -- Uart Chip select ANDed with Transmit Data Ready bit
109
 
110
         test_alu    : out std_logic_vector(15 downto 0); -- ALU output for timing constraints
111
         test_cc     : out std_logic_vector(7 downto 0)   -- Condition Code Outputs for timing constraints
112
         );
113
end System68;
114
 
115
-------------------------------------------------------------------------------
116
-- Architecture for memio Controller Unit
117
-------------------------------------------------------------------------------
118
architecture my_computer of System68 is
119
  -----------------------------------------------------------------------------
120
  -- Signals
121
  -----------------------------------------------------------------------------
122
  -- BOOT ROM
123
  signal rom_data_out  : Std_Logic_Vector(7 downto 0);
124
 
125
  -- UART Interface signals
126
  signal uart_data_out : Std_Logic_Vector(7 downto 0);
127
  signal uart_cs       : Std_Logic;
128
  signal uart_irq      : Std_Logic;
129
 
130
  -- timer
131
  signal timer_data_out : std_logic_vector(7 downto 0);
132
  signal timer_cs    : std_logic;
133
  signal timer_irq   : std_logic;
134
 
135
  -- i/o port
136
  signal ioport_data_out : std_logic_vector(7 downto 0);
137
  signal ioport_cs   : std_logic;
138
 
139
  -- RAM
140
  signal ram_cs      : std_logic; -- memory chip select
141
  signal ram_wrl     : std_logic; -- memory write lower
142
  signal ram_wru     : std_logic; -- memory write upper
143
  signal ram_data_out    : std_logic_vector(7 downto 0);
144
 
145
  -- CPU Interface signals
146
  signal cpu_reset   : Std_Logic;
147
  signal cpu_clk     : Std_Logic;
148
  signal cpu_rw      : std_logic;
149
  signal cpu_vma     : std_logic;
150
  signal cpu_irq     : std_logic;
151
  signal cpu_nmi     : std_logic;
152
  signal cpu_addr    : Std_Logic_Vector(15 downto 0);
153
  signal cpu_data_in : Std_Logic_Vector(7 downto 0);
154
  signal cpu_data_out: Std_Logic_Vector(7 downto 0);
155
 
156
  -- Dynamic Address Translation RAM
157
  signal dat_cs      : std_logic;
158
  signal dat_addr    : std_logic_vector(7 downto 0);
159
 
160
  -- Flashing Led test signals
161
  signal countL      : std_logic_vector(23 downto 0);
162
 
163
 
164
-----------------------------------------------------------------
165
--
166
-- Open Cores Mini UART
167
--
168
-----------------------------------------------------------------
169
 
170
component miniUART is
171
  port (
172
     SysClk   : in  Std_Logic;  -- System Clock
173
     rst      : in  Std_Logic;  -- Reset input
174
     cs       : in  Std_Logic;
175
     rw       : in  Std_Logic;
176
     RxD      : in  Std_Logic;
177
     TxD      : out Std_Logic;
178
     CTS_n    : in  Std_Logic;
179
     RTS_n    : out Std_Logic;
180
     Irq      : out Std_logic;
181
     Addr     : in  Std_Logic;
182
     DataIn   : in  Std_Logic_Vector(7 downto 0); -- 
183
     DataOut  : out Std_Logic_Vector(7 downto 0)); -- 
184
end component;
185
 
186
--------------------------------------
187
--
188
-- Three port parallel I/O
189
--
190
---------------------------------------
191
 
192
component ioport is
193
  port (
194
     clk      : in std_logic;
195
          rst      : in std_logic;
196
          cs       : in std_logic;
197
          rw       : in std_logic;
198
          addr     : in std_logic_vector(2 downto 0);
199
          data_in  : in std_logic_vector(7 downto 0);
200
          data_out : out std_logic_vector(7 downto 0);
201
          porta_io : inout std_logic_vector(7 downto 0);
202
          portb_io : inout std_logic_vector(7 downto 0);
203
          portc_io : inout std_logic_vector(7 downto 0);
204
          portd_io : inout std_logic_vector(7 downto 0)
205
          );
206
end component;
207
 
208
----------------------------------------
209
--
210
-- Timer module
211
--
212
----------------------------------------
213
 
214
component timer is
215
  port (
216
     clk       : in std_logic;
217
          rst       : in std_logic;
218
          cs        : in std_logic;
219
          rw        : in std_logic;
220
          addr      : in std_logic;
221
          data_in   : in std_logic_vector(7 downto 0);
222
          data_out  : out std_logic_vector(7 downto 0);
223
          irq       : out std_logic;
224
     timer_in  : in std_logic;
225
          timer_out : out std_logic
226
          );
227
end component timer;
228
 
229
component cpu68 is
230
  port (
231
         clk:        in std_logic;
232
    rst:      in        std_logic;
233
    rw:      out        std_logic;              -- Asynchronous memory interface
234
    vma:             out        std_logic;
235
    address:  out       std_logic_vector(15 downto 0);
236
    data_in:  in        std_logic_vector(7 downto 0);
237
         data_out: out std_logic_vector(7 downto 0);
238
         irq:      in  std_logic;
239
         nmi:      in  std_logic;
240
         test_alu: out std_logic_vector(15 downto 0);
241
         test_cc:  out std_logic_vector(7 downto 0)
242
  );
243
end component cpu68;
244
 
245
component dat_ram is
246
  port (
247
    clk:      in  std_logic;
248
         rst:      in  std_logic;
249
         cs:       in  std_logic;
250
         rw:       in  std_logic;
251
         addr_lo:  in  std_logic_vector(3 downto 0);
252
         addr_hi:  in  std_logic_vector(3 downto 0);
253
    data_in:  in  std_logic_vector(7 downto 0);
254
         data_out: out std_logic_vector(7 downto 0)
255
         );
256
end component dat_ram;
257
 
258
component boot_rom is
259
  port (
260
    addr  : in  Std_Logic_Vector(9 downto 0);  -- 1K byte boot rom
261
         data  : out Std_Logic_Vector(7 downto 0)
262
  );
263
end component boot_rom;
264
 
265
begin
266
  -----------------------------------------------------------------------------
267
  -- Instantiation of internal components
268
  -----------------------------------------------------------------------------
269
 
270
my_uart  : miniUART port map (
271
    SysClk    => SysClk,
272
         rst       => cpu_reset,
273
    cs        => uart_cs,
274
         rw        => cpu_rw,
275
         RxD       => rxbit,
276
         TxD       => txbit,
277
         CTS_n     => cts_n,
278
         RTS_n     => rts_n,
279
    Irq       => uart_irq,
280
    Addr      => cpu_addr(0),
281
         Datain    => cpu_data_out,
282
         DataOut   => uart_data_out
283
         );
284
 
285
my_ioport  : ioport port map (
286
    clk       => SysClk,
287
         rst       => cpu_reset,
288
    cs        => ioport_cs,
289
         rw        => cpu_rw,
290
    addr      => cpu_addr(2 downto 0),
291
         data_in   => cpu_data_out,
292
         data_out  => ioport_data_out,
293
         porta_io  => porta,
294
         portb_io  => portb,
295
         portc_io  => portc,
296
         portd_io  => portd
297
    );
298
 
299
my_timer  : timer port map (
300
    clk       => SysClk,
301
         rst       => cpu_reset,
302
    cs        => timer_cs,
303
         rw        => cpu_rw,
304
    addr      => cpu_addr(0),
305
         data_in   => cpu_data_out,
306
         data_out  => timer_data_out,
307
    irq       => timer_irq,
308
         timer_in  => CountL(5),
309
         timer_out => timer_out
310
    );
311
 
312
my_cpu : cpu68  port map (
313
         clk         => SysClk,
314
    rst       => cpu_reset,
315
    rw       => cpu_rw,
316
    vma       => cpu_vma,
317
    address   => cpu_addr(15 downto 0),
318
    data_in   => cpu_data_in,
319
         data_out  => cpu_data_out,
320
         irq       => cpu_irq,
321
         nmi       => cpu_nmi,
322
         test_alu  => test_alu,
323
         test_cc   => test_cc
324
  );
325
 
326
 
327
my_dat : dat_ram port map (
328
    clk        => SysClk,
329
         rst        => cpu_reset,
330
         cs         => dat_cs,
331
         rw         => cpu_rw,
332
         addr_hi    => cpu_addr(15 downto 12),
333
         addr_lo    => cpu_addr(3 downto 0),
334
    data_in    => cpu_data_out,
335
         data_out   => dat_addr(7 downto 0)
336
         );
337
 
338
my_rom : boot_rom port map (
339
         addr       => cpu_addr(9 downto 0),
340
    data       => rom_data_out
341
         );
342
 
343
----------------------------------------------------------------------
344
--
345
--  Processes to read and write memory based on bus signals
346
--
347
----------------------------------------------------------------------
348
 
349
memory: process( SysClk, Reset_n,
350
                 cpu_addr, cpu_rw, cpu_vma, cpu_data_out,
351
                 ram_cs, ram_wrl, ram_wru, dat_addr,
352
                                          rom_data_out, ram_data_out,
353
                                          ioport_data_out, timer_data_out, uart_data_out )
354
begin
355
    case cpu_addr(15 downto 13) is
356
                when "111" => -- $E000 - $FFFF
357
                   cpu_data_in <= rom_data_out;
358
                        dat_cs    <= cpu_vma;
359
                        ram_cs    <= '0';
360
                        uart_cs   <= '0';
361
                        ioport_cs <= '0';
362
                        timer_cs  <= '0';
363
                when "100" => -- $8000 - $9FFF
364
                        dat_cs    <= '0';
365
                        ram_cs    <= '0';
366
                   case cpu_addr(5 downto 2) is
367
                        when "0000" => -- $8000
368
           cpu_data_in <= timer_data_out;
369
                          uart_cs   <= '0';
370
                          ioport_cs <= '0';
371
           timer_cs  <= cpu_vma;
372
                        when "0001" => -- $8004
373
                     cpu_data_in <= uart_data_out;
374
                          uart_cs     <= cpu_vma;
375
                          ioport_cs   <= '0';
376
                          timer_cs    <= '0';
377
                        when "0010" | "0011" => -- $8008/$800C
378
           cpu_data_in <= ioport_data_out;
379
                          uart_cs     <= '0';
380
           ioport_cs   <= cpu_vma;
381
                          timer_cs    <= '0';
382
                        when others => -- $8010 to $9FFF
383
           cpu_data_in <= "00000000";
384
                          uart_cs     <= '0';
385
                          ioport_cs   <= '0';
386
                          timer_cs    <= '0';
387
                   end case;
388
                when others =>
389
                  cpu_data_in <= ram_data_out;
390
                  ram_cs     <= cpu_vma;
391
                  dat_cs     <= '0';
392
                  uart_cs    <= '0';
393
                  ioport_cs  <= '0';
394
                  timer_cs   <= '0';
395
         end case;
396
         cpu_reset <= not Reset_n; -- CPU reset is active high
397
    ram_csn <= not( ram_cs and Reset_n );
398
         ram_wrl  <= (not dat_addr(5)) and (not cpu_rw) and SysClk;
399
         ram_wrln <= not ram_wrl;
400
    ram_wru  <= dat_addr(5) and (not cpu_rw) and SysClk;
401
         ram_wrun <= not ram_wru;
402
         ram_addr(16 downto 12) <= dat_addr(4 downto 0);
403
         ram_addr(11 downto 0) <= cpu_addr(11 downto 0);
404
 
405
    if ram_wrl = '1' then
406
                ram_data(7 downto 0) <= cpu_data_out;
407
         else
408
      ram_data(7 downto 0)  <= "ZZZZZZZZ";
409
         end if;
410
 
411
         if ram_wru = '1' then
412
                ram_data(15 downto 8) <= cpu_data_out;
413
         else
414
      ram_data(15 downto 8)  <= "ZZZZZZZZ";
415
    end if;
416
 
417
         if dat_addr(5) = '1' then
418
      ram_data_out <= ram_data(15 downto 8);
419
         else
420
      ram_data_out <= ram_data(7 downto 0);
421
    end if;
422
         -- test pins
423
         uart_csn <= not uart_cs;
424
         test_rw <= cpu_rw;
425
         test_d0 <= uart_data_out(0) and uart_cs;
426
         test_d1 <= uart_data_out(1) and uart_cs;
427
end process;
428
 
429
--
430
-- tie together interrupts
431
--
432
interrupts : process( timer_irq, uart_irq )
433
begin
434
    cpu_irq <= uart_irq;
435
         cpu_nmi <= timer_irq;
436
end process;
437
 
438
--
439
--
440
--clock_gen : process( SysClk, e_clk )
441
--begin
442
--  if SysClk'event and SysClk='1' then
443
--    e_clk <= not e_clk;
444
--  end if;
445
--end process;
446
 
447
  --
448
  -- flash led to indicate code is working
449
  --
450
  increment: process (SysClk, CountL )
451
  begin
452
    if(SysClk'event and SysClk = '1') then
453
      countL <= countL + 1;
454
    end if;
455
         LED <= countL(21);
456
  end process;
457
 
458
  uncommitted: process( SysClk )
459
  begin
460
  --
461
  -- CRTC output signals
462
  --
463
         v_drive     <= '0';
464
    h_drive     <= '0';
465
    blue_lo     <= '0';
466
    blue_hi     <= '0';
467
    green_lo    <= '0';
468
    green_hi    <= '0';
469
    red_lo      <= '0';
470
    red_hi      <= '0';
471
         buzzer      <= '0';
472
 end process;
473
 
474
 
475
end my_computer; --===================== End of architecture =======================--
476
 

powered by: WebSVN 2.1.0

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