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

Subversion Repositories simpcon

[/] [simpcon/] [trunk/] [vhdl/] [sc_fpu.vhd] - Blame information for rev 29

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 29 martin
--
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 18 martin
-- This is the SimpCon interface to the FPU
23
--
24
 
25
Library IEEE;
26
use IEEE.std_logic_1164.all;
27
use ieee.std_logic_unsigned.all;
28
use ieee.numeric_std.all;
29
 
30
entity sc_fpu is
31
generic (ADDR_WIDTH : integer);
32
 
33
port (
34
        clk_i           : in std_logic;
35
        reset_i : in std_logic;
36
 
37
-- SimpCon interface
38
 
39
        address_i               : in std_logic_vector(ADDR_WIDTH-1 downto 0);
40
        wr_data_i               : in std_logic_vector(31 downto 0);
41
        rd_i, wr_i              : in std_logic;
42
        rd_data_o               : out std_logic_vector(31 downto 0);
43
        rdy_cnt_o               : out unsigned(1 downto 0)
44
 
45
);
46
end sc_fpu;
47
 
48
architecture rtl of sc_fpu is
49
 
50
        component fpu
51
            port (
52
                clk_i           : in std_logic;
53
                opa_i           : in std_logic_vector(31 downto 0);
54
                opb_i           : in std_logic_vector(31 downto 0);
55
                fpu_op_i                : in std_logic_vector(2 downto 0);
56
                rmode_i                 : in std_logic_vector(1 downto 0);
57
 
58
                output_o        : out std_logic_vector(31 downto 0);
59
                        ine_o                   : out std_logic;
60
                overflow_o      : out std_logic;
61
                underflow_o     : out std_logic;
62
                div_zero_o      : out std_logic;
63
                inf_o                   : out std_logic;
64
                zero_o                  : out std_logic;
65
                qnan_o                  : out std_logic;
66
                snan_o                  : out std_logic;
67
 
68
                start_i                 : in  std_logic;
69
                ready_o                 : out std_logic
70
                );
71
        end component;
72
 
73
        signal opa_i, opb_i : std_logic_vector(31 downto 0);
74
        signal fpu_op_i         : std_logic_vector(2 downto 0);
75
        signal rmode_i : std_logic_vector(1 downto 0);
76
        signal output_o : std_logic_vector(31 downto 0);
77
        signal start_i, ready_o : std_logic ;
78
        --signal ine_o, overflow_o, underflow_o, div_zero_o, inf_o, zero_o, qnan_o, snan_o: std_logic;
79
 
80
begin
81
 
82
 
83
    -- instantiate the fpu
84
    i_fpu: fpu port map (
85
                        clk_i => clk_i,
86
                        opa_i => opa_i,
87
                        opb_i => opb_i,
88
                        fpu_op_i =>     fpu_op_i,
89
                        rmode_i => rmode_i,
90
                        output_o => output_o,
91
                        ine_o => open,
92
                        overflow_o => open,
93
                        underflow_o => open,
94
                div_zero_o => open,
95
                inf_o => open,
96
                zero_o => open,
97
                qnan_o => open,
98
                snan_o => open,
99
                start_i => start_i,
100
                ready_o => ready_o);
101
 
102
rmode_i <= "00"; -- default rounding mode= round-to-nearest-even 
103
 
104
-- master reads from FPU
105
process(clk_i, reset_i)
106
begin
107
 
108
        if (reset_i='1') then
109 20 martin
--              start_i <= '0';
110 18 martin
        elsif rising_edge(clk_i) then
111
 
112 20 martin
--              if rd_i='1' then
113
--                      -- that's our very simple address decoder
114
--                      if address_i="0011" then
115
--                              start_i <= '1';
116
--                      end if;
117
--              else
118
--                      start_i <= '0';
119
--              end if;
120 18 martin
        end if;
121
 
122
end process;
123
 
124
-- set rdy_cnt
125
process(clk_i)
126
begin
127
        if (reset_i='1') then
128
                rdy_cnt_o <= "11";
129
        elsif rising_edge(clk_i) then
130
                if start_i='1' then
131
                        rdy_cnt_o <= "11";
132
                elsif ready_o = '1' then
133
                        rdy_cnt_o <= "00";
134
                        rd_data_o <= output_o;
135
                end if;
136
        end if;
137
end process;
138
 
139
 
140
-- master writes to FPU
141
process(clk_i, reset_i)
142
 
143
begin
144
 
145
        if (reset_i='1') then
146
                opa_i <= (others => '0');
147
                opb_i <= (others => '0');
148
                fpu_op_i <= (others => '0');
149 20 martin
                start_i <= '0';
150 18 martin
        elsif rising_edge(clk_i) then
151 20 martin
                start_i <= '0';
152 18 martin
 
153
                if wr_i='1' then
154
                        if address_i="0000" then
155
                                        opa_i <= wr_data_i;
156
                        elsif address_i="0001" then
157
                                        opb_i <= wr_data_i;
158
                        elsif address_i="0010" then
159
                                        fpu_op_i <=wr_data_i(2 downto 0);
160 20 martin
                                        start_i <= '1';
161 18 martin
                        end if;
162
                end if;
163
 
164
        end if;
165
 
166
end process;
167
 
168
 
169
end rtl;

powered by: WebSVN 2.1.0

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