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 (63 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 |
|
|
component comp_eq_11ones is
|
41 |
|
|
port (
|
42 |
|
|
sclr : in STD_LOGIC := 'X';
|
43 |
|
|
qa_eq_b : out STD_LOGIC;
|
44 |
|
|
clk : in STD_LOGIC := 'X';
|
45 |
|
|
a : in STD_LOGIC_VECTOR ( 10 downto 0 )
|
46 |
|
|
);
|
47 |
|
|
end component;
|
48 |
|
|
|
49 |
|
|
component comp_eq_51zeros is
|
50 |
|
|
port (
|
51 |
|
|
sclr : in STD_LOGIC := 'X';
|
52 |
|
|
qa_eq_b : out STD_LOGIC;
|
53 |
|
|
clk : in STD_LOGIC := 'X';
|
54 |
|
|
a : in STD_LOGIC_VECTOR ( 50 downto 0 )
|
55 |
|
|
);
|
56 |
|
|
end component;
|
57 |
|
|
|
58 |
|
|
component reg_2b_1c is
|
59 |
|
|
port (
|
60 |
|
|
sclr : in STD_LOGIC := 'X';
|
61 |
|
|
clk : in STD_LOGIC := 'X';
|
62 |
|
|
d : in STD_LOGIC_VECTOR ( 1 downto 0 );
|
63 |
|
|
q : out STD_LOGIC_VECTOR ( 1 downto 0 )
|
64 |
|
|
);
|
65 |
|
|
end component;
|
66 |
|
|
|
67 |
|
|
component reg_3b_1c is
|
68 |
|
|
port (
|
69 |
|
|
sclr : in STD_LOGIC := 'X';
|
70 |
|
|
clk : in STD_LOGIC := 'X';
|
71 |
|
|
d : in STD_LOGIC_VECTOR ( 2 downto 0 );
|
72 |
|
|
q : out STD_LOGIC_VECTOR ( 2 downto 0 )
|
73 |
|
|
);
|
74 |
|
|
end component;
|
75 |
|
|
|
76 |
|
|
component reg_64b_1c is
|
77 |
|
|
port (
|
78 |
|
|
sclr : in STD_LOGIC := 'X';
|
79 |
|
|
clk : in STD_LOGIC := 'X';
|
80 |
|
|
d : in STD_LOGIC_VECTOR ( 63 downto 0 );
|
81 |
|
|
q : out STD_LOGIC_VECTOR ( 63 downto 0 )
|
82 |
|
|
);
|
83 |
|
|
end component;
|
84 |
|
|
|
85 |
|
|
component reg_1b_1c is
|
86 |
|
|
port (
|
87 |
|
|
sclr : in STD_LOGIC := 'X';
|
88 |
|
|
clk : in STD_LOGIC := 'X';
|
89 |
|
|
d : in STD_LOGIC_VECTOR ( 0 downto 0 );
|
90 |
|
|
q : out STD_LOGIC_VECTOR ( 0 downto 0 )
|
91 |
|
|
);
|
92 |
|
|
end component;
|
93 |
|
|
|
94 |
|
|
component comp_eq_000000000000 is
|
95 |
|
|
port (
|
96 |
|
|
sclr : in STD_LOGIC := 'X';
|
97 |
|
|
qa_eq_b : out STD_LOGIC;
|
98 |
|
|
clk : in STD_LOGIC := 'X';
|
99 |
|
|
a : in STD_LOGIC_VECTOR ( 11 downto 0 )
|
100 |
|
|
);
|
101 |
|
|
end component;
|
102 |
|
|
|
103 |
|
|
constant special_value_nan : std_logic_vector(63 downto 0) :="0111111111111000000000000000000000000000000000000000000000000000"; -- conditions for NAN : input nan or sign 1
|
104 |
|
|
constant special_value_minus_inf : std_logic_vector(63 downto 0) :="1111111111110000000000000000000000000000000000000000000000000000"; -- input zero
|
105 |
|
|
constant special_value_inf : std_logic_vector(63 downto 0) :="0111111111110000000000000000000000000000000000000000000000000000"; -- input inf
|
106 |
|
|
|
107 |
|
|
signal eq_11ones , eq_52zeros : std_logic;
|
108 |
|
|
|
109 |
|
|
signal inputMSBsYA,
|
110 |
|
|
match_check_sig ,
|
111 |
|
|
sp_case_0_NAN ,
|
112 |
|
|
sp_case_1_minus_INF ,
|
113 |
|
|
sp_case_2_INF ,
|
114 |
|
|
sp_case_NO : std_logic ;
|
115 |
|
|
|
116 |
|
|
signal sp_case_0_NAN_vec ,
|
117 |
|
|
sp_case_1_minus_INF_vec ,
|
118 |
|
|
sp_case_2_INF_vec ,
|
119 |
|
|
special_value_nan_checked ,
|
120 |
|
|
special_value_minus_inf_checked ,
|
121 |
|
|
special_value_inf_checked ,
|
122 |
|
|
special_value_checked : std_logic_vector(63 downto 0);
|
123 |
|
|
|
124 |
|
|
signal tmp_2bit_signal , tmp_2bit_signal_reg: std_logic_vector(1 downto 0);
|
125 |
|
|
signal tmp_3bit_signal , tmp_3bit_signal_reg: std_logic_vector(2 downto 0);
|
126 |
|
|
signal sp_case_NO_1b_vec , sp_case_NO_1b_vec_reg : std_logic_vector(0 downto 0);
|
127 |
|
|
|
128 |
|
|
signal output_special_val_tmp : std_logic_vector(63 downto 0);
|
129 |
|
|
|
130 |
|
|
begin
|
131 |
|
|
|
132 |
|
|
-- Check for Special Values
|
133 |
|
|
comp_eq_11ones_port_map : comp_eq_11ones port map (rst,eq_11ones,clk,input_val(62 downto 52));
|
134 |
|
|
comp_eq_51zeros_port_map : comp_eq_51zeros port map (rst,eq_52zeros,clk,input_val(50 downto 0));
|
135 |
|
|
|
136 |
|
|
match_check_sig <= eq_11ones and eq_52zeros;
|
137 |
|
|
|
138 |
|
|
-- Check for zero input
|
139 |
|
|
comp_eq_000000000000_inputs_MSBS : comp_eq_000000000000 port map (rst,inputMSBsYA,clk,input_val(62 downto 51));
|
140 |
|
|
|
141 |
|
|
--Register
|
142 |
|
|
|
143 |
|
|
tmp_2bit_signal(1)<=input_val(51);
|
144 |
|
|
tmp_2bit_signal(0)<=input_val(63);
|
145 |
|
|
reg_2b_1c_port_map: reg_2b_1c port map (rst,clk,tmp_2bit_signal,tmp_2bit_signal_reg);
|
146 |
|
|
|
147 |
|
|
--Check for the conditions
|
148 |
|
|
sp_case_0_NAN<= (match_check_sig and tmp_2bit_signal_reg(1)) or tmp_2bit_signal_reg(0);
|
149 |
|
|
sp_case_1_minus_INF<=eq_52zeros and inputMSBsYA;
|
150 |
|
|
sp_case_2_INF<= ((not tmp_2bit_signal_reg(0)) and match_check_sig and (not tmp_2bit_signal_reg(1)));
|
151 |
|
|
|
152 |
|
|
|
153 |
|
|
--Register for special case bits
|
154 |
|
|
tmp_3bit_signal(2)<=sp_case_0_NAN;
|
155 |
|
|
tmp_3bit_signal(1)<=sp_case_1_minus_INF;
|
156 |
|
|
tmp_3bit_signal(0)<=sp_case_2_INF;
|
157 |
|
|
reg_3b_1c_port_map: reg_3b_1c port map (rst,clk,tmp_3bit_signal,tmp_3bit_signal_reg);
|
158 |
|
|
|
159 |
|
|
|
160 |
|
|
-- Check Special case or not
|
161 |
|
|
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
|
162 |
|
|
|
163 |
|
|
|
164 |
|
|
|
165 |
|
|
-- Create special case output
|
166 |
|
|
sp_case_0_NAN_vec<=(others=>tmp_3bit_signal_reg(2));
|
167 |
|
|
sp_case_1_minus_INF_vec<=(others=>tmp_3bit_signal_reg(1));
|
168 |
|
|
sp_case_2_INF_vec<=(others=>tmp_3bit_signal_reg(0));
|
169 |
|
|
|
170 |
|
|
special_value_nan_checked<= special_value_nan and sp_case_0_NAN_vec;
|
171 |
|
|
special_value_minus_inf_checked<= special_value_minus_inf and sp_case_1_minus_INF_vec;
|
172 |
|
|
special_value_inf_checked<= special_value_inf and sp_case_2_INF_vec ;
|
173 |
|
|
|
174 |
|
|
special_value_checked<= special_value_nan_checked or special_value_minus_inf_checked or special_value_inf_checked ;
|
175 |
|
|
|
176 |
|
|
|
177 |
|
|
-- Registers
|
178 |
|
|
|
179 |
|
|
sp_case_NO_1b_vec(0)<=sp_case_NO;
|
180 |
|
|
reg_1b_1c_port_map: reg_1b_1c port map (rst,clk,sp_case_NO_1b_vec,sp_case_NO_1b_vec_reg);
|
181 |
|
|
reg_64b_1c_port_map: reg_64b_1c port map (rst,clk,special_value_checked,output_special_val_tmp);
|
182 |
|
|
|
183 |
|
|
special_val_sel<=sp_case_NO_1b_vec_reg(0);
|
184 |
|
|
|
185 |
|
|
output_special_val(31 downto 30)<=output_special_val_tmp(63 downto 62);
|
186 |
|
|
output_special_val(29 downto 23)<=output_special_val_tmp(58 downto 52);
|
187 |
|
|
output_special_val(22 downto 0)<=output_special_val_tmp(51 downto 29);
|
188 |
|
|
|
189 |
|
|
end Behavioral;
|
190 |
|
|
|