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

Subversion Repositories ion

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

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
        sram_databus    : inout std_logic_vector(15 downto 0);
38
        sram_byte_we_n  : out std_logic_vector(1 downto 0);
39
        sram_oe_n       : out std_logic;
40
 
41
        -- UART 
42
        uart_rxd        : in std_logic;
43
        uart_txd        : out std_logic
44
    );
45
end; --entity mips_mpu
46
 
47
architecture rtl of mips_mpu is
48
 
49
 
50
signal reset_sync :         std_logic_vector(2 downto 0);
51
 
52
-- interface cpu-cache
53
signal cpu_data_rd_addr :   t_word;
54
signal cpu_data_rd_vma :    std_logic;
55
signal cpu_data_rd :        t_word;
56
signal cpu_code_rd_addr :   t_pc;
57
signal cpu_code_rd :        t_word;
58
signal cpu_code_rd_vma :    std_logic;
59
signal cpu_data_wr_addr :   t_pc;
60
signal cpu_data_wr :        t_word;
61
signal cpu_byte_we :        std_logic_vector(3 downto 0);
62
signal cpu_mem_wait :       std_logic;
63
 
64
-- 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
signal data_uart :          t_word;
74
signal data_uart_status :   t_word;
75
signal uart_tx_rdy :        std_logic := '1';
76
signal uart_rx_rdy :        std_logic := '1';
77
signal uart_write_tx :      std_logic;
78
signal uart_read_rx :       std_logic;
79
 
80
 
81
-- Block ram
82
constant BRAM_SIZE : integer := @code_table_size@;
83
constant BRAM_ADDR_SIZE : integer := log2(BRAM_SIZE);
84
 
85 56 ja_rd
--type t_bram is array(0 to BRAM_SIZE-1) of std_logic_vector(7 downto 0);
86
type t_bram is array(0 to (BRAM_SIZE)-1) of t_word;
87 55 ja_rd
 
88
-- bram0 is LSB, bram3 is MSB
89 56 ja_rd
--signal bram3 :              t_bram := (@ code3@);
90
--signal bram2 :              t_bram := (@ code2@);
91
--signal bram1 :              t_bram := (@ code1@);
92
--signal bram0 :              t_bram := (@ code0@);
93 55 ja_rd
 
94 56 ja_rd
signal bram :               t_bram := (@code-32bit@);
95
 
96 55 ja_rd
subtype t_bram_address is std_logic_vector(BRAM_ADDR_SIZE-1 downto 0);
97
 
98
signal bram_rd_addr :       t_bram_address;
99
signal bram_wr_addr :       t_bram_address;
100
signal bram_rd_data :       t_word;
101
signal bram_wr_data :       t_word;
102
signal bram_byte_we :       std_logic_vector(3 downto 0);
103
 
104
 
105
--------------------------------------------------------------------------------
106
begin
107
 
108
cpu: entity work.mips_cpu
109
    port map (
110
        interrupt   => '0',
111
 
112
        data_rd_addr=> cpu_data_rd_addr,
113
        data_rd_vma => cpu_data_rd_vma,
114
        data_rd     => cpu_data_rd,
115
 
116
        code_rd_addr=> cpu_code_rd_addr,
117
        code_rd     => cpu_code_rd,
118
        code_rd_vma => cpu_code_rd_vma,
119
 
120
        data_wr_addr=> cpu_data_wr_addr,
121
        data_wr     => cpu_data_wr,
122
        byte_we     => cpu_byte_we,
123
 
124
        mem_wait    => cpu_mem_wait,
125
 
126
        clk         => clk,
127
        reset       => reset
128
    );
129
 
130
cache: entity work.mips_cache_stub
131
    generic map (
132
        BRAM_ADDR_SIZE => BRAM_ADDR_SIZE,
133
        SRAM_ADDR_SIZE => SRAM_ADDR_SIZE
134
    )
135
    port map (
136
        clk             => clk,
137
        reset           => reset,
138
 
139
        -- Interface to CPU core
140
        data_rd_addr    => cpu_data_rd_addr,
141
        data_rd         => cpu_data_rd,
142
        data_rd_vma     => cpu_data_rd_vma,
143
 
144
        code_rd_addr    => cpu_code_rd_addr,
145
        code_rd         => cpu_code_rd,
146
        code_rd_vma     => cpu_code_rd_vma,
147
 
148
        data_wr_addr    => cpu_data_wr_addr,
149
        byte_we         => cpu_byte_we,
150
        data_wr         => cpu_data_wr,
151
 
152
        mem_wait        => cpu_mem_wait,
153
        cache_enable    => '1',
154
 
155
        -- interface to FPGA i/o devices
156
        io_rd_data      => mpu_io_rd_data,
157
        io_wr_data      => mpu_io_wr_data,
158
        io_rd_addr      => mpu_io_rd_addr,
159
        io_wr_addr      => mpu_io_wr_addr,
160
        io_rd_vma       => mpu_io_rd_vma,
161
        io_byte_we      => mpu_io_byte_we,
162
 
163
        -- interface to synchronous 32-bit-wide FPGA BRAM
164
        bram_rd_data    => bram_rd_data,
165
        bram_wr_data    => bram_wr_data,
166
        bram_rd_addr    => bram_rd_addr,
167
        bram_wr_addr    => bram_wr_addr,
168
        bram_byte_we    => bram_byte_we,
169
 
170
        -- interface to asynchronous 16-bit-wide external SRAM
171
        sram_address    => sram_address,
172
        sram_databus    => sram_databus,
173
        sram_byte_we_n  => sram_byte_we_n,
174
        sram_oe_n       => sram_oe_n
175
    );
176
 
177
 
178
--------------------------------------------------------------------------------
179
-- BRAM interface 
180
 
181
fpga_ram_block:
182
process(clk)
183
begin
184
    if clk'event and clk='1' then
185
 
186 56 ja_rd
        --bram_rd_data <= 
187
        --    bram3(conv_integer(unsigned(bram_rd_addr))) &
188
        --    bram2(conv_integer(unsigned(bram_rd_addr))) &
189
        --    bram1(conv_integer(unsigned(bram_rd_addr))) &
190
        --    bram0(conv_integer(unsigned(bram_rd_addr)));
191
        bram_rd_data <= bram(conv_integer(unsigned(bram_rd_addr)));
192 55 ja_rd
 
193
    end if;
194
end process fpga_ram_block;
195
 
196
-- FIXME this should be in parent block
197
reset_synchronization:
198
process(clk)
199
begin
200
    if clk'event and clk='1' then
201
        reset_sync(2) <= reset;
202
        reset_sync(1) <= reset_sync(2);
203
        reset_sync(0) <= reset_sync(1);
204
    end if;
205
end process reset_synchronization;
206
 
207
--------------------------------------------------------------------------------
208
 
209
 
210
--------------------------------------------------------------------------------
211
 
212
serial_rx : entity work.rs232_rx
213
    port map(
214
        rxd =>      uart_rxd,
215
        data_rx =>  OPEN, --rs232_data_rx,
216
        rx_rdy =>   uart_rx_rdy,
217
        read_rx =>  '1', --read_rx,
218
        clk =>      clk,
219
        reset =>    reset_sync(0)
220
    );
221
 
222
 
223
uart_write_tx <= '1'
224
    when mpu_io_byte_we/="0000" and mpu_io_wr_addr(31 downto 28)=X"2"
225
    else '0';
226
 
227
serial_tx : entity work.rs232_tx
228
    port map(
229
        clk =>      clk,
230
        reset =>    reset_sync(0),
231
        rdy =>      uart_tx_rdy,
232
        load =>     uart_write_tx,
233
        data_i =>   mpu_io_wr_data(7 downto 0),
234
        txd =>      uart_txd
235
    );
236
 
237
-- UART read registers; only status, and hardwired, for the time being
238
data_uart <= data_uart_status; -- FIXME no data rx yet
239
data_uart_status <= X"0000000" & "00" & uart_tx_rdy & uart_rx_rdy;
240
 
241
mpu_io_rd_data <= data_uart;
242
 
243
-- io_rd_data 
244
io_rd_addr <= mpu_io_rd_addr;
245
io_wr_addr <= mpu_io_wr_addr;
246
io_wr_data <= mpu_io_wr_data;
247
io_rd_vma <= mpu_io_rd_vma;
248
io_byte_we <= mpu_io_byte_we;
249
 
250
 
251
end architecture rtl;

powered by: WebSVN 2.1.0

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