⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fpu_exceptions.vhd

📁 This file is floating point exceptions vhdl program
💻 VHD
📖 第 1 页 / 共 2 页
字号:
			else				opa_neg_inf <= '0';			end if;			if opb(62 downto 52) = "11111111111" and or_reduce(opb(51 downto 0)) = '0' and					opb(63) = '1' then				opb_neg_inf <= '1';			else				opb_neg_inf <= '0';			end if;			if opa(62 downto 52) = "11111111111" and or_reduce(opa(51 downto 0)) = '0' then				opa_inf <= '1';			else				opa_inf <= '0';			end if;			if opb(62 downto 52) = "11111111111" and or_reduce(opb(51 downto 0)) = '0' then				opb_inf <= '1';			else				opb_inf <= '0';			end if;			if opa_QNaN = '1' or opb_QNaN = '1' or opa_SNaN = '1' or opb_SNaN = '1' then				NaN_input <= '1';			else				NaN_input <= '0';			end if;			if opa_SNaN = '1' or opb_SNaN = '1' then				SNaN_input <= '1';			else				SNaN_input <= '0';			end if;			if opa_SNaN = '1' or opa_QNaN = '1' then				a_NaN <= '1';			else				a_NaN <= '0';			end if;			if divide = '1' and opb_et_zero = '1' and opa_et_zero = '0' then				div_by_0 <= '1';			else				div_by_0 <= '0';			end if;			if divide = '1' and opb_et_zero = '1' and opa_et_zero = '1' then				div_0_by_0 <= '1';			else				div_0_by_0 <= '0';			end if;			if divide = '1' and opa_inf = '1' and opb_inf = '1' then				div_inf_by_inf <= '1';			else				div_inf_by_inf <= '0';			end if;			if divide = '1' and opa_inf = '0' and opb_inf = '1' then				div_by_inf <= '1';			else				div_by_inf <= '0';			end if;			if multiply = '1' and ((opa_inf = '1' and opb_et_zero = '1') or			 (opa_et_zero = '1' and opb_inf = '1')) then				mul_0_by_inf <= '1';			else				mul_0_by_inf <= '0';			end if;			if multiply = '1' and (opa_inf = '1' or opb_inf = '1') and			  mul_0_by_inf = '0' then				mul_inf <= '1';			else				mul_inf <= '0';			end if;			if divide = '1' and opa_inf = '1' and opb_inf = '0' then				div_inf <= '1';			else				div_inf <= '0';			end if;			if add = '1' and (opa_inf = '1' or opb_inf = '1') then				add_inf <= '1';			else				add_inf <= '0';			end if;			if subtract = '1' and (opa_inf = '1' or opb_inf = '1') then				sub_inf <= '1';			else				sub_inf <= '0';			end if;			if (add = '1' and opa_pos_inf = '1' and opb_neg_inf = '1') or			  (add = '1' and opa_neg_inf = '1' and opb_pos_inf = '1') or			  (subtract = '1' and opa_pos_inf = '1' and opb_pos_inf = '1') or			  (subtract = '1' and opa_neg_inf = '1' and opb_neg_inf = '1') then				addsub_inf_invalid <= '1';			else				addsub_inf_invalid <= '0';			end if;			if (add_inf = '1' or sub_inf = '1') and addsub_inf_invalid = '0' then				addsub_inf <= '1';			else				addsub_inf <= '0';			end if;			if addsub_inf = '1' or mul_inf = '1' or div_inf = '1' or div_by_0 = '1' 			  or (exponent_in > "011111111110") then -- 2046				out_inf_trigger <= '1';			else				out_inf_trigger <= '0';				end if;			if out_inf_trigger = '1' and in_except(63) = '0' then				out_pos_inf <= '1';			else				out_pos_inf <= '0';				end if;			if out_inf_trigger = '1' and in_except(63) = '1' then				out_neg_inf <= '1';			else				out_neg_inf <= '0';				end if;			if rmode = "00" then				round_nearest <= '1';			else				round_nearest <= '0';			end if;			if rmode = "01" then				round_to_zero <= '1';			else				round_to_zero <= '0';			end if;			if rmode = "10" then				round_to_pos_inf <= '1';			else				round_to_pos_inf <= '0';			end if;			if rmode = "11" then				round_to_neg_inf <= '1';			else				round_to_neg_inf <= '0';			end if;			if (out_pos_inf = '1' and round_to_neg_inf = '1') or			   (out_neg_inf = '1' and round_to_pos_inf = '1') or			   (out_inf_trigger = '1' and round_to_zero = '1') then				inf_round_down_trigger <= '1';			else				inf_round_down_trigger <= '0';			end if;			if multiply = '1' and opa_et_zero = '0' and opb_et_zero = '0' and 			  in_et_zero = '1' then				mul_uf <= '1';			else				mul_uf <= '0';			end if;			if divide = '1' and opa_et_zero = '0' and in_et_zero = '1' then				div_uf <= '1';			else				div_uf <= '0';			end if;			if div_by_inf = '1' or mul_uf = '1' or div_uf = '1' then				underflow_trigger <= '1';			else				underflow_trigger <= '0';			end if;			if SNaN_input = '1' or addsub_inf_invalid = '1' or mul_0_by_inf = '1' or				div_0_by_0 = '1' or div_inf_by_inf = '1' then				invalid_trigger <= '1';			else				invalid_trigger <= '0';			end if;																		if div_by_inf = '1' or mul_uf = '1' or div_uf = '1' then				underflow_trigger <= '1';			else				underflow_trigger <= '0';			end if;									if out_inf_trigger = '1' and NaN_input = '0' then				overflow_trigger <= '1';			else				overflow_trigger <= '0';			end if;				if (or_reduce(mantissa_in(1 downto 0)) = '1' or out_inf_trigger = '1' or 			  underflow_trigger = '1') and NaN_input = '0' then				inexact_trigger <= '1';			else				inexact_trigger <= '0';			end if;				if (invalid_trigger = '1' or overflow_trigger = '1' or 			  underflow_trigger = '1' or inexact_trigger = '1') then				except_trigger <= '1';			else				except_trigger <= '0';			end if;				if (invalid_trigger = '1' or overflow_trigger = '1' or 			  underflow_trigger = '1' or inexact_trigger = '1') then				except_trigger <= '1';			else				except_trigger <= '0';			end if;				if (except_trigger = '1' or out_inf_trigger = '1' or 			  NaN_input = '1') then				enable_trigger <= '1';			else				enable_trigger <= '0';			end if;				if (NaN_input = '1' or invalid_trigger = '1') then				NaN_out_trigger <= '1';			else				NaN_out_trigger <= '0';			end if;				if (invalid_trigger = '1' and SNaN_input = '0') then				SNaN_trigger <= '1';			else				SNaN_trigger <= '0';			end if;				if a_NaN = '1' then				NaN_output_0 <= exp_2047 & '1' & opa(50 downto 0);			else				NaN_output_0 <= exp_2047 & '1' & opb(50 downto 0);			end if;				if SNaN_trigger = '1' then				NaN_output <= exp_2047 & "01" & opa(49 downto 0);			else				NaN_output <= NaN_output_0;			end if;				inf_round_down <= exp_2046 & mantissa_max;			if inf_round_down_trigger = '1' then				out_inf <= inf_round_down;			else				out_inf <=  exp_2047 & "0000000000000000000000000000000000000000000000000000";			end if;			if underflow_trigger = '1' then				out_0 <= in_except(63) & "000000000000000000000000000000000000000000000000000000000000000";			else				out_0 <=  in_except;			end if;			if out_inf_trigger = '1' then				out_1 <= in_except(63) & out_inf;			else				out_1 <= out_0;			end if;			if NaN_out_trigger = '1' then				out_2 <= in_except(63) & NaN_output;			else				out_2 <= out_1;			end if;		end if;	end process;	process	begin	wait until clk'event and clk = '1';		if (rst = '1') then			ex_enable <= '0';			underflow <= '0';			overflow <= '0';	   			inexact <= '0';			exception <= '0';			invalid <= '0';			out_fp <= (others =>'0');		elsif (enable = '1') then			ex_enable <= enable_trigger;			underflow <= underflow_trigger;			overflow <= overflow_trigger;	   			inexact <= inexact_trigger;			exception <= except_trigger;			invalid <= invalid_trigger;			out_fp <= out_2;		end if;	end process;	end rtl;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -