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

Subversion Repositories ion

[/] [ion/] [trunk/] [src/] [mips_mpu1_template.vhdl] - Blame information for rev 102

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

Line No. Rev Author Line
1 55 ja_rd
--------------------------------------------------------------------------------
2
-- This file was generated automatically from '/src/mips_mpu2_template.vhdl'.
3
--------------------------------------------------------------------------------
4
-- Synthesizable MPU -- CPU + cache + bootstrap BRAM + UART
5
--
6
-- This module uses the 'stub' version of the cache: a cache which actually is 
7
-- only an interface between the cpu and external static memory. This is useful 
8
-- to test external memory interface and cache-cpu interface without the cache
9
-- functionality getting in the way.
10
--------------------------------------------------------------------------------
11
 
12
library ieee;
13
use ieee.std_logic_1164.all;
14
use ieee.std_logic_arith.all;
15
use ieee.std_logic_unsigned.all;
16
use work.mips_pkg.all;
17
 
18
entity mips_mpu is
19
    generic (
20
        SRAM_ADDR_SIZE : integer := 17
21
    );
22
    port(
23
        clk             : in std_logic;
24
        reset           : in std_logic;
25
        interrupt       : in std_logic;
26
 
27
        -- interface to FPGA i/o devices
28
        io_rd_data      : in std_logic_vector(31 downto 0);
29
        io_rd_addr      : out std_logic_vector(31 downto 2);
30
        io_wr_addr      : out std_logic_vector(31 downto 2);
31
        io_wr_data      : out std_logic_vector(31 downto 0);
32
        io_rd_vma       : out std_logic;
33
        io_byte_we      : out std_logic_vector(3 downto 0);
34
 
35
        -- interface to asynchronous 16-bit-wide EXTERNAL SRAM
36
        sram_address    : out std_logic_vector(SRAM_ADDR_SIZE downto 1);
37 77 ja_rd
        sram_data_wr    : out std_logic_vector(15 downto 0);
38
        sram_data_rd    : in std_logic_vector(15 downto 0);
39 55 ja_rd
        sram_byte_we_n  : out std_logic_vector(1 downto 0);
40
        sram_oe_n       : out std_logic;
41
 
42
        -- UART 
43
        uart_rxd        : in std_logic;
44
        uart_txd        : out std_logic
45
    );
46
end; --entity mips_mpu
47
 
48
architecture rtl of mips_mpu is
49
 
50
-- interface cpu-cache
51 97 ja_rd
signal cpu_data_addr :      t_word;
52 55 ja_rd
signal cpu_data_rd_vma :    std_logic;
53
signal cpu_data_rd :        t_word;
54
signal cpu_code_rd_addr :   t_pc;
55
signal cpu_code_rd :        t_word;
56
signal cpu_code_rd_vma :    std_logic;
57
signal cpu_data_wr :        t_word;
58
signal cpu_byte_we :        std_logic_vector(3 downto 0);
59
signal cpu_mem_wait :       std_logic;
60 102 ja_rd
signal cpu_ic_invalidate :  std_logic;
61
signal cpu_cache_enable :   std_logic;
62 55 ja_rd
 
63 102 ja_rd
 
64 55 ja_rd
-- interface to i/o
65
signal mpu_io_rd_data :     std_logic_vector(31 downto 0);
66
signal mpu_io_wr_data :     std_logic_vector(31 downto 0);
67
signal mpu_io_rd_addr :     std_logic_vector(31 downto 2);
68
signal mpu_io_wr_addr :     std_logic_vector(31 downto 2);
69
signal mpu_io_rd_vma :      std_logic;
70
signal mpu_io_byte_we :     std_logic_vector(3 downto 0);
71
 
72
-- interface to UARTs
73 87 ja_rd
signal uart_rd_word :       t_word;
74 55 ja_rd
signal uart_tx_rdy :        std_logic := '1';
75
signal uart_rx_rdy :        std_logic := '1';
76 87 ja_rd
signal uart_write :         std_logic;
77
signal uart_read :          std_logic;
78 55 ja_rd
signal uart_read_rx :       std_logic;
79 87 ja_rd
signal uart_data_rx :       std_logic_vector(7 downto 0);
80 55 ja_rd
 
81
 
82
-- Block ram
83
constant BRAM_SIZE : integer := @code_table_size@;
84
constant BRAM_ADDR_SIZE : integer := log2(BRAM_SIZE);
85
 
86 56 ja_rd
--type t_bram is array(0 to BRAM_SIZE-1) of std_logic_vector(7 downto 0);
87
type t_bram is array(0 to (BRAM_SIZE)-1) of t_word;
88 55 ja_rd
 
89
-- bram0 is LSB, bram3 is MSB
90 56 ja_rd
--signal bram3 :              t_bram := (@ code3@);
91
--signal bram2 :              t_bram := (@ code2@);
92
--signal bram1 :              t_bram := (@ code1@);
93
--signal bram0 :              t_bram := (@ code0@);
94 55 ja_rd
 
95 56 ja_rd
signal bram :               t_bram := (@code-32bit@);
96
 
97 55 ja_rd
subtype t_bram_address is std_logic_vector(BRAM_ADDR_SIZE-1 downto 0);
98
 
99
signal bram_rd_addr :       t_bram_address;
100
signal bram_wr_addr :       t_bram_address;
101
signal bram_rd_data :       t_word;
102
signal bram_wr_data :       t_word;
103
signal bram_byte_we :       std_logic_vector(3 downto 0);
104
 
105
 
106
--------------------------------------------------------------------------------
107
begin
108
 
109
cpu: entity work.mips_cpu
110
    port map (
111
        interrupt   => '0',
112
 
113 97 ja_rd
        data_addr   => cpu_data_addr,
114 55 ja_rd
        data_rd_vma => cpu_data_rd_vma,
115
        data_rd     => cpu_data_rd,
116
 
117
        code_rd_addr=> cpu_code_rd_addr,
118
        code_rd     => cpu_code_rd,
119
        code_rd_vma => cpu_code_rd_vma,
120
 
121
        data_wr     => cpu_data_wr,
122
        byte_we     => cpu_byte_we,
123
 
124
        mem_wait    => cpu_mem_wait,
125 102 ja_rd
        cache_enable=> cpu_cache_enable,
126
        ic_invalidate=>cpu_ic_invalidate,
127 55 ja_rd
 
128
        clk         => clk,
129
        reset       => reset
130
    );
131
 
132
cache: entity work.mips_cache_stub
133
    generic map (
134
        BRAM_ADDR_SIZE => BRAM_ADDR_SIZE,
135
        SRAM_ADDR_SIZE => SRAM_ADDR_SIZE
136
    )
137
    port map (
138
        clk             => clk,
139
        reset           => reset,
140
 
141
        -- Interface to CPU core
142 97 ja_rd
        data_addr       => cpu_data_addr,
143 55 ja_rd
        data_rd         => cpu_data_rd,
144
        data_rd_vma     => cpu_data_rd_vma,
145
 
146
        code_rd_addr    => cpu_code_rd_addr,
147
        code_rd         => cpu_code_rd,
148
        code_rd_vma     => cpu_code_rd_vma,
149
 
150
        byte_we         => cpu_byte_we,
151
        data_wr         => cpu_data_wr,
152
 
153
        mem_wait        => cpu_mem_wait,
154 102 ja_rd
        cache_enable    => cpu_cache_enable,
155
        ic_invalidate   => cpu_ic_invalidate,
156 55 ja_rd
 
157
        -- interface to FPGA i/o devices
158
        io_rd_data      => mpu_io_rd_data,
159
        io_wr_data      => mpu_io_wr_data,
160
        io_rd_addr      => mpu_io_rd_addr,
161
        io_wr_addr      => mpu_io_wr_addr,
162
        io_rd_vma       => mpu_io_rd_vma,
163
        io_byte_we      => mpu_io_byte_we,
164
 
165
        -- interface to synchronous 32-bit-wide FPGA BRAM
166
        bram_rd_data    => bram_rd_data,
167
        bram_wr_data    => bram_wr_data,
168
        bram_rd_addr    => bram_rd_addr,
169
        bram_wr_addr    => bram_wr_addr,
170
        bram_byte_we    => bram_byte_we,
171
 
172
        -- interface to asynchronous 16-bit-wide external SRAM
173
        sram_address    => sram_address,
174 77 ja_rd
        sram_data_rd    => sram_data_rd,
175
        sram_data_wr    => sram_data_wr,
176 55 ja_rd
        sram_byte_we_n  => sram_byte_we_n,
177
        sram_oe_n       => sram_oe_n
178
    );
179
 
180
 
181
--------------------------------------------------------------------------------
182
-- BRAM interface 
183
 
184
fpga_ram_block:
185
process(clk)
186
begin
187
    if clk'event and clk='1' then
188
 
189 56 ja_rd
        --bram_rd_data <= 
190
        --    bram3(conv_integer(unsigned(bram_rd_addr))) &
191
        --    bram2(conv_integer(unsigned(bram_rd_addr))) &
192
        --    bram1(conv_integer(unsigned(bram_rd_addr))) &
193
        --    bram0(conv_integer(unsigned(bram_rd_addr)));
194
        bram_rd_data <= bram(conv_integer(unsigned(bram_rd_addr)));
195 55 ja_rd
 
196
    end if;
197
end process fpga_ram_block;
198
 
199
 
200
--------------------------------------------------------------------------------
201
 
202
 
203
--------------------------------------------------------------------------------
204
 
205
serial_rx : entity work.rs232_rx
206
    port map(
207
        rxd =>      uart_rxd,
208 87 ja_rd
        data_rx =>  uart_data_rx,
209 55 ja_rd
        rx_rdy =>   uart_rx_rdy,
210 87 ja_rd
        read_rx =>  uart_read_rx,
211 55 ja_rd
        clk =>      clk,
212 59 ja_rd
        reset =>    reset
213 55 ja_rd
    );
214
 
215
 
216 87 ja_rd
-- '1'-> Read some UART register (0x2---0---)
217
uart_read <= '1'
218
    when mpu_io_rd_vma='1' and
219
         mpu_io_rd_addr(31 downto 28)=X"2" and
220
         mpu_io_rd_addr(15 downto 12)=X"0"
221
    else '0';
222
 
223
-- '1'-> Read UART Rx data (0x2---0-0-)
224
-- (This signal clears the RX 1-char buffer)
225
uart_read_rx <= '1'
226
    when uart_read='1' and
227
         mpu_io_rd_addr( 7 downto  4)=X"0"
228
    else '0';
229
 
230
-- '1'-> Write UART Tx register (trigger UART Tx)  (0x20000000)
231
uart_write <= '1'
232 65 ja_rd
    when mpu_io_byte_we/="0000" and
233
         mpu_io_wr_addr(31 downto 28)=X"2" and
234
         mpu_io_wr_addr(15 downto 12)=X"0"
235 55 ja_rd
    else '0';
236
 
237
serial_tx : entity work.rs232_tx
238
    port map(
239
        clk =>      clk,
240 59 ja_rd
        reset =>    reset,
241 55 ja_rd
        rdy =>      uart_tx_rdy,
242 87 ja_rd
        load =>     uart_write,
243 55 ja_rd
        data_i =>   mpu_io_wr_data(7 downto 0),
244
        txd =>      uart_txd
245
    );
246
 
247 87 ja_rd
-- Both UART rd addresses 000 and 020 read the same word (save a mux), but only
248
-- address 000 clears the rx buffer.
249
uart_rd_word <= uart_data_rx & X"00000" & "00" & uart_tx_rdy & uart_rx_rdy;
250 55 ja_rd
 
251 87 ja_rd
-- IO Rd mux: either the UART data/status word od the IO coming from outside
252 65 ja_rd
mpu_io_rd_data <=
253 87 ja_rd
    uart_rd_word when mpu_io_rd_addr(15 downto 12)=X"0" else
254 65 ja_rd
    io_rd_data;
255 55 ja_rd
 
256
-- io_rd_data 
257
io_rd_addr <= mpu_io_rd_addr;
258
io_wr_addr <= mpu_io_wr_addr;
259
io_wr_data <= mpu_io_wr_data;
260
io_rd_vma <= mpu_io_rd_vma;
261
io_byte_we <= mpu_io_byte_we;
262
 
263
 
264
end architecture rtl;

powered by: WebSVN 2.1.0

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