1 ---------------------------------------------------------------------
2 -- TITLE: Plamsa Interface (clock divider and interface to FPGA board)
3 -- AUTHOR: Steve Rhoads (rhoadss@yahoo.com)
4 -- DATE CREATED: 6/6/02
5 -- FILENAME: plasma_if.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.
10 -- This entity divides the clock by two and interfaces to the
11 -- Altera EP20K200EFC484-2X FPGA board.
12 -- Xilinx Spartan-3 XC3S200FT256-4 FPGA.
13 ---------------------------------------------------------------------
15 use ieee.std_logic_1164.all;
16 --use work.mlite_pack.all;
19 port(clk_in : in std_logic;
21 uart_read : in std_logic;
22 uart_write : out std_logic;
24 ram_address : out std_logic_vector(31 downto 2);
25 ram_data : inout std_logic_vector(31 downto 0);
26 ram_ce1_n : out std_logic;
27 ram_ub1_n : out std_logic;
28 ram_lb1_n : out std_logic;
29 ram_ce2_n : out std_logic;
30 ram_ub2_n : out std_logic;
31 ram_lb2_n : out std_logic;
32 ram_we_n : out std_logic;
33 ram_oe_n : out std_logic;
35 gpio0_out : out std_logic_vector(31 downto 0);
36 gpioA_in : in std_logic_vector(31 downto 0));
37 end; --entity plasma_if
40 architecture logic of plasma_if is
43 generic(memory_type : string := "XILINX_16X"; --"DUAL_PORT_" "ALTERA_LPM";
44 log_file : string := "UNUSED");
45 port(clk : in std_logic;
47 uart_write : out std_logic;
48 uart_read : in std_logic;
50 address : out std_logic_vector(31 downto 2);
51 byte_we : out std_logic_vector(3 downto 0);
52 data_write : out std_logic_vector(31 downto 0);
53 data_read : in std_logic_vector(31 downto 0);
54 mem_pause_in : in std_logic;
56 gpio0_out : out std_logic_vector(31 downto 0);
57 gpioA_in : in std_logic_vector(31 downto 0));
58 end component; --plasma
60 signal clk_reg : std_logic;
61 signal we_n_next : std_logic;
62 signal we_n_reg : std_logic;
63 signal mem_address : std_logic_vector(31 downto 2);
64 signal data_write : std_logic_vector(31 downto 0);
65 signal data_reg : std_logic_vector(31 downto 0);
66 signal byte_we : std_logic_vector(3 downto 0);
67 signal mem_pause_in : std_logic;
70 --Divide 50 MHz clock by two
71 clk_div: process(reset, clk_in, clk_reg, we_n_next)
75 elsif rising_edge(clk_in) then
76 clk_reg <= not clk_reg;
81 data_reg <= (others => '0');
82 elsif falling_edge(clk_in) then
83 we_n_reg <= we_n_next or not clk_reg;
86 end process; --clk_div
89 ram_address <= mem_address(31 downto 2);
92 --For Xilinx Spartan-3 Starter Kit
94 process(clk_reg, mem_address, byte_we, data_write)
96 if mem_address(30 downto 28) = "001" then --RAM
99 if byte_we = "0000" then --read
100 ram_data <= (others => 'Z');
108 if clk_reg = '1' then
109 ram_data <= (others => 'Z');
111 ram_data <= data_write;
113 ram_ub1_n <= not byte_we(3);
114 ram_lb1_n <= not byte_we(2);
115 ram_ub2_n <= not byte_we(1);
116 ram_lb2_n <= not byte_we(0);
121 ram_data <= (others => 'Z');
131 end process; --ram_control
134 generic map (memory_type => "XILINX_16X",
135 log_file => "UNUSED")
139 uart_write => uart_write,
140 uart_read => uart_read,
142 address => mem_address,
144 data_write => data_write,
145 data_read => data_reg,
146 mem_pause_in => mem_pause_in,
148 gpio0_out => gpio0_out,
149 gpioA_in => gpioA_in);
151 end; --architecture logic