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

Subversion Repositories the_wizardry_project

[/] [the_wizardry_project/] [trunk/] [Wizardry/] [VHDL/] [Wizardry Top Level/] [Address Generation/] [JOP/] [jopcpu.vhd] - Blame information for rev 22

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 22 mcwaccent
--
2
--
3
--  This file is a part of JOP, the Java Optimized Processor
4
--
5
--  Copyright (C) 2001-2008, Martin Schoeberl (martin@jopdesign.com)
6
--
7
--  This program is free software: you can redistribute it and/or modify
8
--  it under the terms of the GNU General Public License as published by
9
--  the Free Software Foundation, either version 3 of the License, or
10
--  (at your option) any later version.
11
--
12
--  This program is distributed in the hope that it will be useful,
13
--  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
--  GNU General Public License for more details.
16
--
17
--  You should have received a copy of the GNU General Public License
18
--  along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
--
20
 
21
 
22
--
23
--      jopcpu.vhd
24
--
25
--      The JOP CPU
26
--
27
--      2007-03-16      creation
28
--      2007-04-13      Changed memory connection to records
29
--      2008-02-20      memory - I/O muxing after the memory controller (mem_sc)
30
--      2008-03-03      added scratchpad RAM
31
--      2008-03-04      correct MUX selection
32
--
33
--      todo: clean up: substitute all signals by records
34
 
35
 
36
library ieee;
37
use ieee.std_logic_1164.all;
38
use ieee.numeric_std.all;
39
 
40
use work.jop_types.all;
41
use work.sc_pack.all;
42
 
43
 
44
entity jopcpu is
45
 
46
generic (
47
        jpc_width       : integer;                      -- address bits of java bytecode pc = cache size
48
        block_bits      : integer;                      -- 2*block_bits is number of cache blocks
49
        spm_width       : integer := 0           -- size of scratchpad RAM (in number of address bits)
50
);
51
 
52
port (
53
        clk             : in std_logic;
54
        reset   : in std_logic;
55
 
56
--
57
--      SimpCon memory interface
58
--
59
        sc_mem_out              : out sc_out_type;
60
        sc_mem_in               : in sc_in_type;
61
 
62
--
63
--      SimpCon IO interface
64
--
65
        sc_io_out               : out sc_out_type;
66
        sc_io_in                : in sc_in_type;
67
 
68
--
69
--      Interrupts from sc_sys
70
--
71
        irq_in                  : in irq_bcf_type;
72
        irq_out                 : out irq_ack_type;
73
        exc_req                 : out exception_type
74
);
75
end jopcpu;
76
 
77
architecture rtl of jopcpu is
78
 
79
--
80
--      Signals
81
--
82
 
83
        signal stack_tos                : std_logic_vector(31 downto 0);
84
        signal stack_nos                : std_logic_vector(31 downto 0);
85
        signal rd, wr                   : std_logic;
86
        signal ext_addr                 : std_logic_vector(EXTA_WIDTH-1 downto 0);
87
        signal stack_din                : std_logic_vector(31 downto 0);
88
 
89
-- extension/mem interface
90
 
91
        signal mem_in                   : mem_in_type;
92
        signal mem_out                  : mem_out_type;
93
 
94
        signal sc_ctrl_mem_out  : sc_out_type;
95
        signal sc_ctrl_mem_in   : sc_in_type;
96
 
97
        signal sc_scratch_out   : sc_out_type;
98
        signal sc_scratch_in    : sc_in_type;
99
 
100
        signal next_mux_mem             : std_logic_vector(1 downto 0);
101
        signal dly_mux_mem              : std_logic_vector(1 downto 0);
102
        signal mux_mem                  : std_logic_vector(1 downto 0);
103
        signal is_pipelined             : std_logic;
104
 
105
        signal mem_access               : std_logic;
106
        signal scratch_access   : std_logic;
107
        signal io_access                : std_logic;
108
 
109
        signal bsy                              : std_logic;
110
 
111
        signal jbc_addr                 : std_logic_vector(jpc_width-1 downto 0);
112
        signal jbc_data                 : std_logic_vector(7 downto 0);
113
 
114
-- SimpCon io interface
115
 
116
        signal sp_ov                    : std_logic;
117
 
118
begin
119
 
120
--
121
--      components of jop
122
--
123
 
124
        cmp_core: entity work.core
125
                generic map(jpc_width)
126
                port map (clk, reset,
127
                        bsy,
128
                        stack_din, ext_addr,
129
                        rd, wr,
130
                        jbc_addr, jbc_data,
131
                        irq_in, irq_out, sp_ov,
132
                        stack_tos, stack_nos
133
                );
134
 
135
        exc_req.spov <= sp_ov;
136
 
137
        cmp_ext: entity work.extension
138
                port map (
139
                        clk => clk,
140
                        reset => reset,
141
                        ain => stack_tos,
142
                        bin => stack_nos,
143
 
144
                        ext_addr => ext_addr,
145
                        rd => rd,
146
                        wr => wr,
147
                        bsy => bsy,
148
                        dout => stack_din,
149
 
150
                        mem_in => mem_in,
151
                        mem_out => mem_out
152
                );
153
 
154
        cmp_mem: entity work.mem_sc
155
                generic map (
156
                        jpc_width => jpc_width,
157
                        block_bits => block_bits
158
                )
159
                port map (
160
                        clk => clk,
161
                        reset => reset,
162
                        ain => stack_tos,
163
                        bin => stack_nos,
164
 
165
                        np_exc => exc_req.np,
166
                        ab_exc => exc_req.ab,
167
 
168
                        mem_in => mem_in,
169
                        mem_out => mem_out,
170
 
171
                        jbc_addr => jbc_addr,
172
                        jbc_data => jbc_data,
173
 
174
                        sc_mem_out => sc_ctrl_mem_out,
175
                        sc_mem_in => sc_ctrl_mem_in
176
                );
177
 
178
 
179
        --
180
        -- Generate scratchpad memory when size is != 0.
181
        -- Results in warnings when the size is 0.
182
        --
183
        sc1: if spm_width /= 0 generate
184
                cmp_scm: entity work.sdpram
185
                        generic map (
186
                                width => 32,
187
                                addr_width => spm_width
188
                        )
189
                        port map (
190
                                wrclk => clk,
191
                                data => sc_scratch_out.wr_data,
192
                                wraddress => sc_scratch_out.address(spm_width-1 downto 0),
193
                                wren => sc_scratch_out.wr,
194
                                rdclk => clk,
195
                                rdaddress => sc_scratch_out.address(spm_width-1 downto 0),
196
                                rden => sc_scratch_out.rd,
197
                                dout => sc_scratch_in.rd_data
198
                );
199
        end generate;
200
 
201
        sc_scratch_in.rdy_cnt <= (others => '0');
202
 
203
        --
204
        --      Select for the read mux
205
        --
206
        --      TODO: this mux selection works ONLY for two cycle pipelining!
207
        --
208
 
209
process(clk, reset)
210
begin
211
        if (reset='1') then
212
                dly_mux_mem <= (others => '0');
213
                next_mux_mem <= (others => '0');
214
                is_pipelined <= '0';
215
        elsif rising_edge(clk) then
216
 
217
                if sc_ctrl_mem_out.rd='1' or sc_ctrl_mem_out.wr='1' then
218
                        -- highest address bits decides between IO, memory, and on-chip memory
219
                        -- save the mux selection on read or write
220
                        next_mux_mem <= sc_ctrl_mem_out.address(SC_ADDR_SIZE-1 downto SC_ADDR_SIZE-2);
221
                        -- a read or write with rdy_cnt of 1 means pipelining
222
                        if sc_ctrl_mem_in.rdy_cnt(1) = '0' then
223
                                is_pipelined <= '1';
224
                        end if;
225
                end if;
226
                -- delayed mux selection for pipelined access
227
                if sc_ctrl_mem_in.rdy_cnt(1) = '0' then
228
                        dly_mux_mem <= next_mux_mem;
229
                end if;
230
                -- pipelining is over
231
                if sc_ctrl_mem_in.rdy_cnt = "00" then
232
                        is_pipelined <= '0';
233
                end if;
234
 
235
        end if;
236
end process;
237
 
238
process(next_mux_mem, dly_mux_mem, sc_ctrl_mem_out, sc_ctrl_mem_in, sc_mem_in, sc_io_in, sc_scratch_in, is_pipelined, mux_mem)
239
begin
240
 
241
        mem_access <= '0';
242
        scratch_access <= '0';
243
        io_access <= '0';
244
 
245
        -- for one cycle peripherals we need to set the mux from next_mux_mem
246
        mux_mem <= next_mux_mem;
247
        -- for pipelining we need to delay the mux selection
248
        if is_pipelined='1' then
249
                mux_mem <= dly_mux_mem;
250
        end if;
251
 
252
        -- read MUX
253
        case mux_mem is
254
                when "10" =>
255
                        sc_ctrl_mem_in <= sc_scratch_in;
256
                when "11" =>
257
                        sc_ctrl_mem_in <= sc_io_in;
258
                when others =>
259
                        sc_ctrl_mem_in <= sc_mem_in;
260
        end case;
261
 
262
        -- select
263
        case sc_ctrl_mem_out.address(SC_ADDR_SIZE-1 downto SC_ADDR_SIZE-2) is
264
                when "10" =>
265
                        scratch_access <= '1';
266
                when "11" =>
267
                        io_access <= '1';
268
                when others =>
269
                        mem_access <= '1';
270
        end case;
271
 
272
end process;
273
 
274
        sc_mem_out.address <= sc_ctrl_mem_out.address;
275
        sc_mem_out.wr_data <= sc_ctrl_mem_out.wr_data;
276
        sc_mem_out.wr <= sc_ctrl_mem_out.wr and mem_access;
277
        sc_mem_out.rd <= sc_ctrl_mem_out.rd and mem_access;
278
 
279
        sc_scratch_out.address <= sc_ctrl_mem_out.address;
280
        sc_scratch_out.wr_data <= sc_ctrl_mem_out.wr_data;
281
        sc_scratch_out.wr <= sc_ctrl_mem_out.wr and scratch_access;
282
        sc_scratch_out.rd <= sc_ctrl_mem_out.rd and scratch_access;
283
 
284
        sc_io_out.address <= sc_ctrl_mem_out.address;
285
        sc_io_out.wr_data <= sc_ctrl_mem_out.wr_data;
286
        sc_io_out.wr <= sc_ctrl_mem_out.wr and io_access;
287
        sc_io_out.rd <= sc_ctrl_mem_out.rd and io_access;
288
 
289
end rtl;

powered by: WebSVN 2.1.0

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