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

Subversion Repositories plasma

[/] [plasma/] [trunk/] [vhdl/] [plasma_if.vhd] - Blame information for rev 400

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

Line No. Rev Author Line
1 57 rhoads
---------------------------------------------------------------------
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.
9
-- DESCRIPTION:
10
--    This entity divides the clock by two and interfaces to the 
11
--    Altera EP20K200EFC484-2X FPGA board.
12 139 rhoads
--    Xilinx Spartan-3 XC3S200FT256-4 FPGA.
13 57 rhoads
---------------------------------------------------------------------
14
library ieee;
15
use ieee.std_logic_1164.all;
16 139 rhoads
--use work.mlite_pack.all;
17 57 rhoads
 
18
entity plasma_if is
19 139 rhoads
   port(clk_in      : in std_logic;
20
        reset       : in std_logic;
21
        uart_read   : in std_logic;
22
        uart_write  : out std_logic;
23 57 rhoads
 
24 139 rhoads
        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;
34
 
35
        gpio0_out   : out std_logic_vector(31 downto 0);
36
        gpioA_in    : in std_logic_vector(31 downto 0));
37 57 rhoads
end; --entity plasma_if
38
 
39 139 rhoads
 
40 57 rhoads
architecture logic of plasma_if is
41 139 rhoads
 
42
   component plasma
43 186 rhoads
      generic(memory_type : string := "XILINX_16X"; --"DUAL_PORT_" "ALTERA_LPM";
44 139 rhoads
              log_file    : string := "UNUSED");
45
      port(clk               : in std_logic;
46
           reset             : in std_logic;
47
           uart_write        : out std_logic;
48
           uart_read         : in std_logic;
49
 
50
           address           : out std_logic_vector(31 downto 2);
51 263 rhoads
           byte_we           : out std_logic_vector(3 downto 0);
52 139 rhoads
           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;
55
 
56
           gpio0_out         : out std_logic_vector(31 downto 0);
57
           gpioA_in          : in std_logic_vector(31 downto 0));
58
   end component; --plasma
59
 
60 57 rhoads
   signal clk_reg      : std_logic;
61 139 rhoads
   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 263 rhoads
   signal byte_we      : std_logic_vector(3 downto 0);
67 57 rhoads
   signal mem_pause_in : std_logic;
68 139 rhoads
 
69 57 rhoads
begin  --architecture
70 139 rhoads
   --Divide 50 MHz clock by two
71
   clk_div: process(reset, clk_in, clk_reg, we_n_next)
72 57 rhoads
   begin
73 139 rhoads
      if reset = '1' then
74 57 rhoads
         clk_reg <= '0';
75
      elsif rising_edge(clk_in) then
76
         clk_reg <= not clk_reg;
77
      end if;
78 139 rhoads
 
79
      if reset = '1' then
80
         we_n_reg <= '1';
81
         data_reg <= (others => '0');
82
      elsif falling_edge(clk_in) then
83
         we_n_reg <= we_n_next or not clk_reg;
84
         data_reg <= ram_data;
85
      end if;
86 57 rhoads
   end process; --clk_div
87
 
88 139 rhoads
   mem_pause_in <= '0';
89
   ram_address <= mem_address(31 downto 2);
90
   ram_we_n <= we_n_reg;
91
 
92
   --For Xilinx Spartan-3 Starter Kit
93
   ram_control:
94 263 rhoads
   process(clk_reg, mem_address, byte_we, data_write)
95 139 rhoads
   begin
96
      if mem_address(30 downto 28) = "001" then  --RAM
97
         ram_ce1_n <= '0';
98
         ram_ce2_n <= '0';
99 263 rhoads
         if byte_we = "0000" then      --read
100 139 rhoads
            ram_data  <= (others => 'Z');
101
            ram_ub1_n <= '0';
102
            ram_lb1_n <= '0';
103
            ram_ub2_n <= '0';
104
            ram_lb2_n <= '0';
105
            we_n_next <= '1';
106
            ram_oe_n  <= '0';
107
         else                                    --write
108
            if clk_reg = '1' then
109
               ram_data <= (others => 'Z');
110
            else
111
               ram_data <= data_write;
112
            end if;
113 263 rhoads
            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);
117 139 rhoads
            we_n_next <= '0';
118
            ram_oe_n  <= '1';
119
         end if;
120
      else
121
         ram_data <= (others => 'Z');
122
         ram_ce1_n <= '1';
123
         ram_ub1_n <= '1';
124
         ram_lb1_n <= '1';
125
         ram_ce2_n <= '1';
126
         ram_ub2_n <= '1';
127
         ram_lb2_n <= '1';
128
         we_n_next <= '1';
129
         ram_oe_n  <= '1';
130
      end if;
131
   end process; --ram_control
132
 
133 57 rhoads
   u1_plama: plasma
134 139 rhoads
      generic map (memory_type => "XILINX_16X",
135
                   log_file    => "UNUSED")
136 57 rhoads
      PORT MAP (
137 139 rhoads
         clk               => clk_reg,
138
         reset             => reset,
139
         uart_write        => uart_write,
140
         uart_read         => uart_read,
141 57 rhoads
 
142 139 rhoads
         address           => mem_address,
143 263 rhoads
         byte_we           => byte_we,
144 139 rhoads
         data_write        => data_write,
145
         data_read         => data_reg,
146
         mem_pause_in      => mem_pause_in,
147
 
148
         gpio0_out         => gpio0_out,
149
         gpioA_in          => gpioA_in);
150
 
151 57 rhoads
end; --architecture logic
152
 

powered by: WebSVN 2.1.0

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