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

Subversion Repositories fp_log

[/] [fp_log/] [trunk/] [LAU/] [Virtex 4/] [SP-LAU/] [special_case_detector.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 NikosAl
----------------------------------------------------------------------------------
2
-- Company: TUM - Technischen Universität München
3
-- Engineer: N.Alachiotis
4
-- 
5
-- Create Date:    11:08:46 06/24/2009 
6
-- Design Name: 
7
-- Module Name:    special_case_detector - Behavioral 
8
-- Project Name: 
9
-- Target Devices: 
10
-- Tool versions: 
11
-- Description: 
12
--
13
-- Dependencies: 
14
--
15
-- Revision: 
16
-- Revision 0.01 - File Created
17
-- Additional Comments: 
18
--
19
----------------------------------------------------------------------------------
20
library IEEE;
21
use IEEE.STD_LOGIC_1164.ALL;
22
use IEEE.STD_LOGIC_ARITH.ALL;
23
use IEEE.STD_LOGIC_UNSIGNED.ALL;
24
 
25
---- Uncomment the following library declaration if instantiating
26
---- any Xilinx primitives in this code.
27
--library UNISIM;
28
--use UNISIM.VComponents.all;
29
 
30
entity special_case_detector is
31
    Port ( rst : in  STD_LOGIC;
32
           clk : in  STD_LOGIC;
33
           input_val : in  STD_LOGIC_VECTOR (31 downto 0);
34
                          special_val_sel : out STD_LOGIC;
35
                          output_special_val : out STD_LOGIC_VECTOR(31 downto 0));
36
end special_case_detector;
37
 
38
architecture Behavioral of special_case_detector is
39
 
40
 
41
component comp_eq_8ones is
42
  port (
43
    sclr : in STD_LOGIC := 'X';
44
    qa_eq_b : out STD_LOGIC;
45
    clk : in STD_LOGIC := 'X';
46
    a : in STD_LOGIC_VECTOR ( 7 downto 0 )
47
  );
48
end component;
49
 
50
component comp_eq_22zeros is
51
  port (
52
    sclr : in STD_LOGIC := 'X';
53
    qa_eq_b : out STD_LOGIC;
54
    clk : in STD_LOGIC := 'X';
55
    a : in STD_LOGIC_VECTOR ( 21 downto 0 )
56
  );
57
end component;
58
 
59
component reg_2b_1c is
60
  port (
61
    sclr : in STD_LOGIC := 'X';
62
    clk : in STD_LOGIC := 'X';
63
    d : in STD_LOGIC_VECTOR ( 1 downto 0 );
64
    q : out STD_LOGIC_VECTOR ( 1 downto 0 )
65
  );
66
end component;
67
 
68
component reg_3b_1c is
69
  port (
70
    sclr : in STD_LOGIC := 'X';
71
    clk : in STD_LOGIC := 'X';
72
    d : in STD_LOGIC_VECTOR ( 2 downto 0 );
73
    q : out STD_LOGIC_VECTOR ( 2 downto 0 )
74
  );
75
end component;
76
 
77
component reg_32b_1c is
78
  port (
79
    sclr : in STD_LOGIC := 'X';
80
    clk : in STD_LOGIC := 'X';
81
    d : in STD_LOGIC_VECTOR ( 31 downto 0 );
82
    q : out STD_LOGIC_VECTOR ( 31 downto 0 )
83
  );
84
end component;
85
 
86
component reg_1b_1c is
87
  port (
88
    sclr : in STD_LOGIC := 'X';
89
    clk : in STD_LOGIC := 'X';
90
    d : in STD_LOGIC_VECTOR ( 0 downto 0 );
91
    q : out STD_LOGIC_VECTOR ( 0 downto 0 )
92
  );
93
end component;
94
 
95
component comp_eq_000000000 is
96
  port (
97
    sclr : in STD_LOGIC := 'X';
98
    qa_eq_b : out STD_LOGIC;
99
    clk : in STD_LOGIC := 'X';
100
    a : in STD_LOGIC_VECTOR ( 8 downto 0 )
101
  );
102
end component;
103
 
104
constant special_value_nan              : std_logic_vector(31 downto 0) :="01111111110000000000000000000000";  -- conditions for NAN : input nan or sign 1
105
constant special_value_minus_inf : std_logic_vector(31 downto 0) :="11111111100000000000000000000000";  -- input zero
106
constant special_value_inf                      : std_logic_vector(31 downto 0) :="01111111100000000000000000000000";  -- input inf
107
 
108
signal eq_8ones , eq_23zeros : std_logic;
109
 
110
signal inputMSBsYA,
111
                 match_check_sig                ,
112
                 sp_case_0_NAN          ,
113
                 sp_case_1_minus_INF    ,
114
                 sp_case_2_INF                  ,
115
                 sp_case_NO                             : std_logic ;
116
 
117
signal sp_case_0_NAN_vec                                        ,
118
                 sp_case_1_minus_INF_vec                        ,
119
                 sp_case_2_INF_vec                                      ,
120
                 special_value_nan_checked              ,
121
                 special_value_minus_inf_checked        ,
122
                 special_value_inf_checked              ,
123
                 special_value_checked                          : std_logic_vector(31 downto 0);
124
 
125
signal tmp_2bit_signal , tmp_2bit_signal_reg: std_logic_vector(1 downto 0);
126
signal tmp_3bit_signal , tmp_3bit_signal_reg: std_logic_vector(2 downto 0);
127
signal sp_case_NO_1b_vec , sp_case_NO_1b_vec_reg : std_logic_vector(0 downto 0);
128
 
129
signal output_special_val_tmp : std_logic_vector(31 downto 0);
130
 
131
begin
132
 
133
-- Check for Special Values
134
comp_eq_8ones_port_map : comp_eq_8ones port map (rst,eq_8ones,clk,input_val(30 downto 23));
135
comp_eq_23zeros_port_map : comp_eq_22zeros port map (rst,eq_23zeros,clk,input_val(21 downto 0));
136
 
137
match_check_sig <= eq_8ones and eq_23zeros;
138
 
139
-- Check for zero input
140
comp_eq_000000000_inputs_MSBS : comp_eq_000000000 port map (rst,inputMSBsYA,clk,input_val(30 downto 22));
141
 
142
--Register 
143
 
144
tmp_2bit_signal(1)<=input_val(22);
145
tmp_2bit_signal(0)<=input_val(31);
146
reg_2b_1c_port_map: reg_2b_1c port map (rst,clk,tmp_2bit_signal,tmp_2bit_signal_reg);
147
 
148
--Check for the conditions
149
sp_case_0_NAN<= (match_check_sig and tmp_2bit_signal_reg(1)) or tmp_2bit_signal_reg(0);
150
sp_case_1_minus_INF<=eq_23zeros and inputMSBsYA;
151
sp_case_2_INF<= ((not tmp_2bit_signal_reg(0)) and match_check_sig and (not tmp_2bit_signal_reg(1)));
152
 
153
 
154
--Register for special case bits
155
tmp_3bit_signal(2)<=sp_case_0_NAN;
156
tmp_3bit_signal(1)<=sp_case_1_minus_INF;
157
tmp_3bit_signal(0)<=sp_case_2_INF;
158
reg_3b_1c_port_map: reg_3b_1c port map (rst,clk,tmp_3bit_signal,tmp_3bit_signal_reg);
159
 
160
 
161
-- Check Special case or not
162
sp_case_NO<=(tmp_3bit_signal_reg(2) or tmp_3bit_signal_reg(1) or tmp_3bit_signal_reg(0)); -- This is special case YES
163
 
164
 
165
 
166
-- Create special case output
167
sp_case_0_NAN_vec<=(others=>tmp_3bit_signal_reg(2));
168
sp_case_1_minus_INF_vec<=(others=>tmp_3bit_signal_reg(1));
169
sp_case_2_INF_vec<=(others=>tmp_3bit_signal_reg(0));
170
 
171
special_value_nan_checked<= special_value_nan and sp_case_0_NAN_vec;
172
special_value_minus_inf_checked<= special_value_minus_inf and sp_case_1_minus_INF_vec;
173
special_value_inf_checked<= special_value_inf and sp_case_2_INF_vec ;
174
 
175
special_value_checked<= special_value_nan_checked or special_value_minus_inf_checked or special_value_inf_checked ;
176
 
177
 
178
-- Registers 
179
 
180
sp_case_NO_1b_vec(0)<=sp_case_NO;
181
reg_1b_1c_port_map: reg_1b_1c port map (rst,clk,sp_case_NO_1b_vec,sp_case_NO_1b_vec_reg);
182
reg_32b_1c_port_map: reg_32b_1c port map (rst,clk,special_value_checked,output_special_val_tmp);
183
 
184
special_val_sel<=sp_case_NO_1b_vec_reg(0);
185
 
186
 
187
output_special_val<=output_special_val_tmp;
188
 
189
 
190
end Behavioral;
191
 

powered by: WebSVN 2.1.0

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