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/] [fetch.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
--      fetch.vhd
24
--
25
--      jop instrcution fetch and branch
26
--
27
--
28
--      resources on ACEX1K30-3
29
--
30
--              132 LCs, max ca. 50 MHz
31
--
32
--      todo:
33
--              5 stage pipeline (jtbl/rom)
34
--              relativ address for jp, br
35
--              load pc instead of addres mux befor rom!
36
--
37
--      2001-07-04      first version
38
--      2001-07-18      component pc_inc in own file for Xilinx
39
--      2001-10-24      added 2 delays for br address (address is now in br opcode!)
40
--      2001-10-28      ldjpc, stjpc
41
--      2001-10-31      stbc (write content of jbc)
42
--      2001-11-13      added jtbl (jtbl and rom in one pipline stage!)
43
--      2001-11-14      change jbc to 1024 bytes
44
--      2001-11-16      split to fetch and bcfetch
45
--      2001-12-06      ir from decode to rom, (one brdly removed)
46
--                              mux befor rom removed, unregistered jfetch conrols imput to
47
--                              pc, jpaddr unregistered!
48
--      2001-12-07      branch relativ
49
--      2001-12-08      use table for branch offsets
50
--      2001-12-08      instruction set changed to 8 bit, pc to 10 bits
51
--      2002-12-02      wait instruction for memory
52
--      2003-08-15      move bcfetch to core
53
--      2004-04-06      nxt and opd are in rom. rom address from jpc_mux and with
54
--                              positiv edge rdaddr. unregistered output in rom.
55
--      2004-10-08      moved bsy/pcwait from decode to fetch
56
--
57
--
58
 
59
 
60
library ieee;
61
use ieee.std_logic_1164.all;
62
use ieee.numeric_std.all;
63
 
64
entity fetch is
65
 
66
generic (
67
        pc_width        : integer;      -- address bits of internal instruction rom
68
        i_width         : integer       -- instruction width
69
);
70
port (
71
        clk, reset      : in std_logic;
72
 
73
        nxt, opd        : out std_logic;        -- jfetch and jopdfetch from table
74
 
75
        br                      : in std_logic;
76
        bsy                     : in std_logic;         -- direct from the memory module
77
        jpaddr          : in std_logic_vector(pc_width-1 downto 0);
78
 
79
        dout            : out std_logic_vector(i_width-1 downto 0)               -- internal instruction (rom)
80
);
81
end fetch;
82
 
83
architecture rtl of fetch is
84
 
85
--
86
--      rom component (use technology specific vhdl-file (arom/xrom))
87
--              or generic rom.vhd
88
--
89
--      rom registered address, unregisterd out
90
--
91
component rom is
92
generic (width : integer; addr_width : integer);
93
port (
94
        clk                     : in std_logic;
95
 
96
        address         : in std_logic_vector(pc_width-1 downto 0);
97
 
98
        q                       : out std_logic_vector(i_width+1 downto 0)
99
);
100
end component;
101
--
102
--      offsets for relativ branches.
103
--
104
component offtbl is
105
port (
106
        idx             : in std_logic_vector(4 downto 0);
107
        q               : out std_logic_vector(pc_width-1 downto 0)
108
);
109
end component;
110
 
111
        signal pc_mux           : std_logic_vector(pc_width-1 downto 0);
112
        signal pc_inc           : std_logic_vector(pc_width-1 downto 0);
113
        signal pc                       : std_logic_vector(pc_width-1 downto 0);
114
        signal brdly            : std_logic_vector(pc_width-1 downto 0);
115
 
116
        signal off                      : std_logic_vector(pc_width-1 downto 0);
117
 
118
        signal jfetch           : std_logic;            -- fetch next byte code as opcode
119
        signal jopdfetch        : std_logic;            -- fetch next byte code as operand
120
 
121
        signal rom_data         : std_logic_vector(i_width+1 downto 0);          -- output from ROM
122
        signal ir                       : std_logic_vector(i_width-1 downto 0);          -- instruction register
123
signal pcwait : std_logic;
124
 
125
begin
126
 
127
 
128
--
129
--      pc_mux is 1 during reset!
130
--              => first instruction from ROM gets NEVER executed.
131
--
132
        cmp_rom: rom generic map (i_width+2, pc_width) port map(clk, pc_mux, rom_data);
133
        jfetch <= rom_data(9);
134
        jopdfetch <= rom_data(8);
135
 
136
        cmp_off: offtbl port map(ir(4 downto 0), off);
137
 
138
        dout <= ir;
139
        nxt <= jfetch;
140
        opd <= jopdfetch;
141
 
142
process(clk)
143
begin
144
        if rising_edge(clk) then                                -- we don't need a reset
145
                ir <= rom_data(7 downto 0);                      -- better read (second) instruction from room
146
                pcwait <= '0';
147
                -- decode wait instruction from unregistered rom
148
                if (rom_data(7 downto 0)="10000001") then        -- wait instuction
149
                        pcwait <= '1';
150
                end if;
151
        end if;
152
end process;
153
 
154
process(clk, reset, pc, off)
155
 
156
begin
157
        if (reset='1') then
158
                pc <= std_logic_vector(to_unsigned(0, pc_width));
159
                brdly <= std_logic_vector(to_unsigned(0, pc_width));
160
        elsif rising_edge(clk) then
161
                brdly <= std_logic_vector(unsigned(pc) + unsigned(off));
162
                pc <= pc_mux;
163
        end if;
164
end process;
165
 
166
        -- bsy is too late to register pcwait and bsy
167
        pc_inc <= std_logic_vector(to_unsigned(0, pc_width-1)) & not (pcwait and bsy);
168
 
169
process(jfetch, br, jpaddr, brdly, pc, pc_inc)
170
begin
171
        if (jfetch='1') then
172
                pc_mux <= jpaddr;
173
        else
174
                if (br='1') then
175
                        pc_mux <= brdly;
176
                else
177
                        pc_mux <= std_logic_vector(unsigned(pc) + unsigned(pc_inc));
178
                end if;
179
        end if;
180
end process;
181
 
182
end rtl;
183
 

powered by: WebSVN 2.1.0

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