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

Subversion Repositories System09

[/] [System09/] [trunk/] [rtl/] [System09_Digilent_3S500E/] [System09_Digilent_3S500E.vhd] - Blame information for rev 19

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

Line No. Rev Author Line
1 19 dilbert57
-- $Id: System09_Digilent_3S500E.vhd,v 1.1 2007-12-09 16:06:02 dilbert57 Exp $
2
--===========================================================================----
3
--
4
--  S Y N T H E Z I A B L E    System09 - SOC.
5
--
6
--  This core adheres to the GNU public license  
7
--
8
-- File name      : System09.vhd
9
--
10
-- Purpose        : Top level file for 6809 compatible system on a chip
11
--                  Designed with Xilinx XC3S500E Spartan 3E FPGA.
12
--                  Implemented With Digilent Xilinx Starter FPGA board,
13
--
14
-- Dependencies   : ieee.Std_Logic_1164
15
--                  ieee.std_logic_unsigned
16
--                  ieee.std_logic_arith
17
--                  ieee.numeric_std
18
--
19
-- Uses           : mon_rom  (kbug_rom2k.vhd)       Monitor ROM
20
--                  cpu09    (cpu09.vhd)      CPU core
21
--                  miniuart (minitUART3.vhd) ACIA / MiniUART
22
--                           (rxunit3.vhd)
23
--                           (tx_unit3.vhd)
24
-- 
25
-- Author         : John E. Kent      
26
--                  dilbert57@opencores.org      
27
--
28
--===========================================================================----
29
--
30
-- Revision History:
31
--===========================================================================--
32
-- Version 0.1 - 20 March 2003
33
-- Version 0.2 - 30 March 2003
34
-- Version 0.3 - 29 April 2003
35
-- Version 0.4 - 29 June 2003
36
--
37
-- Version 0.5 - 19 July 2003
38
-- prints out "Hello World"
39
--
40
-- Version 0.6 - 5 September 2003
41
-- Runs SBUG
42
--
43
-- Version 1.0- 6 Sep 2003 - John Kent
44
-- Inverted CLK_50MHZ
45
-- Initial release to Open Cores
46
--
47
-- Version 1.1 - 17 Jan 2004 - John Kent
48
-- Updated miniUart.
49
--
50
-- Version 1.2 - 25 Jan 2004 - John Kent
51
-- removed signals "test_alu" and "test_cc" 
52
-- Trap hardware re-instated.
53
--
54
-- Version 1.3 - 11 Feb 2004 - John Kent
55
-- Designed forked off to produce System09_VDU
56
-- Added VDU component
57
--      VDU runs at 25MHz and divides the clock by 2 for the CPU
58
-- UART Runs at 57.6 Kbps
59
--
60
-- Version 2.0 - 2 September 2004 - John Kent
61
-- ported to Digilent Xilinx Spartan3 starter board
62
--      removed Compaact Flash and Trap Logic.
63
-- Replaced SBUG with KBug9s
64
--
65
-- Version 3.0 - 22 April 2006 - John Kent
66
-- Port to Digilent Spartan 3E Starter board
67
-- Removed keyboard, vdu, timer, and trap logic
68
-- added PIA with counters attached.
69
-- Uses 32Kbytes of internal Block RAM
70
--===========================================================================--
71
library ieee;
72
   use ieee.std_logic_1164.all;
73
   use IEEE.STD_LOGIC_ARITH.ALL;
74
   use IEEE.STD_LOGIC_UNSIGNED.ALL;
75
   use ieee.numeric_std.all;
76
 
77
entity My_System09 is
78
  port(
79
    CLK_50MHZ     : in  Std_Logic;  -- System Clock input
80
    BTN_SOUTH     : in  Std_Logic;
81
 
82
         -- Uart Interface
83
         RS232_DCE_RXD : in  std_logic;
84
    RS232_DCE_TXD : out std_logic;
85
 
86
         -- LEDS & Switches
87
         LED           : out std_logic_vector(7 downto 0)
88
         );
89
end My_System09;
90
 
91
-------------------------------------------------------------------------------
92
-- Architecture for System09
93
-------------------------------------------------------------------------------
94
architecture my_computer of My_System09 is
95
  -----------------------------------------------------------------------------
96
  -- Signals
97
  -----------------------------------------------------------------------------
98
  -- BOOT ROM
99
  signal rom_cs        : Std_logic;
100
  signal rom_data_out  : Std_Logic_Vector(7 downto 0);
101
 
102
  -- UART Interface signals
103
  signal uart_data_out : Std_Logic_Vector(7 downto 0);
104
  signal uart_cs       : Std_Logic;
105
  signal uart_irq      : Std_Logic;
106
  signal baudclk       : Std_Logic;
107
  signal DCD_n         : Std_Logic;
108
  signal RTS_n         : Std_Logic;
109
  signal CTS_n         : Std_Logic;
110
 
111
  -- PIA Interface signals
112
  signal pia_data_out  : Std_Logic_Vector(7 downto 0);
113
  signal pia_cs        : Std_Logic;
114
  signal pia_irq_a     : Std_Logic;
115
  signal pia_irq_b     : Std_Logic;
116
 
117
  -- RAM
118
  signal ram_cs       : std_logic; -- memory chip select
119
  signal ram_data_out : std_logic_vector(7 downto 0);
120
 
121
  -- CPU Interface signals
122
  signal cpu_reset    : Std_Logic;
123
  signal cpu_clk      : Std_Logic;
124
  signal cpu_rw       : std_logic;
125
  signal cpu_vma      : std_logic;
126
  signal cpu_halt     : std_logic;
127
  signal cpu_hold     : std_logic;
128
  signal cpu_firq     : std_logic;
129
  signal cpu_irq      : std_logic;
130
  signal cpu_nmi      : std_logic;
131
  signal cpu_addr     : std_logic_vector(15 downto 0);
132
  signal cpu_data_in  : std_logic_vector(7 downto 0);
133
  signal cpu_data_out : std_logic_vector(7 downto 0);
134
 
135
  signal BaudCount    : std_logic_vector(6 downto 0);
136
  signal CountL       : std_logic_vector(23 downto 0);
137
  -- CLK_50MHZ clock divide by 4
138
  signal prescale     : std_logic_vector(1 downto 0);
139
 
140
-----------------------------------------------------------------
141
--
142
-- CPU09 CPU core
143
--
144
-----------------------------------------------------------------
145
 
146
component cpu09
147
  port (
148
         clk:        in std_logic;
149
    rst:      in        std_logic;
150
    rw:      out        std_logic;              -- Asynchronous memory interface
151
    vma:             out        std_logic;
152
    address:  out       std_logic_vector(15 downto 0);
153
    data_in:  in        std_logic_vector(7 downto 0);
154
         data_out: out std_logic_vector(7 downto 0);
155
         halt:     in  std_logic;
156
         hold:     in  std_logic;
157
         irq:      in  std_logic;
158
         nmi:      in  std_logic;
159
         firq:     in  std_logic
160
  );
161
end component;
162
 
163
 
164
----------------------------------------
165
--
166
-- Block RAM Monitor ROM
167
--
168
----------------------------------------
169
component rom_8k
170
    Port (
171
       clk   : in  std_logic;
172
                 rst   : in  std_logic;
173
                 cs    : in  std_logic;
174
                 rw    : in  std_logic;
175
       addr  : in  std_logic_vector (12 downto 0);
176
       rdata : out std_logic_vector (7 downto 0);
177
       wdata : in  std_logic_vector (7 downto 0)
178
    );
179
end component;
180
 
181
----------------------------------------
182
--
183
-- Block RAM Monitor
184
--
185
----------------------------------------
186
component ram_32k
187
    Port (
188
       clk   : in  std_logic;
189
                 rst   : in  std_logic;
190
                 cs    : in  std_logic;
191
                 rw    : in  std_logic;
192
       addr  : in  std_logic_vector (14 downto 0);
193
       rdata : out std_logic_vector (7 downto 0);
194
       wdata : in  std_logic_vector (7 downto 0)
195
    );
196
end component;
197
 
198
-----------------------------------------------------------------
199
--
200
-- 6822 compatible PIA with counters
201
--
202
-----------------------------------------------------------------
203
 
204
component pia_timer
205
        port (
206
         clk       : in    std_logic;
207
    rst       : in    std_logic;
208
    cs        : in    std_logic;
209
    rw        : in    std_logic;
210
    addr      : in    std_logic_vector(1 downto 0);
211
    data_in   : in    std_logic_vector(7 downto 0);
212
         data_out  : out   std_logic_vector(7 downto 0);
213
         irqa      : out   std_logic;
214
         irqb      : out   std_logic
215
         );
216
end component;
217
 
218
-----------------------------------------------------------------
219
--
220
-- 6850 compatible UART (ACIA)
221
--
222
-----------------------------------------------------------------
223
 
224
component miniUART
225
  port (
226
     clk      : in  Std_Logic;  -- System Clock
227
     rst      : in  Std_Logic;  -- Reset input (active high)
228
     cs       : in  Std_Logic;  -- miniUART Chip Select
229
     rw       : in  Std_Logic;  -- Read / Not Write
230
     irq      : out Std_Logic;  -- Interrupt
231
     Addr     : in  Std_Logic;  -- Register Select
232
     DataIn   : in  Std_Logic_Vector(7 downto 0); -- Data Bus In 
233
     DataOut  : out Std_Logic_Vector(7 downto 0); -- Data Bus Out
234
     RxC      : in  Std_Logic;  -- Receive Baud Clock
235
     TxC      : in  Std_Logic;  -- Transmit Baud Clock
236
     RxD      : in  Std_Logic;  -- Receive Data
237
     TxD      : out Std_Logic;  -- Transmit Data
238
          DCD_n    : in  Std_Logic;  -- Data Carrier Detect
239
     CTS_n    : in  Std_Logic;  -- Clear To Send
240
     RTS_n    : out Std_Logic );  -- Request To send
241
end component;
242
 
243
 
244
component BUFG
245
port (
246
     i: in std_logic;
247
          o: out std_logic
248
  );
249
end component;
250
 
251
begin
252
  -----------------------------------------------------------------------------
253
  -- Instantiation of internal components
254
  -----------------------------------------------------------------------------
255
 
256
my_cpu : cpu09  port map (
257
         clk         => cpu_clk,
258
    rst       => cpu_reset,
259
    rw       => cpu_rw,
260
    vma       => cpu_vma,
261
    address   => cpu_addr(15 downto 0),
262
    data_in   => cpu_data_in,
263
         data_out  => cpu_data_out,
264
         halt      => cpu_halt,
265
         hold      => cpu_hold,
266
         irq       => cpu_irq,
267
         nmi       => cpu_nmi,
268
         firq      => cpu_firq
269
  );
270
 
271
my_rom : rom_8k port map (
272
       clk   => cpu_clk,
273
                 rst   => cpu_reset,
274
                 cs    => rom_cs,
275
                 rw    => '1',
276
       addr  => cpu_addr(12 downto 0),
277
       rdata => rom_data_out,
278
       wdata => cpu_data_out
279
    );
280
 
281
my_ram : ram_32k port map (
282
       clk   => cpu_clk,
283
                 rst   => cpu_reset,
284
                 cs    => ram_cs,
285
                 rw    => cpu_rw,
286
       addr  => cpu_addr(14 downto 0),
287
       rdata => ram_data_out,
288
       wdata => cpu_data_out
289
    );
290
 
291
my_pia  : pia_timer port map (
292
         clk         => cpu_clk,
293
         rst       => cpu_reset,
294
    cs        => pia_cs,
295
         rw        => cpu_rw,
296
    addr      => cpu_addr(1 downto 0),
297
         data_in   => cpu_data_out,
298
         data_out  => pia_data_out,
299
    irqa      => pia_irq_a,
300
    irqb      => pia_irq_b
301
         );
302
 
303
my_uart  : miniUART port map (
304
         clk         => cpu_clk,
305
         rst       => cpu_reset,
306
    cs        => uart_cs,
307
         rw        => cpu_rw,
308
    irq       => uart_irq,
309
    Addr      => cpu_addr(0),
310
         Datain    => cpu_data_out,
311
         DataOut   => uart_data_out,
312
         RxC       => baudclk,
313
         TxC       => baudclk,
314
         RxD       => RS232_DCE_RXD,
315
         TxD       => RS232_DCE_TXD,
316
         DCD_n     => dcd_n,
317
         CTS_n     => cts_n,
318
         RTS_n     => rts_n
319
         );
320
 
321
 
322
clk_buffer : BUFG port map(
323
    i => prescale(1),
324
         o => cpu_clk
325
    );
326
 
327
----------------------------------------------------------------------
328
--
329
-- Process to decode memory map
330
--
331
----------------------------------------------------------------------
332
 
333
mem_decode: process( cpu_clk, BTN_SOUTH,
334
                     cpu_addr, cpu_rw, cpu_vma,
335
                                              rom_data_out,
336
                                                        ram_data_out,
337
                                                   uart_data_out,
338
                     pia_data_out )
339
begin
340
    case cpu_addr(15 downto 14) is
341
           --
342
                -- Monitor ROM $C000 - $FFFF
343
                --
344
                when "11" => -- $C000 - $FFFF
345
                   cpu_data_in <= rom_data_out;
346
                        rom_cs      <= cpu_vma;
347
                        ram_cs      <= '0';
348
                        uart_cs     <= '0';
349
                        pia_cs      <= '0';
350
      --
351
                -- IO Devices $8000 - $BFFF
352
                --
353
                when "10" => -- $8000 - $BFFF
354
                        rom_cs    <= '0';
355
                        ram_cs    <= '0';
356
                   case cpu_addr(3 downto 2) is
357
                        --
358
                        -- PIA TIMER $8004
359
                        --
360
                        when "01" => -- $8004
361
                     cpu_data_in <= pia_data_out;
362
                          uart_cs     <= '0';
363
           pia_cs      <= cpu_vma;
364
                        --
365
                        -- UART / ACIA $8008
366
                        --
367
                        when "10" => -- $8008
368
                     cpu_data_in <= uart_data_out;
369
                          uart_cs     <= cpu_vma;
370
           pia_cs      <= '0';
371
 
372
                        when others =>
373
           cpu_data_in <= "11111111";
374
                          uart_cs     <= '0';
375
           pia_cs      <= '0';
376
                   end case;
377
                --
378
                -- Everything else is RAM
379
                --
380
                when others =>
381
                  cpu_data_in <= ram_data_out;
382
                  rom_cs      <= '0';
383
                  ram_cs      <= cpu_vma;
384
                  uart_cs     <= '0';
385
        pia_cs      <= '0';
386
         end case;
387
end process;
388
 
389
--
390
-- Interrupts and other bus control signals
391
--
392
interrupts : process( BTN_SOUTH, uart_irq,
393
                      pia_irq_a, pia_irq_b
394
                                                         )
395
begin
396
         cpu_reset <= BTN_SOUTH; -- CPU reset is active high
397
    cpu_irq   <= uart_irq;
398
         cpu_nmi   <= pia_irq_a;
399
         cpu_firq  <= pia_irq_b;
400
         cpu_halt  <= '0';
401
    cpu_hold  <= '0';
402
end process;
403
 
404
my_cpu_clock: process( CLK_50MHZ, prescale )
405
begin
406
    if(CLK_50MHZ'event and CLK_50MHZ = '0') then
407
                   prescale <= prescale + "01";
408
    end if;
409
end process;
410
 
411
--
412
-- Baud rate clock
413
-- 50 MHz / 81.38 = ~614.4 KHz (38400 * 16)
414
--
415
my_baud: process( CLK_50MHZ )
416
begin
417
    if(CLK_50MHZ'event and CLK_50MHZ = '0') then
418
                if( BaudCount = 81 )    then
419
                   BaudCount <= "0000000";
420
                        baudclk <= '0';
421
                else
422
                   BaudCount <= BaudCount + 1;
423
                        if BaudCount = 40 then
424
                           baudclk <= '1';
425
         else
426
                           baudclk <= baudclk;
427
         end if;
428
                end if;
429
    end if;
430
end process;
431
 
432
--
433
--
434
my_led_flasher: process( CLK_50MHZ, BTN_SOUTH, CountL )
435
begin
436
    if BTN_SOUTH = '1' then
437
                   CountL <= "000000000000000000000000";
438
    elsif(CLK_50MHZ'event and CLK_50MHZ = '0') then
439
                   CountL <= CountL + 1;
440
    end if;
441
         LED(7 downto 0) <= CountL(23 downto 16);
442
end process;
443
 
444
DCD_n <= '0';
445
CTS_n <= '0';
446
 
447
end my_computer; --===================== End of architecture =======================--
448
 

powered by: WebSVN 2.1.0

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