2010-04-22 04:01:38 +03:00
|
|
|
---------------------------------------------------------------------
|
|
|
|
-- TITLE: Plasma (CPU core with memory)
|
|
|
|
-- AUTHOR: Steve Rhoads (rhoadss@yahoo.com)
|
|
|
|
-- DATE CREATED: 6/4/02
|
|
|
|
-- FILENAME: plasma.vhd
|
|
|
|
-- PROJECT: Plasma CPU core
|
|
|
|
-- COPYRIGHT: Software placed into the public domain by the author.
|
|
|
|
-- Software 'as is' without warranty. Author liable for nothing.
|
|
|
|
-- DESCRIPTION:
|
|
|
|
-- This entity combines the CPU core with memory and a UART.
|
|
|
|
--
|
|
|
|
-- Memory Map:
|
|
|
|
-- 0x00000000 - 0x0000ffff Internal RAM (8KB)
|
|
|
|
-- 0x10000000 - 0x100fffff External RAM (1MB)
|
|
|
|
-- Access all Misc registers with 32-bit accesses
|
|
|
|
-- 0x20000000 Uart Write (will pause CPU if busy)
|
|
|
|
-- 0x20000000 Uart Read
|
|
|
|
-- 0x20000010 IRQ Mask
|
|
|
|
-- 0x20000020 IRQ Status
|
|
|
|
-- 0x20000030 GPIO0 Out Set bits
|
|
|
|
-- 0x20000040 GPIO0 Out Clear bits
|
|
|
|
-- 0x20000050 GPIOA In
|
|
|
|
---------------------------------------------------------------------
|
|
|
|
library ieee;
|
|
|
|
use ieee.std_logic_1164.all;
|
|
|
|
use work.mlite_pack.all;
|
|
|
|
|
|
|
|
entity plasma is
|
|
|
|
generic(memory_type : string := "XILINX_16X"; --"DUAL_PORT_" "ALTERA_LPM";
|
2010-05-04 19:17:38 +03:00
|
|
|
log_file : string := "UNUSED");
|
2010-04-22 04:01:38 +03:00
|
|
|
port(clk : in std_logic;
|
|
|
|
reset : in std_logic;
|
|
|
|
|
|
|
|
uart_write : out std_logic;
|
|
|
|
uart_read : in std_logic;
|
|
|
|
|
|
|
|
data_read : in std_logic_vector(31 downto 0);
|
2010-05-04 19:17:38 +03:00
|
|
|
mem_pause_in : in std_logic
|
|
|
|
);
|
2010-04-22 04:01:38 +03:00
|
|
|
end; --entity plasma
|
|
|
|
|
|
|
|
architecture logic of plasma is
|
|
|
|
signal address_next : std_logic_vector(31 downto 2);
|
|
|
|
signal byte_we_next : std_logic_vector(3 downto 0);
|
|
|
|
signal cpu_address : std_logic_vector(31 downto 0);
|
|
|
|
signal cpu_byte_we : std_logic_vector(3 downto 0);
|
|
|
|
signal cpu_data_w : std_logic_vector(31 downto 0);
|
|
|
|
signal cpu_data_r : std_logic_vector(31 downto 0);
|
|
|
|
signal cpu_pause : std_logic;
|
|
|
|
|
|
|
|
signal data_read_uart : std_logic_vector(7 downto 0);
|
2010-05-01 06:21:55 +03:00
|
|
|
signal write_enable : std_logic;
|
2010-04-22 04:01:38 +03:00
|
|
|
signal mem_busy : std_logic;
|
|
|
|
|
|
|
|
signal enable_misc : std_logic;
|
|
|
|
signal enable_uart : std_logic;
|
|
|
|
signal enable_uart_read : std_logic;
|
|
|
|
signal enable_uart_write : std_logic;
|
|
|
|
|
|
|
|
signal uart_write_busy : std_logic;
|
|
|
|
signal uart_data_avail : std_logic;
|
|
|
|
signal irq_mask_reg : std_logic_vector(7 downto 0);
|
|
|
|
signal irq_status : std_logic_vector(7 downto 0);
|
|
|
|
signal irq : std_logic;
|
|
|
|
|
|
|
|
signal ram_enable : std_logic;
|
|
|
|
signal ram_byte_we : std_logic_vector(3 downto 0);
|
|
|
|
signal ram_address : std_logic_vector(31 downto 2);
|
|
|
|
signal ram_data_w : std_logic_vector(31 downto 0);
|
|
|
|
signal ram_data_r : std_logic_vector(31 downto 0);
|
|
|
|
|
|
|
|
begin --architecture
|
2010-05-04 19:17:38 +03:00
|
|
|
--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
-- PROCESSOR
|
|
|
|
--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
2010-04-22 04:01:38 +03:00
|
|
|
u1_cpu: mlite_cpu
|
|
|
|
generic map (memory_type => memory_type)
|
|
|
|
PORT MAP (
|
|
|
|
clk => clk,
|
|
|
|
reset_in => reset,
|
|
|
|
intr_in => irq,
|
|
|
|
|
|
|
|
address_next => address_next, --before rising_edge(clk)
|
|
|
|
byte_we_next => byte_we_next,
|
|
|
|
|
|
|
|
address => cpu_address(31 downto 2), --after rising_edge(clk)
|
|
|
|
byte_we => cpu_byte_we,
|
|
|
|
data_w => cpu_data_w,
|
|
|
|
data_r => cpu_data_r,
|
|
|
|
mem_pause => cpu_pause);
|
|
|
|
|
2010-05-04 19:17:38 +03:00
|
|
|
--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
-- ADDRESS DECODER
|
|
|
|
--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
write_enable <= '1' when cpu_byte_we /= "0000" else '0';
|
|
|
|
mem_busy <= mem_pause_in;
|
|
|
|
cpu_pause <= '0'; --(uart_write_busy and enable_uart and write_enable) or --UART busy
|
|
|
|
-- (cpu_address(28) and mem_busy); --DDR or flash
|
|
|
|
|
|
|
|
enable_uart <= '1' when cpu_address(30 downto 28) = "010" and cpu_address(7 downto 4) = "0000" else '0';
|
|
|
|
enable_uart_read <= enable_uart and not write_enable;
|
|
|
|
enable_uart_write <= enable_uart and write_enable;
|
|
|
|
cpu_address(1 downto 0) <= "00";
|
|
|
|
ram_enable <= '1' when address_next(30 downto 28) = "000" else '0';
|
|
|
|
ram_byte_we <= byte_we_next;
|
|
|
|
ram_address(31 downto 13) <= ZERO(31 downto 13);
|
|
|
|
ram_address(12 downto 2) <= (address_next(12)) & address_next(11 downto 2);
|
|
|
|
ram_data_w <= cpu_data_w;
|
|
|
|
|
2010-04-22 04:01:38 +03:00
|
|
|
|
|
|
|
misc_proc: process(clk, reset, cpu_address, enable_misc,
|
|
|
|
ram_data_r, data_read, data_read_uart, cpu_pause,
|
2010-05-04 19:17:38 +03:00
|
|
|
irq_mask_reg, irq_status, write_enable,
|
|
|
|
cpu_data_w)
|
2010-04-22 04:01:38 +03:00
|
|
|
begin
|
|
|
|
case cpu_address(30 downto 28) is
|
|
|
|
when "000" => --internal RAM
|
|
|
|
cpu_data_r <= ram_data_r;
|
|
|
|
when "001" => --external RAM
|
|
|
|
cpu_data_r <= data_read; --DDR
|
|
|
|
when "010" => --misc
|
|
|
|
case cpu_address(6 downto 4) is
|
|
|
|
when "000" => --uart
|
|
|
|
cpu_data_r <= ZERO(31 downto 8) & data_read_uart;
|
|
|
|
when "001" => --irq_mask
|
|
|
|
cpu_data_r <= ZERO(31 downto 8) & irq_mask_reg;
|
|
|
|
when "010" => --irq_status
|
|
|
|
cpu_data_r <= ZERO(31 downto 8) & irq_status;
|
|
|
|
when others =>
|
2010-05-04 19:17:38 +03:00
|
|
|
cpu_data_r <= ZERO(31 downto 8) & data_read_uart;
|
2010-04-22 04:01:38 +03:00
|
|
|
end case;
|
|
|
|
when "011" => --flash
|
|
|
|
cpu_data_r <= data_read;
|
|
|
|
when others =>
|
|
|
|
cpu_data_r <= ZERO;
|
|
|
|
end case;
|
2010-05-04 19:17:38 +03:00
|
|
|
end process;
|
2010-04-22 04:01:38 +03:00
|
|
|
|
|
|
|
u2_ram: ram
|
|
|
|
generic map (memory_type => memory_type)
|
|
|
|
port map (
|
|
|
|
clk => clk,
|
|
|
|
enable => ram_enable,
|
|
|
|
write_byte_enable => ram_byte_we,
|
|
|
|
address => ram_address,
|
|
|
|
data_write => ram_data_w,
|
|
|
|
data_read => ram_data_r);
|
|
|
|
|
|
|
|
u3_uart: uart
|
|
|
|
generic map (log_file => log_file)
|
|
|
|
port map(
|
|
|
|
clk => clk,
|
|
|
|
reset => reset,
|
|
|
|
enable_read => enable_uart_read,
|
|
|
|
enable_write => enable_uart_write,
|
|
|
|
data_in => cpu_data_w(7 downto 0),
|
|
|
|
data_out => data_read_uart,
|
|
|
|
uart_read => uart_read,
|
|
|
|
uart_write => uart_write,
|
|
|
|
busy_write => uart_write_busy,
|
|
|
|
data_avail => uart_data_avail);
|
|
|
|
|
|
|
|
|
|
|
|
end; --architecture logic
|
|
|
|
|