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

Subversion Repositories mlite

[/] [mlite/] [trunk/] [vhdl/] [plasma.vhd] - Blame information for rev 329

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

Line No. Rev Author Line
1 48 rhoads
---------------------------------------------------------------------
2
-- TITLE: Plasma (CPU core with memory)
3
-- AUTHOR: Steve Rhoads (rhoadss@yahoo.com)
4
-- DATE CREATED: 6/4/02
5
-- FILENAME: plasma.vhd
6
-- PROJECT: Plasma CPU core
7
-- COPYRIGHT: Software placed into the public domain by the author.
8
--    Software 'as is' without warranty.  Author liable for nothing.
9
-- DESCRIPTION:
10
--    This entity combines the CPU core with memory and a UART.
11 139 rhoads
--
12
-- Memory Map:
13 184 rhoads
--   0x00000000 - 0x0000ffff   Internal RAM (8KB)
14
--   0x10000000 - 0x100fffff   External RAM (1MB)
15 139 rhoads
--   Access all Misc registers with 32-bit accesses
16
--   0x20000000  Uart Write (will pause CPU if busy)
17
--   0x20000000  Uart Read
18
--   0x20000010  IRQ Mask
19
--   0x20000020  IRQ Status
20 286 rhoads
--   0x20000030  GPIO0 Out Set bits
21
--   0x20000040  GPIO0 Out Clear bits
22 139 rhoads
--   0x20000050  GPIOA In
23
--   0x20000060  Counter
24 286 rhoads
--   0x20000070  Ethernet transmit count
25 139 rhoads
--   IRQ bits:
26
--      7   GPIO31
27 329 rhoads
--      6  ^GPIO31
28 286 rhoads
--      5   EthernetSendDone
29
--      4   EthernetReceive
30 139 rhoads
--      3   Counter(18)
31
--      2  ^Counter(18)
32
--      1  ^UartWriteBusy
33
--      0   UartDataAvailable
34 48 rhoads
---------------------------------------------------------------------
35
library ieee;
36
use ieee.std_logic_1164.all;
37
use work.mlite_pack.all;
38
 
39
entity plasma is
40 186 rhoads
   generic(memory_type : string := "XILINX_16X"; --"DUAL_PORT_" "ALTERA_LPM";
41 286 rhoads
           log_file    : string := "UNUSED";
42
           ethernet    : std_logic := '0');
43
   port(clk          : in std_logic;
44
        reset        : in std_logic;
45 48 rhoads
 
46 286 rhoads
        uart_write   : out std_logic;
47
        uart_read    : in std_logic;
48 48 rhoads
 
49 286 rhoads
        address      : out std_logic_vector(31 downto 2);
50
        byte_we      : out std_logic_vector(3 downto 0);
51
        data_write   : out std_logic_vector(31 downto 0);
52
        data_read    : in std_logic_vector(31 downto 0);
53
        mem_pause_in : in std_logic;
54 139 rhoads
 
55 286 rhoads
        gpio0_out    : out std_logic_vector(31 downto 0);
56
        gpioA_in     : in std_logic_vector(31 downto 0));
57 48 rhoads
end; --entity plasma
58
 
59
architecture logic of plasma is
60 264 rhoads
   signal address_next    : std_logic_vector(31 downto 2);
61
   signal byte_we_next    : std_logic_vector(3 downto 0);
62
   signal mem_address     : std_logic_vector(31 downto 2);
63
   signal mem_byte_we     : std_logic_vector(3 downto 0);
64
   signal data_r          : std_logic_vector(31 downto 0);
65
   signal data_w          : std_logic_vector(31 downto 0);
66
   signal data_read_ram   : std_logic_vector(31 downto 0);
67
   signal data_read_uart  : std_logic_vector(7 downto 0);
68
   signal write_enable    : std_logic;
69
   signal mem_pause       : std_logic;
70 286 rhoads
   signal eth_pause       : std_logic;
71 139 rhoads
 
72
   signal enable_internal_ram : std_logic;
73
   signal enable_misc         : std_logic;
74
   signal enable_uart         : std_logic;
75
   signal enable_uart_read    : std_logic;
76
   signal enable_uart_write   : std_logic;
77 286 rhoads
   signal enable_eth          : std_logic;
78 139 rhoads
 
79
   signal gpio0_reg           : std_logic_vector(31 downto 0);
80
 
81
   signal uart_write_busy     : std_logic;
82
   signal uart_data_avail     : std_logic;
83
   signal irq_mask_reg        : std_logic_vector(7 downto 0);
84
   signal irq_status          : std_logic_vector(7 downto 0);
85
   signal irq                 : std_logic;
86 286 rhoads
   signal irq_eth_rec         : std_logic;
87
   signal irq_eth_send        : std_logic;
88 139 rhoads
   signal counter_reg         : std_logic_vector(31 downto 0);
89
 
90 48 rhoads
begin  --architecture
91 264 rhoads
   write_enable <= '1' when mem_byte_we /= "0000" else '0';
92 286 rhoads
   mem_pause <= ((mem_pause_in or eth_pause) and not enable_misc) or
93
                (uart_write_busy and enable_uart and write_enable);
94
   irq_status <= gpioA_in(31) & not gpioA_in(31) &
95
                 irq_eth_send & irq_eth_rec &
96 139 rhoads
                 counter_reg(18) & not counter_reg(18) &
97
                 not uart_write_busy & uart_data_avail;
98
   irq <= '1' when (irq_status and irq_mask_reg) /= ZERO(7 downto 0) else '0';
99 286 rhoads
   gpio0_out(31 downto 29) <= gpio0_reg(31 downto 29);
100
   gpio0_out(23 downto 0) <= gpio0_reg(23 downto 0);
101 139 rhoads
 
102 264 rhoads
   enable_internal_ram <= '1' when address_next(30 downto 28) = "000" else '0';
103
   enable_misc <= '1' when mem_address(30 downto 28) = "010" else '0';
104
   enable_uart <= '1' when enable_misc = '1' and mem_address(7 downto 4) = "0000" else '0';
105 139 rhoads
   enable_uart_read <= enable_uart and not write_enable;
106
   enable_uart_write <= enable_uart and write_enable;
107 286 rhoads
   enable_eth <= '1' when enable_misc = '1' and mem_address(7 downto 4) = "0111" else '0';
108 139 rhoads
 
109 48 rhoads
   u1_cpu: mlite_cpu
110
      generic map (memory_type => memory_type)
111
      PORT MAP (
112 139 rhoads
         clk          => clk,
113
         reset_in     => reset,
114
         intr_in      => irq,
115 48 rhoads
 
116 264 rhoads
         address_next => address_next,
117
         byte_we_next => byte_we_next,
118
 
119
         address      => mem_address,
120
         byte_we      => mem_byte_we,
121
         data_w       => data_w,
122
         data_r       => data_r,
123 48 rhoads
         mem_pause    => mem_pause);
124
 
125 264 rhoads
   misc_proc: process(clk, reset, address_next, mem_address, enable_misc,
126 139 rhoads
      data_read_ram, data_read, data_read_uart, mem_pause,
127
      irq_mask_reg, irq_status, gpio0_reg, write_enable,
128 264 rhoads
      gpioA_in, counter_reg, data_w)
129 139 rhoads
   begin
130 264 rhoads
      case mem_address(30 downto 28) is
131 139 rhoads
      when "000" =>      --internal RAM
132 264 rhoads
         data_r <= data_read_ram;
133 139 rhoads
      when "001" =>      --external RAM
134 264 rhoads
         data_r <= data_read;
135 139 rhoads
      when "010" =>      --misc
136 264 rhoads
         case mem_address(6 downto 4) is
137 139 rhoads
         when "000" =>      --uart
138 264 rhoads
            data_r <= ZERO(31 downto 8) & data_read_uart;
139 139 rhoads
         when "001" =>      --irq_mask
140 264 rhoads
            data_r <= ZERO(31 downto 8) & irq_mask_reg;
141 139 rhoads
         when "010" =>      --irq_status
142 264 rhoads
            data_r <= ZERO(31 downto 8) & irq_status;
143 139 rhoads
         when "011" =>      --gpio0
144 264 rhoads
            data_r <= gpio0_reg;
145 139 rhoads
         when "101" =>      --gpioA
146 264 rhoads
            data_r <= gpioA_in;
147 139 rhoads
         when "110" =>      --counter
148 264 rhoads
            data_r <= counter_reg;
149 139 rhoads
         when others =>
150 264 rhoads
            data_r <= gpioA_in;
151 139 rhoads
         end case;
152 286 rhoads
      when "011" =>      --flash
153
         data_r <= data_read;
154 139 rhoads
      when others =>
155 264 rhoads
         data_r <= ZERO;
156 139 rhoads
      end case;
157
 
158
      if reset = '1' then
159
         irq_mask_reg <= ZERO(7 downto 0);
160
         gpio0_reg <= ZERO;
161
         counter_reg <= ZERO;
162
      elsif rising_edge(clk) then
163
         if mem_pause = '0' then
164
            if enable_misc = '1' and write_enable = '1' then
165 264 rhoads
               if mem_address(6 downto 4) = "001" then
166
                  irq_mask_reg <= data_w(7 downto 0);
167
               elsif mem_address(6 downto 4) = "011" then
168 286 rhoads
                  gpio0_reg <= gpio0_reg or data_w;
169
               elsif mem_address(6 downto 4) = "100" then
170
                  gpio0_reg <= gpio0_reg and not data_w;
171 139 rhoads
               end if;
172
            end if;
173
         end if;
174
         counter_reg <= bv_inc(counter_reg);
175
      end if;
176
   end process;
177
 
178 48 rhoads
   u2_ram: ram
179
      generic map (memory_type => memory_type)
180 139 rhoads
      port map (
181
         clk               => clk,
182
         enable            => enable_internal_ram,
183 264 rhoads
         write_byte_enable => byte_we_next,
184
         address           => address_next,
185
         data_write        => data_w,
186 139 rhoads
         data_read         => data_read_ram);
187 48 rhoads
 
188
   u3_uart: uart
189
      generic map (log_file => log_file)
190
      port map(
191 139 rhoads
         clk          => clk,
192
         reset        => reset,
193
         enable_read  => enable_uart_read,
194
         enable_write => enable_uart_write,
195 264 rhoads
         data_in      => data_w(7 downto 0),
196 139 rhoads
         data_out     => data_read_uart,
197
         uart_read    => uart_read,
198
         uart_write   => uart_write,
199
         busy_write   => uart_write_busy,
200
         data_avail   => uart_data_avail);
201 48 rhoads
 
202 286 rhoads
   dma_gen: if ethernet = '0' generate
203
      address <= mem_address;
204
      byte_we <= mem_byte_we;
205
      data_write <= data_w;
206
      eth_pause <= '0';
207
      gpio0_out(28 downto 24) <= ZERO(28 downto 24);
208
      irq_eth_rec <= '0';
209
      irq_eth_send <= '0';
210
   end generate;
211
 
212
   dma_gen2: if ethernet = '1' generate
213
   u4_eth: eth_dma
214
      port map(
215
         clk         => clk,
216
         reset       => reset,
217
         enable_eth  => gpio0_reg(24),
218
         select_eth  => enable_eth,
219
         rec_isr     => irq_eth_rec,
220
         send_isr    => irq_eth_send,
221
 
222
         address     => address,      --to DDR
223
         byte_we     => byte_we,
224
         data_write  => data_write,
225
         data_read   => data_read,
226
         pause_in    => mem_pause_in,
227
 
228
         mem_address => mem_address,  --from CPU
229
         mem_byte_we => mem_byte_we,
230
         data_w      => data_w,
231
         pause_out   => eth_pause,
232
 
233
         E_RX_CLK    => gpioA_in(20),
234
         E_RX_DV     => gpioA_in(19),
235
         E_RXD       => gpioA_in(18 downto 15),
236
         E_TX_CLK    => gpioA_in(14),
237
         E_TX_EN     => gpio0_out(28),
238
         E_TXD       => gpio0_out(27 downto 24));
239
   end generate;
240
 
241 48 rhoads
end; --architecture logic

powered by: WebSVN 2.1.0

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