-- Test vectors for the fixed point math package, part 2 -- This is a test for the fixed point math packages. -- Created for vhdl-200x by David Bishop (dbishop@vhdl.org) -- -------------------------------------------------------------------- -- modification history : Last Modified $Date: 2007-06-19 10:13:04-04 $ -- Version $Id: test_fixed2.vhdl,v 1.5 2007-06-19 10:13:04-04 l435385 Exp $ -- -------------------------------------------------------------------- entity test_fixed2 is generic ( quiet : BOOLEAN := false); -- make the simulation quiet end entity test_fixed2; use std.textio.all; library ieee; use ieee.math_real.all; use ieee.std_logic_1164.all; use ieee.numeric_std.all; use ieee.math_utility_pkg.all; use ieee.fixed_pkg.all; architecture testbench of test_fixed2 is constant iterations : NATURAL := 10000; -- used in random number test constant debug : BOOLEAN := false; -- debug mode, prints out lots of data -- purpose: reports an error procedure report_error ( constant errmes : in STRING; -- error message actual : in ufixed; -- data from algorithm constant expected : in ufixed) is -- reference data variable L : LINE; begin -- function report_error assert actual = expected report errmes & LF & "Actual: " & to_string(actual) & " (" & REAL'image(to_real(actual)) & ")" & LF & " /= " & to_string(expected) & " (" & REAL'image(to_real(expected)) & ")" severity error; return; end procedure report_error; procedure report_error ( constant errmes : STRING; -- error message actual : in sfixed; -- data from algorithm constant expected : sfixed) is -- reference data variable L : LINE; begin -- function report_error assert actual = expected report errmes & LF & "Actual: " & to_string(actual) & " (" & REAL'image(to_real(actual)) & ")" & LF & " /= " & to_string(expected) & " (" & REAL'image(to_real(expected)) & ")" severity error; return; end procedure report_error; procedure report_error ( constant errmes : STRING; -- error message actual : in STD_LOGIC_VECTOR; -- data from algorithm constant expected : STD_LOGIC_VECTOR) is -- reference data variable L : LINE; begin -- function report_error assert actual = expected report errmes & LF & "Actual: " & to_string(to_ufixed(actual, actual'length-1, 0)) & LF & " /= " & to_string(to_sfixed(expected, expected'length-1, 0)) severity error; return; end procedure report_error; subtype ufixed7_3 is ufixed (3 downto -3); -- 7 bit subtype ufixed16_8 is ufixed (7 downto -8); -- 16 bit subtype ufixed17_8 is ufixed (8 downto -8); -- 17 bit subtype sfixed7_3 is sfixed (3 downto -3); -- 7 bit subtype sfixed8_3 is sfixed (4 downto -3); -- 8 bit subtype sfixed16_8 is sfixed (7 downto -8); -- 16 bit signal start_nullrangetest, nullrangetest_done : BOOLEAN := false; -- start reading test signal start_saturatetest, saturatetest_done : BOOLEAN := false; signal start_ssaturatetest, ssaturatetest_done : BOOLEAN := false; -- signed signal start_fromstrtest, fromstrtest_done : BOOLEAN := false; -- from_string signal start_randomtest, randomtest_done : BOOLEAN := false; signal start_randomstest, randomstest_done : BOOLEAN := false; signal start_accumtest, accumtest_done : BOOLEAN := false; -- accumulator test signal start_overloadtest, overloadtest_done : BOOLEAN := false; -- overload test signal start_divmodtest, divmodtest_done : BOOLEAN := false; -- div and mod signal start_reduce_test, reduce_test_done : BOOLEAN := false; -- reduce signal start_booltest, booltest_done : BOOLEAN := false; -- boolean -- functions signal start_vecbool, vecbool_done : BOOLEAN := false; -- vector booleans signal start_matchtest, matchtest_done : BOOLEAN := false; -- vector booleans begin -- architecture testbench -- purpose: Main test process tester : process is begin -- process tester --------------------------------------------------------------------------- -- Saturation and rounding test --------------------------------------------------------------------------- start_saturatetest <= true; -- unsigned number test wait until saturatetest_done; start_ssaturatetest <= true; -- signed number test wait until ssaturatetest_done; --------------------------------------------------------------------------- -- Overloaded function test --------------------------------------------------------------------------- start_overloadtest <= true; wait until overloadtest_done; start_reduce_test <= true; wait until reduce_test_done; start_booltest <= true; wait until booltest_done; start_vecbool <= true; wait until vecbool_done; start_matchtest <= true; wait until matchtest_done; --------------------------------------------------------------------------- -- From_string test --------------------------------------------------------------------------- start_fromstrtest <= true; wait until fromstrtest_done; --------------------------------------------------------------------------- -- Div and mod test --------------------------------------------------------------------------- start_divmodtest <= true; wait until divmodtest_done; --------------------------------------------------------------------------- -- Accumulator test --------------------------------------------------------------------------- start_accumtest <= true; wait until accumtest_done; --------------------------------------------------------------------------- -- Null range test --------------------------------------------------------------------------- start_nullrangetest <= true; wait until nullrangetest_done; --------------------------------------------------------------------------- -- Random number test --------------------------------------------------------------------------- start_randomtest <= true; wait until randomtest_done; start_randomstest <= true; wait until randomstest_done; report "Fixed point package testing part 2 complete"; wait; end process tester; -- purpose: test the saturation and rounding -- type : combinational -- inputs : -- outputs: saturatetest : process is variable check7uf1, check7uf2, check7uf3 : ufixed7_3; variable check3uf1, check3uf2 : ufixed (4 downto 2); -- odd range variable checkint : INTEGER; variable checkreal : REAL; variable checkuns : UNSIGNED (5 downto 0); variable check7sf1, check7sf2, check7sf3 : sfixed7_3; begin -- process saturatetest wait until start_saturatetest; check3uf1 := "001"; -- 4 check7uf1 := resize (arg => check3uf1, left_index => check7uf1'high, right_index => check7uf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check7uf2 := "0100000"; -- 4 report_error ("resize 4 dt 2 to 3 dt -3 error", check7uf1, check7uf2); check3uf1 := "101"; -- 20 check7uf1 := resize (arg => check3uf1, left_index => check7uf1'high, right_index => check7uf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check7uf2 := (others => '1'); -- saturation report_error ("resize 4 dt 2 to 3 dt -3 sat error", check7uf1, check7uf2); check3uf1 := "101"; -- 20 check7uf1 := resize (arg => check3uf1, left_index => check7uf1'high, right_index => check7uf1'low, round_style => fixed_truncate, overflow_style => fixed_wrap); -- wrap check7uf2 := "0100000"; -- 4 report_error ("resize 4 dt 2 to 3 dt -3 wrap error", check7uf1, check7uf2); check7uf1 := resize (arg => to_ufixed (7.96875, 3, -5), -- "0111.11111" left_index => check7uf1'high, right_index => check7uf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check7uf2 := "0111111"; -- 7.875 report_error ("resize to 3 dt -3 no round error", check7uf1, check7uf2); check7uf1 := resize (arg => to_ufixed (7.96875, 3, -5), -- "0111.11111" left_index => check7uf1'high, right_index => check7uf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check7uf2 := "1000000"; -- 8 report_error ("resize to 3 dt -3 wrap round error", check7uf1, check7uf2); check7uf1 := resize (arg => to_ufixed (15.96875, 3, -5), -- "1111.11111" left_index => check7uf1'high, right_index => check7uf1'low, round_style => fixed_round, overflow_style => fixed_wrap); -- wrap check7uf2 := (others => '0'); -- 0 report_error ("resize to 3 dt -3 wrap round error", check7uf1, check7uf2); check7uf1 := resize (arg => to_ufixed (15.96875, 3, -5), -- "1111.11111" left_index => check7uf1'high, right_index => check7uf1'low, round_style => fixed_truncate, overflow_style => fixed_wrap); -- wrap check7uf2 := "1111111"; -- 15.875 report_error ("resize to 3 dt -3 wrap no round error", check7uf1, check7uf2); -- integer to ufixed if (not quiet) then checkint := 17; report "Expect to_ufixed(integer) overflow error" severity note; check7uf1 := to_ufixed (arg => checkint, left_index => check7uf1'high, right_index => check7uf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check7uf2 := (others => '1'); report_error ("to_ufixed 17 failed to saturate", check7uf1, check7uf2); checkint := 17; report "Expect to_ufixed(integer) overflow error" severity note; check7uf1 := to_ufixed (arg => checkint, left_index => check7uf1'high, right_index => check7uf1'low, round_style => fixed_truncate, overflow_style => fixed_wrap); -- wrap check7uf2 := "0001000"; -- 1 report_error ("to_ufixed 17 failed to wrap", check7uf1, check7uf2); end if; checkint := 5; check3uf1 := to_ufixed (arg => checkint, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3uf2 := "001"; report_error ("to_ufixed 5 not round_test", check3uf1, check3uf2); checkint := 5; check3uf1 := to_ufixed (arg => checkint, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3uf2 := "001"; report_error ("to_ufixed 5 round_test", check3uf1, check3uf2); checkint := 7; check3uf1 := to_ufixed (arg => checkint, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3uf2 := "001"; report_error ("to_ufixed 7 not round_test", check3uf1, check3uf2); checkint := 7; check3uf1 := to_ufixed (arg => checkint, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3uf2 := "010"; report_error ("to_ufixed 7 round_test", check3uf1, check3uf2); checkint := 17; check3uf1 := to_ufixed (arg => checkint, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3uf2 := "100"; report_error ("to_ufixed 17 not round_test", check3uf1, check3uf2); checkint := 17; check3uf1 := to_ufixed (arg => checkint, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3uf2 := "100"; report_error ("to_ufixed 17 round_test", check3uf1, check3uf2); checkint := 19; check3uf1 := to_ufixed (arg => checkint, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3uf2 := "100"; report_error ("to_ufixed 19 not round_test", check3uf1, check3uf2); checkint := 19; check3uf1 := to_ufixed (arg => checkint, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3uf2 := "101"; report_error ("to_ufixed 19 round_test", check3uf1, check3uf2); checkint := 24; check3uf1 := to_ufixed (arg => checkint, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3uf2 := "110"; report_error ("to_ufixed 24 not round_test", check3uf1, check3uf2); checkint := 24; check3uf1 := to_ufixed (arg => checkint, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3uf2 := "110"; report_error ("to_ufixed 24 round_test", check3uf1, check3uf2); checkint := 27; check3uf1 := to_ufixed (arg => checkint, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3uf2 := "110"; report_error ("to_ufixed 27 not round_test", check3uf1, check3uf2); checkint := 27; check3uf1 := to_ufixed (arg => checkint, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3uf2 := "111"; report_error ("to_ufixed 27 round_test", check3uf1, check3uf2); checkint := 31; check3uf1 := to_ufixed (arg => checkint, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3uf2 := "111"; report_error ("to_ufixed 31 not round_test", check3uf1, check3uf2); checkint := 31; check3uf1 := to_ufixed (arg => checkint, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3uf2 := "111"; report_error ("to_ufixed 31 round_test", check3uf1, check3uf2); checkint := 31; check3uf1 := to_ufixed (arg => checkint, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_truncate, overflow_style => fixed_wrap); -- wrap check3uf2 := "111"; report_error ("to_ufixed 31 wrap not round_test", check3uf1, check3uf2); checkint := 31; check3uf1 := to_ufixed (arg => checkint, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_round, overflow_style => fixed_wrap); -- saturate check3uf2 := "000"; report_error ("to_ufixed 31 wrap round_test", check3uf1, check3uf2); if (not quiet) then checkint := 35; report "Expect to_ufixed(integer) overflow error" severity note; check3uf1 := to_ufixed (arg => checkint, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3uf2 := "111"; report_error ("to_ufixed 35 not round_test", check3uf1, check3uf2); checkint := 35; report "Expect to_ufixed(integer) overflow error" severity note; check3uf1 := to_ufixed (arg => checkint, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3uf2 := "111"; report_error ("to_ufixed 35 round_test", check3uf1, check3uf2); checkint := 35; report "Expect to_ufixed(integer) overflow error" severity note; check3uf1 := to_ufixed (arg => checkint, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_truncate, overflow_style => fixed_wrap); -- saturate check3uf2 := "000"; report_error ("to_ufixed 35 wrap not round_test", check3uf1, check3uf2); checkint := 35; report "Expect to_ufixed(integer) overflow error" severity note; check3uf1 := to_ufixed (arg => checkint, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_round, overflow_style => fixed_wrap); -- saturate check3uf2 := "001"; report_error ("to_ufixed 35 wrap round_test", check3uf1, check3uf2); end if; -- real number unsigned fixed if (not quiet) then checkreal := 17.0; report "Expect to_ufixed(real) overflow error" severity note; check7uf1 := to_ufixed (arg => checkreal, left_index => check7uf1'high, right_index => check7uf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check7uf2 := (others => '1'); report_error ("to_ufixed 17.0 failed to saturate", check7uf1, check7uf2); checkreal := 17.0; report "Expect to_ufixed(real) overflow error" severity note; check7uf1 := to_ufixed (arg => checkreal, left_index => check7uf1'high, right_index => check7uf1'low, round_style => fixed_truncate, overflow_style => fixed_wrap); -- wrap check7uf2 := "0001000"; -- 1 report_error ("to_ufixed 17.0 failed to wrap", check7uf1, check7uf2); end if; checkreal := 5.0; check3uf1 := to_ufixed (arg => checkreal, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3uf2 := "001"; report_error ("to_ufixed 5.0 not round_test", check3uf1, check3uf2); checkreal := 5.0; check3uf1 := to_ufixed (arg => checkreal, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3uf2 := "001"; report_error ("to_ufixed 5.0 round_test", check3uf1, check3uf2); checkreal := 7.0; check3uf1 := to_ufixed (arg => checkreal, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3uf2 := "001"; report_error ("to_ufixed 7.0 not round_test", check3uf1, check3uf2); checkreal := 7.0; check3uf1 := to_ufixed (arg => checkreal, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3uf2 := "010"; report_error ("to_ufixed 7.0 round_test", check3uf1, check3uf2); checkreal := 17.0; check3uf1 := to_ufixed (arg => checkreal, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3uf2 := "100"; report_error ("to_ufixed 17.0 not round_test", check3uf1, check3uf2); checkreal := 17.0; check3uf1 := to_ufixed (arg => checkreal, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3uf2 := "100"; report_error ("to_ufixed 17.0 round_test", check3uf1, check3uf2); checkreal := 19.0; check3uf1 := to_ufixed (arg => checkreal, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3uf2 := "100"; report_error ("to_ufixed 19.0 not round_test", check3uf1, check3uf2); checkreal := 19.0; check3uf1 := to_ufixed (arg => checkreal, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3uf2 := "101"; report_error ("to_ufixed 19.0 round_test", check3uf1, check3uf2); checkreal := 24.0; check3uf1 := to_ufixed (arg => checkreal, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3uf2 := "110"; report_error ("to_ufixed 24.0 not round_test", check3uf1, check3uf2); checkreal := 24.0; check3uf1 := to_ufixed (arg => checkreal, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3uf2 := "110"; report_error ("to_ufixed 24.0 round_test", check3uf1, check3uf2); checkreal := 27.0; check3uf1 := to_ufixed (arg => checkreal, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3uf2 := "110"; report_error ("to_ufixed 27.0 not round_test", check3uf1, check3uf2); checkreal := 27.0; check3uf1 := to_ufixed (arg => checkreal, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3uf2 := "111"; report_error ("to_ufixed 27.0 round_test", check3uf1, check3uf2); checkreal := 31.0; check3uf1 := to_ufixed (arg => checkreal, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3uf2 := "111"; report_error ("to_ufixed 31.0 not round_test", check3uf1, check3uf2); checkreal := 31.0; check3uf1 := to_ufixed (arg => checkreal, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3uf2 := "111"; report_error ("to_ufixed 31.0 round_test", check3uf1, check3uf2); checkreal := 31.0; check3uf1 := to_ufixed (arg => checkreal, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_truncate, overflow_style => fixed_wrap); -- saturate check3uf2 := "111"; report_error ("to_ufixed 31.0 wrap not round_test", check3uf1, check3uf2); checkreal := 31.0; check3uf1 := to_ufixed (arg => checkreal, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_round, overflow_style => fixed_wrap); -- saturate check3uf2 := "000"; report_error ("to_ufixed 31.0 wrap round_test", check3uf1, check3uf2); if (not quiet) then checkreal := 35.0; report "Expect to_ufixed(real) overflow error" severity note; check3uf1 := to_ufixed (arg => checkreal, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3uf2 := "111"; report_error ("to_ufixed 35.0 not round_test", check3uf1, check3uf2); checkreal := 35.0; report "Expect to_ufixed(real) overflow error" severity note; check3uf1 := to_ufixed (arg => checkreal, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3uf2 := "111"; report_error ("to_ufixed 35.0 round_test", check3uf1, check3uf2); checkreal := 35.0; report "Expect to_ufixed(real) overflow error" severity note; check3uf1 := to_ufixed (arg => checkreal, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_truncate, overflow_style => fixed_wrap); -- saturate check3uf2 := "000"; report_error ("to_ufixed 35.0 wrap not round_test", check3uf1, check3uf2); checkreal := 35.0; report "Expect to_ufixed(real) overflow error" severity note; check3uf1 := to_ufixed (arg => checkreal, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_round, overflow_style => fixed_wrap); -- saturate check3uf2 := "001"; report_error ("to_ufixed 35.0 wrap round_test", check3uf1, check3uf2); end if; -- unsigned checkuns := to_unsigned (17, checkuns'length); check7uf1 := to_ufixed (arg => checkuns, left_index => check7uf1'high, right_index => check7uf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check7uf2 := (others => '1'); report_error ("to_ufixed uns 17 failed to saturate", check7uf1, check7uf2); checkuns := to_unsigned (17, checkuns'length); check7uf1 := to_ufixed (arg => checkuns, left_index => check7uf1'high, right_index => check7uf1'low, round_style => fixed_truncate, overflow_style => fixed_wrap); -- wrap check7uf2 := "0001000"; -- 1 report_error ("to_ufixed uns 17 failed to wrap", check7uf1, check7uf2); checkuns := to_unsigned (5, checkuns'length); check3uf1 := to_ufixed (arg => checkuns, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3uf2 := "001"; report_error ("to_ufixed uns 5 not round_test", check3uf1, check3uf2); checkuns := to_unsigned (5, checkuns'length); check3uf1 := to_ufixed (arg => checkuns, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3uf2 := "001"; report_error ("to_ufixed uns 5 round_test", check3uf1, check3uf2); checkuns := to_unsigned (7, checkuns'length); check3uf1 := to_ufixed (arg => checkuns, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3uf2 := "001"; report_error ("to_ufixed uns 7 not round_test", check3uf1, check3uf2); checkuns := to_unsigned (7, checkuns'length); check3uf1 := to_ufixed (arg => checkuns, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3uf2 := "010"; report_error ("to_ufixed uns 7 round_test", check3uf1, check3uf2); checkuns := to_unsigned (17, checkuns'length); check3uf1 := to_ufixed (arg => checkuns, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3uf2 := "100"; report_error ("to_ufixed uns 17 not round_test", check3uf1, check3uf2); checkuns := to_unsigned (17, checkuns'length); check3uf1 := to_ufixed (arg => checkuns, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3uf2 := "100"; report_error ("to_ufixed uns 17 round_test", check3uf1, check3uf2); checkuns := to_unsigned (19, checkuns'length); check3uf1 := to_ufixed (arg => checkuns, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3uf2 := "100"; report_error ("to_ufixed uns 19 not round_test", check3uf1, check3uf2); checkuns := to_unsigned (19, checkuns'length); check3uf1 := to_ufixed (arg => checkuns, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3uf2 := "101"; report_error ("to_ufixed uns 19 round_test", check3uf1, check3uf2); checkuns := to_unsigned (24, checkuns'length); check3uf1 := to_ufixed (arg => checkuns, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3uf2 := "110"; report_error ("to_ufixed uns 24 not round_test", check3uf1, check3uf2); checkuns := to_unsigned (24, checkuns'length); check3uf1 := to_ufixed (arg => checkuns, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3uf2 := "110"; report_error ("to_ufixed uns 24 round_test", check3uf1, check3uf2); checkuns := to_unsigned (27, checkuns'length); check3uf1 := to_ufixed (arg => checkuns, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3uf2 := "110"; report_error ("to_ufixed uns 27 not round_test", check3uf1, check3uf2); checkuns := to_unsigned (27, checkuns'length); check3uf1 := to_ufixed (arg => checkuns, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3uf2 := "111"; report_error ("to_ufixed uns 27 round_test", check3uf1, check3uf2); checkuns := to_unsigned (31, checkuns'length); check3uf1 := to_ufixed (arg => checkuns, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3uf2 := "111"; report_error ("to_ufixed uns 31 not round_test", check3uf1, check3uf2); checkuns := to_unsigned (31, checkuns'length); check3uf1 := to_ufixed (arg => checkuns, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3uf2 := "111"; report_error ("to_ufixed uns 31 round_test", check3uf1, check3uf2); checkuns := to_unsigned (31, checkuns'length); check3uf1 := to_ufixed (arg => checkuns, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_truncate, overflow_style => fixed_wrap); -- saturate check3uf2 := "111"; report_error ("to_ufixed uns 31 wrap not round_test", check3uf1, check3uf2); checkuns := to_unsigned (31, checkuns'length); check3uf1 := to_ufixed (arg => checkuns, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_round, overflow_style => fixed_wrap); -- saturate check3uf2 := "000"; report_error ("to_ufixed uns 31 wrap round_test", check3uf1, check3uf2); checkuns := to_unsigned (35, checkuns'length); check3uf1 := to_ufixed (arg => checkuns, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3uf2 := "111"; report_error ("to_ufixed uns 35 not round_test", check3uf1, check3uf2); checkuns := to_unsigned (35, checkuns'length); check3uf1 := to_ufixed (arg => checkuns, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3uf2 := "111"; report_error ("to_ufixed uns 35 round_test", check3uf1, check3uf2); checkuns := to_unsigned (35, checkuns'length); check3uf1 := to_ufixed (arg => checkuns, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_truncate, overflow_style => fixed_wrap); -- saturate check3uf2 := "000"; report_error ("to_ufixed uns 35 wrap not round_test", check3uf1, check3uf2); checkuns := to_unsigned (35, checkuns'length); check3uf1 := to_ufixed (arg => checkuns, left_index => check3uf1'high, right_index => check3uf1'low, round_style => fixed_round, overflow_style => fixed_wrap); -- saturate check3uf2 := "001"; report_error ("to_ufixed uns 35 wrap round_test", check3uf1, check3uf2); -- signed assert (quiet) report "Rounding test completed" severity note; saturatetest_done <= true; wait; end process saturatetest; -- purpose: test the signed saturation and rounding ssaturatetest : process is variable check7sf1, check7sf2, check7sf3 : sfixed8_3; variable check3sf1, check3sf2 : sfixed (5 downto 2); -- odd range variable check9sf, check9sf2 : sfixed (3 downto -5); variable check10sf : sfixed (4 downto -5); variable checkint : INTEGER; variable checkreal : REAL; variable checks : SIGNED (6 downto 0); begin -- process saturatetest wait until start_ssaturatetest; check3sf1 := "0001"; -- 4 check7sf1 := resize (arg => check3sf1, left_index => check7sf1'high, right_index => check7sf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check7sf2 := "00100000"; -- 4 report_error ("resize signed 4 dt 2 to 3 dt -3 error", check7sf1, check7sf2); check3sf1 := "0101"; -- 20 check7sf1 := resize (arg => check3sf1, left_index => check7sf1'high, right_index => check7sf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check7sf2 := (others => '1'); -- saturation check7sf2 (check7sf2'high) := '0'; report_error ("resize signed 4 dt 2 to 3 dt -3 sat error", check7sf1, check7sf2); check3sf1 := "0101"; -- 20 check7sf1 := resize (arg => check3sf1, left_index => check7sf1'high, right_index => check7sf1'low, round_style => fixed_truncate, overflow_style => fixed_wrap); -- wrap check7sf2 := "10100000"; -- -12 report_error ("resize signed 4 dt 2 to 3 dt -3 wrap error", check7sf1, check7sf2); check9sf := to_sfixed (7.96875, 3, -5); -- "0111.11111" check7sf1 := resize (arg => check9sf, left_index => check7sf1'high, right_index => check7sf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check7sf2 := "00111111"; -- 7.875 report_error ("resize signed to 3 dt -3 no round error", check7sf1, check7sf2); check9sf := to_sfixed (7.96875, 3, -5); -- "0111.11111" check7sf1 := resize (arg => check9sf, -- "0111.11111" left_index => check7sf1'high, right_index => check7sf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check7sf2 := "01000000"; -- 8 report_error ("resize signed to 3 dt -3 round error", check7sf1, check7sf2); check10sf := to_sfixed (15.96875, 4, -5); -- "01111.11111" check7sf1 := resize (arg => check10sf, left_index => check7sf1'high, right_index => check7sf1'low, round_style => fixed_round, overflow_style => fixed_wrap); -- wrap check7sf2 := "10000000"; -- -16 report_error ("resize signed to 3 dt -3 wrap round error", check7sf1, check7sf2); check7sf1 := resize (arg => to_sfixed (15.96875, 4, -5), -- "01111.11111" left_index => check7sf1'high, right_index => check7sf1'low, round_style => fixed_truncate, overflow_style => fixed_wrap); -- wrap check7sf2 := "01111111"; -- 15.875 report_error ("resize signed to 3 dt -3 wrap no round error", check7sf1, check7sf2); -- integer to sfixed if (not quiet) then checkint := 17; report "Expect to_sfixed(integer) overflow error" severity note; check7sf1 := to_sfixed (arg => checkint, left_index => check7sf1'high, right_index => check7sf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check7sf2 := (others => '1'); check7sf2 (check7sf2'high) := '0'; report_error ("to_sfixed 17 failed to saturate", check7sf1, check7sf2); checkint := 17; report "Expect to_sfixed(integer) overflow error" severity note; check7sf1 := to_sfixed (arg => checkint, left_index => check7sf1'high, right_index => check7sf1'low, round_style => fixed_truncate, overflow_style => fixed_wrap); -- wrap check7sf2 := "10001000"; -- -15 report_error ("to_sfixed 17 failed to wrap", check7sf1, check7sf2); checkint := 49; report "Expect to_sfixed(integer) overflow error" severity note; check7sf1 := to_sfixed (arg => checkint, left_index => check7sf1'high, right_index => check7sf1'low, round_style => fixed_truncate, overflow_style => fixed_wrap); -- wrap check7sf2 := "10001000"; -- -15 report_error ("to_sfixed 49 failed to wrap", check7sf1, check7sf2); checkint := 113; report "Expect to_sfixed(integer) overflow error" severity note; check7sf1 := to_sfixed (arg => checkint, left_index => check7sf1'high, right_index => check7sf1'low, round_style => fixed_truncate, overflow_style => fixed_wrap); -- wrap check7sf2 := "10001000"; -- -15 report_error ("to_sfixed 113 failed to wrap", check7sf1, check7sf2); end if; checkint := 5; check3sf1 := to_sfixed (arg => checkint, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3sf2 := "0001"; report_error ("to_sfixed 5 not round_test", check3sf1, check3sf2); checkint := 5; check3sf1 := to_sfixed (arg => checkint, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3sf2 := "0001"; report_error ("to_sfixed 5 round_test", check3sf1, check3sf2); checkint := 7; check3sf1 := to_sfixed (arg => checkint, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3sf2 := "0001"; report_error ("to_sfixed 7 not round_test", check3sf1, check3sf2); checkint := 7; check3sf1 := to_sfixed (arg => checkint, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3sf2 := "0010"; report_error ("to_sfixed 7 round_test", check3sf1, check3sf2); checkint := 17; check3sf1 := to_sfixed (arg => checkint, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3sf2 := "0100"; report_error ("to_sfixed 17 not round_test", check3sf1, check3sf2); checkint := 17; check3sf1 := to_sfixed (arg => checkint, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3sf2 := "0100"; report_error ("to_sfixed 17 round_test", check3sf1, check3sf2); checkint := 19; check3sf1 := to_sfixed (arg => checkint, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3sf2 := "0100"; report_error ("to_sfixed 19 not round_test", check3sf1, check3sf2); checkint := 19; check3sf1 := to_sfixed (arg => checkint, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3sf2 := "0101"; report_error ("to_sfixed 19 round_test", check3sf1, check3sf2); checkint := 24; check3sf1 := to_sfixed (arg => checkint, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3sf2 := "0110"; report_error ("to_sfixed 24 not round_test", check3sf1, check3sf2); checkint := 24; check3sf1 := to_sfixed (arg => checkint, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3sf2 := "0110"; report_error ("to_sfixed 24 round_test", check3sf1, check3sf2); checkint := 27; check3sf1 := to_sfixed (arg => checkint, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3sf2 := "0110"; report_error ("to_sfixed 27 not round_test", check3sf1, check3sf2); checkint := 27; check3sf1 := to_sfixed (arg => checkint, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3sf2 := "0111"; report_error ("to_sfixed 27 round_test", check3sf1, check3sf2); checkint := 31; check3sf1 := to_sfixed (arg => checkint, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3sf2 := "0111"; report_error ("to_sfixed 31 not round_test", check3sf1, check3sf2); checkint := 31; check3sf1 := to_sfixed (arg => checkint, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3sf2 := "0111"; report_error ("to_sfixed 31 round_test", check3sf1, check3sf2); checkint := 31; check3sf1 := to_sfixed (arg => checkint, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_truncate, overflow_style => fixed_wrap); -- saturate check3sf2 := "0111"; report_error ("to_sfixed 31 wrap not round_test", check3sf1, check3sf2); checkint := 31; check3sf1 := to_sfixed (arg => checkint, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_round, overflow_style => fixed_wrap); -- saturate check3sf2 := "1000"; report_error ("to_sfixed 31 wrap round_test", check3sf1, check3sf2); if (not quiet) then checkint := 35; report "Expect to_sfixed(integer) overflow error" severity note; check3sf1 := to_sfixed (arg => checkint, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3sf2 := "0111"; report_error ("to_sfixed 35 not round_test", check3sf1, check3sf2); checkint := 35; report "Expect to_sfixed(integer) overflow error" severity note; check3sf1 := to_sfixed (arg => checkint, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3sf2 := "0111"; report_error ("to_sfixed 35 round_test", check3sf1, check3sf2); checkint := 35; report "Expect to_sfixed(integer) overflow error" severity note; check3sf1 := to_sfixed (arg => checkint, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_truncate, overflow_style => fixed_wrap); -- saturate check3sf2 := "1000"; report_error ("to_sfixed 35 wrap not round_test", check3sf1, check3sf2); checkint := 35; report "Expect to_sfixed(integer) overflow error" severity note; check3sf1 := to_sfixed (arg => checkint, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_round, overflow_style => fixed_wrap); -- saturate check3sf2 := "1001"; report_error ("to_sfixed 35 wrap round_test", check3sf1, check3sf2); end if; -- real number signed fixed if (not quiet) then checkreal := 17.0; report "Expect to_sfixed(real) overflow error" severity note; check7sf1 := to_sfixed (arg => checkreal, left_index => check7sf1'high, right_index => check7sf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check7sf2 := (others => '1'); check7sf2 (check7sf2'high) := '0'; report_error ("to_sfixed 17.0 failed to saturate", check7sf1, check7sf2); checkreal := 17.0; report "Expect to_sfixed(real) overflow error" severity note; check7sf1 := to_sfixed (arg => checkreal, left_index => check7sf1'high, right_index => check7sf1'low, round_style => fixed_truncate, overflow_style => fixed_wrap); -- wrap check7sf2 := "10001000"; -- 1 report_error ("to_sfixed 49.0 failed to wrap", check7sf1, check7sf2); checkreal := 49.0; report "Expect to_sfixed(real) overflow error" severity note; check7sf1 := to_sfixed (arg => checkreal, left_index => check7sf1'high, right_index => check7sf1'low, round_style => fixed_truncate, overflow_style => fixed_wrap); -- wrap check7sf2 := "10001000"; -- 1 report_error ("to_sfixed 113.0 failed to wrap", check7sf1, check7sf2); checkreal := 113.0; report "Expect to_sfixed(real) overflow error" severity note; check7sf1 := to_sfixed (arg => checkreal, left_index => check7sf1'high, right_index => check7sf1'low, round_style => fixed_truncate, overflow_style => fixed_wrap); -- wrap check7sf2 := "10001000"; -- 1 report_error ("to_sfixed 17.0 failed to wrap", check7sf1, check7sf2); end if; checkreal := 5.0; check3sf1 := to_sfixed (arg => checkreal, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3sf2 := "0001"; report_error ("to_sfixed 5.0 not round_test", check3sf1, check3sf2); checkreal := 5.0; check3sf1 := to_sfixed (arg => checkreal, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3sf2 := "0001"; report_error ("to_sfixed 5.0 round_test", check3sf1, check3sf2); checkreal := 7.0; check3sf1 := to_sfixed (arg => checkreal, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3sf2 := "0001"; report_error ("to_sfixed 7.0 not round_test", check3sf1, check3sf2); checkreal := 7.0; check3sf1 := to_sfixed (arg => checkreal, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3sf2 := "0010"; report_error ("to_sfixed 7.0 round_test", check3sf1, check3sf2); checkreal := 17.0; check3sf1 := to_sfixed (arg => checkreal, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3sf2 := "0100"; report_error ("to_sfixed 17.0 not round_test", check3sf1, check3sf2); checkreal := 17.0; check3sf1 := to_sfixed (arg => checkreal, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3sf2 := "0100"; report_error ("to_sfixed 17.0 round_test", check3sf1, check3sf2); checkreal := 19.0; check3sf1 := to_sfixed (arg => checkreal, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3sf2 := "0100"; report_error ("to_sfixed 19.0 not round_test", check3sf1, check3sf2); checkreal := 19.0; check3sf1 := to_sfixed (arg => checkreal, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3sf2 := "0101"; report_error ("to_sfixed 19.0 round_test", check3sf1, check3sf2); checkreal := 24.0; check3sf1 := to_sfixed (arg => checkreal, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3sf2 := "0110"; report_error ("to_sfixed 24.0 not round_test", check3sf1, check3sf2); checkreal := 24.0; check3sf1 := to_sfixed (arg => checkreal, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3sf2 := "0110"; report_error ("to_sfixed 24.0 round_test", check3sf1, check3sf2); checkreal := 27.0; check3sf1 := to_sfixed (arg => checkreal, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3sf2 := "0110"; report_error ("to_sfixed 27.0 not round_test", check3sf1, check3sf2); checkreal := 27.0; check3sf1 := to_sfixed (arg => checkreal, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3sf2 := "0111"; report_error ("to_sfixed 27.0 round_test", check3sf1, check3sf2); checkreal := 31.0; check3sf1 := to_sfixed (arg => checkreal, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3sf2 := "0111"; report_error ("to_sfixed 31.0 not round_test", check3sf1, check3sf2); checkreal := 31.0; check3sf1 := to_sfixed (arg => checkreal, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3sf2 := "0111"; report_error ("to_sfixed 31.0 round_test", check3sf1, check3sf2); checkreal := 31.0; check3sf1 := to_sfixed (arg => checkreal, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_truncate, overflow_style => fixed_wrap); -- saturate check3sf2 := "0111"; report_error ("to_sfixed 31.0 wrap not round_test", check3sf1, check3sf2); checkreal := 31.0; check3sf1 := to_sfixed (arg => checkreal, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_round, overflow_style => fixed_wrap); -- saturate check3sf2 := "1000"; -- overflow into the sign bit and wrap report_error ("to_sfixed 31.0 wrap round_test", check3sf1, check3sf2); if (not quiet) then checkreal := 35.0; report "Expect to_sfixed(real) overflow error" severity note; check3sf1 := to_sfixed (arg => checkreal, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3sf2 := "0111"; report_error ("to_sfixed 35.0 not round_test", check3sf1, check3sf2); checkreal := 35.0; report "Expect to_sfixed(real) overflow error" severity note; check3sf1 := to_sfixed (arg => checkreal, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3sf2 := "0111"; report_error ("to_sfixed 35.0 round_test", check3sf1, check3sf2); checkreal := 35.0; report "Expect to_sfixed(real) overflow error" severity note; check3sf1 := to_sfixed (arg => checkreal, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_truncate, overflow_style => fixed_wrap); -- saturate check3sf2 := "1000"; report_error ("to_sfixed 35.0 wrap not round_test", check3sf1, check3sf2); checkreal := 35.0; report "Expect to_sfixed(real) overflow error" severity note; check3sf1 := to_sfixed (arg => checkreal, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_round, overflow_style => fixed_wrap); -- saturate check3sf2 := "1001"; report_error ("to_sfixed 35.0 wrap round_test", check3sf1, check3sf2); end if; -- signed checks := to_signed (17, checks'length); check7sf1 := to_sfixed (arg => checks, left_index => check7sf1'high, right_index => check7sf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check7sf2 := (others => '1'); check7sf2 (check7sf2'high) := '0'; report_error ("to_sfixed s 17 failed to saturate", check7sf1, check7sf2); checks := to_signed (17, checks'length); check7sf1 := to_sfixed (arg => checks, left_index => check7sf1'high, right_index => check7sf1'low, round_style => fixed_truncate, overflow_style => fixed_wrap); -- wrap check7sf2 := "10001000"; -- 1 report_error ("to_sfixed s 17 failed to wrap", check7sf1, check7sf2); checks := to_signed (5, checks'length); check3sf1 := to_sfixed (arg => checks, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3sf2 := "0001"; report_error ("to_sfixed s 5 not round_test", check3sf1, check3sf2); checks := to_signed (5, checks'length); check3sf1 := to_sfixed (arg => checks, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3sf2 := "0001"; report_error ("to_sfixed s 5 round_test", check3sf1, check3sf2); checks := to_signed (7, checks'length); check3sf1 := to_sfixed (arg => checks, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3sf2 := "0001"; report_error ("to_sfixed s 7 not round_test", check3sf1, check3sf2); checks := to_signed (7, checks'length); check3sf1 := to_sfixed (arg => checks, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3sf2 := "0010"; report_error ("to_sfixed s 7 round_test", check3sf1, check3sf2); checks := to_signed (17, checks'length); check3sf1 := to_sfixed (arg => checks, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3sf2 := "0100"; report_error ("to_sfixed s 17 not round_test", check3sf1, check3sf2); checks := to_signed (17, checks'length); check3sf1 := to_sfixed (arg => checks, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3sf2 := "0100"; report_error ("to_sfixed s 17 round_test", check3sf1, check3sf2); checks := to_signed (19, checks'length); check3sf1 := to_sfixed (arg => checks, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3sf2 := "0100"; report_error ("to_sfixed s 19 not round_test", check3sf1, check3sf2); checks := to_signed (19, checks'length); check3sf1 := to_sfixed (arg => checks, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3sf2 := "0101"; report_error ("to_sfixed s 19 round_test", check3sf1, check3sf2); checks := to_signed (24, checks'length); check3sf1 := to_sfixed (arg => checks, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3sf2 := "0110"; report_error ("to_sfixed s 24 not round_test", check3sf1, check3sf2); checks := to_signed (24, checks'length); check3sf1 := to_sfixed (arg => checks, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3sf2 := "0110"; report_error ("to_sfixed s 24 round_test", check3sf1, check3sf2); checks := to_signed (27, checks'length); check3sf1 := to_sfixed (arg => checks, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3sf2 := "0110"; report_error ("to_sfixed s 27 not round_test", check3sf1, check3sf2); checks := to_signed (27, checks'length); check3sf1 := to_sfixed (arg => checks, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3sf2 := "0111"; report_error ("to_sfixed s 27 round_test", check3sf1, check3sf2); checks := to_signed (31, checks'length); check3sf1 := to_sfixed (arg => checks, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3sf2 := "0111"; report_error ("to_sfixed s 31 not round_test", check3sf1, check3sf2); checks := to_signed (31, checks'length); check3sf1 := to_sfixed (arg => checks, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3sf2 := "0111"; report_error ("to_sfixed s 31 round_test", check3sf1, check3sf2); checks := to_signed (31, checks'length); check3sf1 := to_sfixed (arg => checks, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_truncate, overflow_style => fixed_wrap); -- saturate check3sf2 := "0111"; report_error ("to_sfixed s 31 wrap not round_test", check3sf1, check3sf2); checks := to_signed (31, checks'length); check3sf1 := to_sfixed (arg => checks, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_round, overflow_style => fixed_wrap); -- saturate check3sf2 := "1000"; report_error ("to_sfixed s 31 wrap round_test", check3sf1, check3sf2); checks := to_signed (35, checks'length); check3sf1 := to_sfixed (arg => checks, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3sf2 := "0111"; report_error ("to_sfixed s 35 not round_test", check3sf1, check3sf2); checks := to_signed (35, checks'length); check3sf1 := to_sfixed (arg => checks, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3sf2 := "0111"; report_error ("to_sfixed s 35 round_test", check3sf1, check3sf2); checks := to_signed (35, checks'length); check3sf1 := to_sfixed (arg => checks, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_truncate, overflow_style => fixed_wrap); -- saturate check3sf2 := "1000"; report_error ("to_sfixed s 35 wrap not round_test", check3sf1, check3sf2); checks := to_signed (35, checks'length); check3sf1 := to_sfixed (arg => checks, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_round, overflow_style => fixed_wrap); -- saturate check3sf2 := "1001"; report_error ("to_sfixed s 35 wrap round_test", check3sf1, check3sf2); --------------------------------------------------------------------------- -- Negative number test --------------------------------------------------------------------------- check3sf1 := "1111"; -- -4 check7sf1 := resize (arg => check3sf1, left_index => check7sf1'high, right_index => check7sf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check7sf2 := "11100000"; -- -4 report_error ("resize -signed 4 dt 2 to 3 dt -3 error", check7sf1, check7sf2); check3sf1 := "1011"; -- -20 check7sf1 := resize (arg => check3sf1, left_index => check7sf1'high, right_index => check7sf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check7sf2 := (others => '0'); -- saturation check7sf2 (check7sf2'high) := '1'; report_error ("resize -signed 4 dt 2 to 3 dt -3 sat error", check7sf1, check7sf2); check3sf1 := "1011"; -- -20 check7sf1 := resize (arg => check3sf1, left_index => check7sf1'high, right_index => check7sf1'low, round_style => fixed_truncate, overflow_style => fixed_wrap); -- wrap check7sf2 := "01100000"; -- 12 report_error ("resize -signed 4 dt 2 to 3 dt -3 wrap error", check7sf1, check7sf2); check9sf := "100000011"; -- -7.90625 check7sf1 := resize (arg => check9sf, left_index => check7sf1'high, right_index => check7sf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check7sf2 := "11000000"; -- -8.0 report_error ("resize -signed to 3 dt -3 no round error", check7sf1, check7sf2); check9sf := "100000011"; -- -7.90625 check7sf1 := resize (arg => check9sf, -- "0111.11111" left_index => check7sf1'high, right_index => check7sf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check7sf2 := "11000001"; -- -7.875 report_error ("resize -signed to 3 dt -3 round error", check7sf1, check7sf2); check9sf := "100000001"; -- -7.96875 check7sf1 := resize (arg => check9sf, -- "0111.11111" left_index => check7sf1'high, right_index => check7sf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check7sf2 := "11000000"; -- -8 report_error ("resize -signed to 3 dt -3 round error", check7sf1, check7sf2); check10sf := "1111111111"; -- -1 check7sf1 := resize (arg => check10sf, left_index => check7sf1'high, right_index => check7sf1'low, round_style => fixed_round, overflow_style => fixed_wrap); -- wrap check7sf2 := (others => '0'); -- -1 report_error ("resize -signed to 3 dt -3 wrap round error", check7sf1, check7sf2); check10sf := "1111111100"; -- -1 check7sf1 := resize (arg => check10sf, left_index => check7sf1'high, right_index => check7sf1'low, round_style => fixed_round, overflow_style => fixed_wrap); -- wrap check7sf2 := "11111111"; -- -1 report_error ("resize -signed to 3 dt -3 wrap round error", check7sf1, check7sf2); -- integer to sfixed if (not quiet) then checkint := -17; report "Expect to_sfixed(integer) -overflow error" severity note; check7sf1 := to_sfixed (arg => checkint, left_index => check7sf1'high, right_index => check7sf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check7sf2 := (others => '0'); check7sf2 (check7sf2'high) := '1'; report_error ("to_sfixed -17 failed to saturate", check7sf1, check7sf2); checkint := -17; report "Expect to_sfixed(integer) -overflow error" severity note; check7sf1 := to_sfixed (arg => checkint, left_index => check7sf1'high, right_index => check7sf1'low, round_style => fixed_truncate, overflow_style => fixed_wrap); -- wrap check7sf2 := "01111000"; -- 15 report_error ("to_sfixed -17 failed to wrap", check7sf1, check7sf2); checkint := -18; report "Expect to_sfixed(integer) -overflow error" severity note; check7sf1 := to_sfixed (arg => checkint, left_index => check7sf1'high, right_index => check7sf1'low, round_style => fixed_truncate, overflow_style => fixed_wrap); -- wrap check7sf2 := "01110000"; -- 14 report_error ("to_sfixed -18 failed to wrap", check7sf1, check7sf2); checkint := -50; report "Expect to_sfixed(integer) -overflow error" severity note; check7sf1 := to_sfixed (arg => checkint, left_index => check7sf1'high, right_index => check7sf1'low, round_style => fixed_truncate, overflow_style => fixed_wrap); -- wrap check7sf2 := "01110000"; -- 14 report_error ("to_sfixed -50 failed to wrap", check7sf1, check7sf2); checkint := -114; report "Expect to_sfixed(integer) -overflow error" severity note; check7sf1 := to_sfixed (arg => checkint, left_index => check7sf1'high, right_index => check7sf1'low, round_style => fixed_truncate, overflow_style => fixed_wrap); -- wrap check7sf2 := "01110000"; -- 14 report_error ("to_sfixed -114 failed to wrap", check7sf1, check7sf2); end if; checkint := -5; check3sf1 := to_sfixed (arg => checkint, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3sf2 := "1110"; -- -8 report_error ("to_sfixed -5 not round_test", check3sf1, check3sf2); checkint := -5; check3sf1 := to_sfixed (arg => checkint, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3sf2 := "1111"; -- -4 report_error ("to_sfixed -5 round_test", check3sf1, check3sf2); checkint := -7; check3sf1 := to_sfixed (arg => checkint, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3sf2 := "1110"; -- -8 report_error ("to_sfixed -7 not round_test", check3sf1, check3sf2); checkint := -7; check3sf1 := to_sfixed (arg => checkint, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3sf2 := "1110"; report_error ("to_sfixed -7 round_test", check3sf1, check3sf2); checkint := -17; check3sf1 := to_sfixed (arg => checkint, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3sf2 := "1011"; -- -20 report_error ("to_sfixed -17 not round_test", check3sf1, check3sf2); checkint := -17; check3sf1 := to_sfixed (arg => checkint, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3sf2 := "1100"; -- -16 report_error ("to_sfixed -17 round_test", check3sf1, check3sf2); checkint := -19; check3sf1 := to_sfixed (arg => checkint, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3sf2 := "1011"; -- -20 report_error ("to_sfixed -19 not round_test", check3sf1, check3sf2); checkint := -19; check3sf1 := to_sfixed (arg => checkint, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3sf2 := "1011"; report_error ("to_sfixed -19 round_test", check3sf1, check3sf2); checkint := -24; check3sf1 := to_sfixed (arg => checkint, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3sf2 := "1010"; report_error ("to_sfixed -24 not round_test", check3sf1, check3sf2); checkint := -24; check3sf1 := to_sfixed (arg => checkint, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3sf2 := "1010"; report_error ("to_sfixed -24 round_test", check3sf1, check3sf2); checkint := -27; check3sf1 := to_sfixed (arg => checkint, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3sf2 := "1001"; report_error ("to_sfixed -27 not round_test", check3sf1, check3sf2); checkint := -27; check3sf1 := to_sfixed (arg => checkint, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3sf2 := "1001"; report_error ("to_sfixed -27 round_test", check3sf1, check3sf2); checkint := -31; check3sf1 := to_sfixed (arg => checkint, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3sf2 := "1000"; -- -32 report_error ("to_sfixed -31 not round_test", check3sf1, check3sf2); checkint := -31; check3sf1 := to_sfixed (arg => checkint, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3sf2 := "1000"; -- -32 report_error ("to_sfixed -31 round_test", check3sf1, check3sf2); checkint := -31; check3sf1 := to_sfixed (arg => checkint, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_truncate, overflow_style => fixed_wrap); -- saturate check3sf2 := "1000"; -- -32 report_error ("to_sfixed -31 wrap not round_test", check3sf1, check3sf2); checkint := -31; check3sf1 := to_sfixed (arg => checkint, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_round, overflow_style => fixed_wrap); -- saturate check3sf2 := "1000"; -- -32 report_error ("to_sfixed -31 wrap round_test", check3sf1, check3sf2); if (not quiet) then checkint := -35; report "Expect to_sfixed(integer) -overflow error" severity note; check3sf1 := to_sfixed (arg => checkint, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3sf2 := "1000"; -- -32 report_error ("to_sfixed -35 not round_test", check3sf1, check3sf2); checkint := -35; report "Expect to_sfixed(integer) -overflow error" severity note; check3sf1 := to_sfixed (arg => checkint, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3sf2 := "1000"; -- -32 report_error ("to_sfixed -35 round_test", check3sf1, check3sf2); checkint := -35; report "Expect to_sfixed(integer) -overflow error" severity note; check3sf1 := to_sfixed (arg => checkint, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_truncate, overflow_style => fixed_wrap); -- saturate check3sf2 := "0111"; -- 28 report_error ("to_sfixed -35 wrap not round_test", check3sf1, check3sf2); checkint := -35; report "Expect to_sfixed(integer) -overflow error" severity note; check3sf1 := to_sfixed (arg => checkint, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_round, overflow_style => fixed_wrap); -- saturate check3sf2 := "0111"; -- 28 report_error ("to_sfixed -35 wrap round_test", check3sf1, check3sf2); end if; checkint := -31; check3sf1 := to_sfixed (arg => checkint, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_round, overflow_style => fixed_wrap); check3sf2 := "1000"; report_error ("to_sfixed -31 wrap round_test", check3sf1, check3sf2); checkint := -32; check3sf1 := to_sfixed (arg => checkint, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_round, overflow_style => fixed_wrap); check3sf2 := "1000"; report_error ("to_sfixed -32 wrap round_test", check3sf1, check3sf2); -- real number signed fixed if (not quiet) then checkreal := -17.0; report "Expect to_sfixed(real) -overflow error" severity note; check7sf1 := to_sfixed (arg => checkreal, left_index => check7sf1'high, right_index => check7sf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check7sf2 := (others => '0'); check7sf2 (check7sf2'high) := '1'; report_error ("to_sfixed -17.0 failed to saturate", check7sf1, check7sf2); checkreal := -17.0; report "Expect to_sfixed(real) -overflow error" severity note; check7sf1 := to_sfixed (arg => checkreal, left_index => check7sf1'high, right_index => check7sf1'low, round_style => fixed_truncate, overflow_style => fixed_wrap); -- wrap check7sf2 := "01111000"; --15 report_error ("to_sfixed -17.0 failed to wrap", check7sf1, check7sf2); end if; checkreal := -5.0; check3sf1 := to_sfixed (arg => checkreal, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3sf2 := "1110"; -- -8 report_error ("to_sfixed -5.0 not round_test", check3sf1, check3sf2); checkreal := -5.0; check3sf1 := to_sfixed (arg => checkreal, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3sf2 := "1111"; -- -4 report_error ("to_sfixed -5.0 round_test", check3sf1, check3sf2); checkreal := -7.0; check3sf1 := to_sfixed (arg => checkreal, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3sf2 := "1110"; -- -8 report_error ("to_sfixed -7.0 not round_test", check3sf1, check3sf2); checkreal := -7.0; check3sf1 := to_sfixed (arg => checkreal, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3sf2 := "1110"; report_error ("to_sfixed -7.0 round_test", check3sf1, check3sf2); checkreal := -17.0; check3sf1 := to_sfixed (arg => checkreal, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3sf2 := "1011"; -- -20 report_error ("to_sfixed -17.0 not round_test", check3sf1, check3sf2); checkreal := -17.0; check3sf1 := to_sfixed (arg => checkreal, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3sf2 := "1100"; -- -16 report_error ("to_sfixed -17.0 round_test", check3sf1, check3sf2); checkreal := -19.0; check3sf1 := to_sfixed (arg => checkreal, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3sf2 := "1011"; -- -20 report_error ("to_sfixed -19.0 not round_test", check3sf1, check3sf2); checkreal := -19.0; check3sf1 := to_sfixed (arg => checkreal, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3sf2 := "1011"; report_error ("to_sfixed -19.0 round_test", check3sf1, check3sf2); checkreal := -24.0; check3sf1 := to_sfixed (arg => checkreal, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3sf2 := "1010"; report_error ("to_sfixed -24.0 not round_test", check3sf1, check3sf2); checkreal := -24.0; check3sf1 := to_sfixed (arg => checkreal, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3sf2 := "1010"; report_error ("to_sfixed -24.0 round_test", check3sf1, check3sf2); checkreal := -27.0; check3sf1 := to_sfixed (arg => checkreal, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3sf2 := "1001"; report_error ("to_sfixed -27.0 not round_test", check3sf1, check3sf2); checkreal := -27.0; check3sf1 := to_sfixed (arg => checkreal, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3sf2 := "1001"; report_error ("to_sfixed -27.0 round_test", check3sf1, check3sf2); checkreal := -31.0; check3sf1 := to_sfixed (arg => checkreal, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3sf2 := "1000"; -- -32 report_error ("to_sfixed -31.0 not round_test", check3sf1, check3sf2); checkreal := -31.0; check3sf1 := to_sfixed (arg => checkreal, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3sf2 := "1000"; -- -32 report_error ("to_sfixed -31.0 round_test", check3sf1, check3sf2); checkreal := -31.0; check3sf1 := to_sfixed (arg => checkreal, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_truncate, overflow_style => fixed_wrap); -- saturate check3sf2 := "1000"; -- -32 report_error ("to_sfixed -31.0 wrap not round_test", check3sf1, check3sf2); checkreal := -31.0; check3sf1 := to_sfixed (arg => checkreal, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_round, overflow_style => fixed_wrap); -- saturate check3sf2 := "1000"; -- -32 report_error ("to_sfixed -31.0 wrap round_test", check3sf1, check3sf2); if (not quiet) then checkreal := -35.0; report "Expect to_sfixed(real) -overflow error" severity note; check3sf1 := to_sfixed (arg => checkreal, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_truncate, overflow_style => fixed_saturate); -- saturate check3sf2 := "1000"; -- -32 report_error ("to_sfixed -35.0 not round_test", check3sf1, check3sf2); checkreal := -35.0; report "Expect to_sfixed(real) -overflow error" severity note; check3sf1 := to_sfixed (arg => checkreal, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_round, overflow_style => fixed_saturate); -- saturate check3sf2 := "1000"; -- -32 report_error ("to_sfixed -35.0 round_test", check3sf1, check3sf2); checkreal := -35.0; report "Expect to_sfixed(real) -overflow error" severity note; check3sf1 := to_sfixed (arg => checkreal, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_truncate, overflow_style => fixed_wrap); -- saturate check3sf2 := "0111"; -- 28 report_error ("to_sfixed -35.0 wrap not round_test", check3sf1, check3sf2); checkreal := -35.0; report "Expect to_sfixed(real) -overflow error" severity note; check3sf1 := to_sfixed (arg => checkreal, left_index => check3sf1'high, right_index => check3sf1'low, round_style => fixed_round, overflow_style => fixed_wrap); -- saturate check3sf2 := "0111"; -- 28 report_error ("to_sfixed -35.0 wrap round_test", check3sf1, check3sf2); end if; check10sf := "1111111111"; check9sf := resize (check10sf, check9sf'high, check9sf'low); check9sf2 := "111111111"; report_error ("Almost 0 resize", check9sf, check9sf2); -- -signed to sfixed -- report to_string(check3sf1) & " = " & real'image(to_real(check3sf1)) severity note; -- check9sf := "100000000"; -- -8 -- check9sf2 := "000100000"; -- for i in 1 to 20 loop -- report to_string(check9sf) & " = " & real'image(to_real(check9sf)) severity note; -- check9sf := resize (check9sf + check9sf2, check9sf'high, check9sf'low); -- end loop; -- i assert (quiet) report "Saturation test complete" severity note; ssaturatetest_done <= true; wait; end process ssaturatetest; -- purpose: check the overloaded functions overloadtest : process is -- purpose: Converts an sfixed to a ufixed function to_ufixed ( arg : sfixed) return ufixed is variable argabs : sfixed (arg'high + 1 downto arg'low); variable result : ufixed (arg'range); begin argabs := abs (arg); result := ufixed (argabs (arg'range)); return result; end function to_ufixed; variable check7uf1, check7uf2 : ufixed7_3; variable check7uf : ufixed (4 downto -3); -- ufixed7_3+ufixed7_3 variable check7sf1, check7sf2 : sfixed7_3; variable check7sf : sfixed (4 downto -3); -- sfixed7_3+sfixed7_3 variable check7sfx : sfixed (5 downto -3); -- ufixed7_3+sfixed7_3 variable checkint : INTEGER; variable checkreal : REAL; variable mulres : ufixed (7 downto -6); -- ufixed7_3*ufixed7_3 variable divres : ufixed (6 downto -7); -- ufixed7_3/ufixed7_3 variable smulres : sfixed (7 downto -6); -- sfixed7_3*sfixed7_3 variable smulresx : sfixed (8 downto -6); -- sfixed7_3 * ufixed7_3 variable sdivres : sfixed (7 downto -6); -- sfixed7_3/sfixed7_3 variable sdivresi2 : sfixed (7 downto -3); -- int / sfixed7_3 variable sdivresx : sfixed (7 downto -7); -- sfixed7_3/ufixed7_3 variable sdivresx2 : sfixed (8 downto -6); -- ufixed7_3/sfixed7_3 variable smodresx : sfixed(4 downto -3); -- sfixed7_3 rem ufixed7_3 variable bigs : sfixed (9 downto -9); -- Big sfixed variable uf1 : ufixed (0 downto 0); -- one BIT variable uf2 : ufixed (1 downto 0); -- two bits variable uf3 : ufixed (-1 downto -1); -- one negative bit variable sf1 : sfixed (0 downto 0); -- one BIT variable sf2 : sfixed (1 downto 0); -- two bits variable sf3 : sfixed (-1 downto -1); -- one BIT begin wait until start_overloadtest; -- + and - check7uf1 := "0000100"; -- 0.5 checkint := 2; check7uf := check7uf1 + checkint; report_error ("uf+int", check7uf, to_ufixed (0.5+2.0, check7uf'high, check7uf'low)); check7uf := checkint + check7uf1; report_error ("int+uf", check7uf, to_ufixed (0.5+2.0, check7uf'high, check7uf'low)); check7uf1 := "0011100"; -- 3.5 checkint := 2; check7uf := check7uf1 - checkint; report_error ("uf-int", check7uf, to_ufixed (3.5-2.0, check7uf'high, check7uf'low)); checkint := 4; check7uf := checkint - check7uf1; report_error ("int-uf", check7uf, to_ufixed (4.0-3.5, check7uf'high, check7uf'low)); check7uf1 := "0001100"; -- 1.5 uf1 := "0"; -- 0 check7uf := check7uf1 + uf1; report_error (to_string(check7uf1) & " + " & to_string(uf1), check7uf, check7uf1); check7uf1 := "0010100"; -- 2.5 uf1 := "1"; -- 1 check7uf := check7uf1 + uf1; report_error (to_string(check7uf1) & " + " & to_string(uf1), check7uf, to_ufixed(3.5, check7uf)); uf1 := "0"; -- 0 uf3 := "0"; -- 0 check7uf := resize (uf3 + uf1, check7uf); report_error (to_string(uf3) & " + " & to_string(uf1), check7uf, to_ufixed(0, check7uf)); uf1 := "0"; -- 0 uf3 := "1"; -- 0 check7uf := resize (uf1 + uf3, check7uf); report_error (to_string(uf1) & " + " & to_string(uf3), check7uf, to_ufixed(0.5, check7uf)); check7uf1 := "0010100"; -- 2.5 uf3 := "1"; -- 0.5 check7uf := check7uf1 + uf3; report_error (to_string(check7uf1) & " + " & to_string(uf3), check7uf, to_ufixed(3, check7uf)); check7uf1 := "0010110"; -- 2.75 uf2 := "11"; -- 3 check7uf := check7uf1 + uf2; report_error (to_string(check7uf1) & " + " & to_string(uf2), check7uf, to_ufixed(5.75, check7uf)); check7uf1 := "0010100"; -- 2.5 uf3 := "1"; -- 0.5 check7uf := check7uf1 - uf3; report_error (to_string(check7uf1) & " - " & to_string(uf3), check7uf, to_ufixed(2, check7uf)); check7uf1 := "0010100"; -- 2.5 uf1 := "1"; -- 1 check7uf := check7uf1 - uf1; report_error (to_string(check7uf1) & " - " & to_string(uf1), check7uf, to_ufixed(1.5, check7uf)); check7uf1 := "0000100"; -- 0.5 uf1 := "1"; -- 1 check7uf := check7uf1 - uf1; -- underflow report_error (to_string(check7uf1) & " - " & to_string(uf1), check7uf, to_ufixed(31.5, check7uf)); -- real number check7uf1 := "0000100"; -- 0.5 checkreal := 2.0; check7uf := check7uf1 + checkreal; report_error ("uf+real", check7uf, to_ufixed (0.5+2.0, check7uf'high, check7uf'low)); check7uf := checkreal + check7uf1; report_error ("real+uf", check7uf, to_ufixed (0.5+2.0, check7uf'high, check7uf'low)); check7uf1 := "0011100"; -- 3.5 checkreal := 2.0; check7uf := check7uf1 - checkreal; report_error ("uf-real", check7uf, to_ufixed (3.5-2.0, check7uf'high, check7uf'low)); checkreal := 4.0; check7uf := checkreal - check7uf1; report_error ("real+uf", check7uf, to_ufixed (4.0-3.5, check7uf'high, check7uf'low)); -- multiply check7uf1 := "0000100"; -- 0.5 checkreal := 2.0; mulres := check7uf1 * checkreal; report_error ("uf*real", mulres, to_ufixed (2.0*0.5, mulres'high, mulres'low)); mulres := checkreal * check7uf1; report_error ("real*uf", mulres, to_ufixed (2.0*0.5, mulres'high, mulres'low)); check7uf1 := "0000100"; -- 0.5 checkint := 2; mulres := resize (check7uf1 * checkint, mulres'high, mulres'low); report_error ("uf*int", mulres, to_ufixed (2.0*0.5, mulres'high, mulres'low)); mulres := resize (checkint * check7uf1, mulres'high, mulres'low); report_error ("int*uf", mulres, to_ufixed (2.0*0.5, mulres'high, mulres'low)); -- divide check7uf1 := "0000100"; -- 0.5 checkreal := 2.0; divres := check7uf1 / checkreal; report_error ("uf/real", divres, to_ufixed (0.5/2.0, divres'high, divres'low)); divres := checkreal / check7uf1; report_error ("real/uf", divres, to_ufixed (2.0/0.5, divres'high, divres'low)); check7uf1 := "0000100"; -- 0.5 checkint := 2; divres := resize (check7uf1 / checkint, divres'high, divres'low); report_error ("uf/real", divres, to_ufixed (0.5/2.0, divres'high, divres'low)); divres := resize (checkint / check7uf1, divres'high, divres'low); report_error ("real/uf", divres, to_ufixed (2.0/0.5, divres'high, divres'low)); -- rem and mod check7uf1 := "0010000"; -- 2.0 checkreal := 5.0; check7uf1 := checkreal rem check7uf1; report_error ("REAL rem uf", check7uf1, to_ufixed (5 rem 2, check7uf1'high, check7uf1'low)); check7uf1 := "0101000"; -- 5.0 checkreal := 2.0; check7uf1 := check7uf1 rem checkreal; report_error ("REAL rem uf", check7uf1, to_ufixed (5 rem 2, check7uf1'high, check7uf1'low)); check7uf1 := "0010000"; -- 2.0 checkint := 5; check7uf1 := checkint rem check7uf1; report_error ("int rem uf", check7uf1, to_ufixed (5 rem 2, check7uf1'high, check7uf1'low)); check7uf1 := "0101000"; -- 5.0 checkint := 2; check7uf1 := check7uf1 rem checkint; report_error ("int rem uf", check7uf1, to_ufixed (5 rem 2, check7uf1'high, check7uf1'low)); check7uf1 := "0010000"; -- 2.0 checkreal := 5.0; check7uf1 := checkreal mod check7uf1; report_error ("REAL mod uf", check7uf1, to_ufixed (5 mod 2, check7uf1'high, check7uf1'low)); check7uf1 := "0101000"; -- 5.0 checkreal := 2.0; check7uf1 := check7uf1 mod checkreal; report_error ("REAL mod uf", check7uf1, to_ufixed (5 mod 2, check7uf1'high, check7uf1'low)); check7uf1 := "0010000"; -- 2.0 checkint := 5; check7uf1 := checkint mod check7uf1; report_error ("int mod uf", check7uf1, to_ufixed (5 mod 2, check7uf1'high, check7uf1'low)); check7uf1 := "0101000"; -- 5.0 checkint := 2; check7uf1 := check7uf1 mod checkint; report_error ("int mod uf", check7uf1, to_ufixed (5 mod 2, check7uf1'high, check7uf1'low)); -- now with signed fixed point numbers -- + and - check7sf1 := "0000100"; -- 0.5 checkint := 2; check7sf := check7sf1 + checkint; report_error ("sf+int", check7sf, to_sfixed (0.5+2.0, check7sf'high, check7sf'low)); check7sf := checkint + check7sf1; report_error ("int+sf", check7sf, to_sfixed (0.5+2.0, check7sf'high, check7sf'low)); check7sf1 := "0011100"; -- 3.5 checkint := 2; check7sf := check7sf1 - checkint; report_error ("sf-int", check7sf, to_sfixed (3.5-2.0, check7sf'high, check7sf'low)); checkint := 4; check7sf := checkint - check7sf1; report_error ("int-sf", check7sf, to_sfixed (4.0-3.5, check7sf'high, check7sf'low)); check7sf1 := "0000100"; -- 0.5 sf1 := "0"; -- 0 check7sf := check7sf1 + sf1; report_error (to_string (check7sf1) & " + " & to_string (sf1), check7sf, to_sfixed (0.5, check7sf)); check7sf1 := "0000100"; -- 0.5 sf1 := "1"; -- -1 check7sf := check7sf1 + sf1; report_error (to_string (check7sf1) & " + " & to_string (sf1), check7sf, to_sfixed (-0.5, check7sf)); check7sf1 := "0001100"; -- 1.5 sf1 := "1"; -- -1 check7sf := check7sf1 * sf1; report_error (to_string (check7sf1) & " + " & to_string (sf1), check7sf, to_sfixed (-1.5, check7sf)); check7sf1 := "0010100"; -- 2.5 sf2 := "01"; -- 1 check7sf := check7sf1 + sf2; report_error (to_string (check7sf1) & " + " & to_string (sf2), check7sf, to_sfixed (3.5, check7sf)); check7sf1 := "0010100"; -- 2.5 sf2 := "11"; -- -1 check7sf := check7sf1 + sf2; report_error (to_string (check7sf1) & " + " & to_string (sf2), check7sf, to_sfixed (1.5, check7sf)); check7sf1 := "0010100"; -- 2.5 sf2 := "10"; -- -2 check7sf := check7sf1 + sf2; report_error (to_string (check7sf1) & " + " & to_string (sf2), check7sf, to_sfixed (0.5, check7sf)); check7sf1 := "0010100"; -- 2.5 sf3 := "0"; -- 0 check7sf := check7sf1 + sf3; report_error (to_string (check7sf1) & " + " & to_string (sf3), check7sf, to_sfixed (2.5, check7sf)); check7sf1 := "0010100"; -- 2.5 sf3 := "1"; -- -0.5 check7sf := check7sf1 + sf3; report_error (to_string (check7sf1) & " + " & to_string (sf3), check7sf, to_sfixed (2, check7sf)); -- real number check7sf1 := "0000100"; -- 0.5 checkreal := 2.0; check7sf := check7sf1 + checkreal; report_error ("sf+real", check7sf, to_sfixed (0.5+2.0, check7sf'high, check7sf'low)); check7sf := checkreal + check7sf1; report_error ("real+sf", check7sf, to_sfixed (0.5+2.0, check7sf'high, check7sf'low)); check7sf1 := "0011100"; -- 3.5 checkreal := 2.0; check7sf := check7sf1 - checkreal; report_error ("sf-real", check7sf, to_sfixed (3.5-2.0, check7sf'high, check7sf'low)); checkreal := 4.0; check7sf := checkreal - check7sf1; report_error ("real+sf", check7sf, to_sfixed (4.0-3.5, check7sf'high, check7sf'low)); -- multiply check7sf1 := "0000100"; -- 0.5 checkreal := 2.0; smulres := check7sf1 * checkreal; report_error ("sf*real", smulres, to_sfixed (2.0*0.5, smulres'high, smulres'low)); smulres := checkreal * check7sf1; report_error ("real*sf", smulres, to_sfixed (2.0*0.5, smulres'high, smulres'low)); check7sf1 := "0000100"; -- 0.5 checkint := 2; smulres := resize (check7sf1 * checkint, smulres'high, smulres'low); report_error ("sf*int", smulres, to_sfixed (2.0*0.5, smulres'high, smulres'low)); smulres := resize (checkint * check7sf1, smulres'high, smulres'low); report_error ("int*sf", smulres, to_sfixed (2.0*0.5, smulres'high, smulres'low)); -- divide check7sf1 := "0000100"; -- 0.5 checkreal := 2.0; sdivres := check7sf1 / checkreal; report_error ("sf/real", sdivres, to_sfixed (0.5/2.0, sdivres'high, sdivres'low)); sdivres := checkreal / check7sf1; report_error ("real/sf", sdivres, to_sfixed (2.0/0.5, sdivres'high, sdivres'low)); check7sf1 := "0000100"; -- 0.5 checkint := 2; sdivres := resize (check7sf1 / checkint, sdivres'high, sdivres'low); report_error ("sf/real", sdivres, to_sfixed (0.5/2.0, sdivres'high, sdivres'low)); sdivres := resize (checkint / check7sf1, sdivres'high, sdivres'low); report_error ("real/sf", sdivres, to_sfixed (2.0/0.5, sdivres'high, sdivres'low)); -- rem and mod check7sf1 := "0010000"; -- 2.0 checkreal := 5.0; check7sf1 := checkreal rem check7sf1; report_error ("REAL rem sf", check7sf1, to_sfixed (5 rem 2, check7sf1'high, check7sf1'low)); check7sf1 := "0101000"; -- 5.0 checkreal := 2.0; check7sf1 := check7sf1 rem checkreal; report_error ("REAL rem sf", check7sf1, to_sfixed (5 rem 2, check7sf1'high, check7sf1'low)); check7sf1 := "0010000"; -- 2.0 checkint := 5; check7sf1 := checkint rem check7sf1; report_error ("int rem sf", check7sf1, to_sfixed (5 rem 2, check7sf1'high, check7sf1'low)); check7sf1 := "0101000"; -- 5.0 checkint := 2; check7sf1 := resize (check7sf1 rem checkint, check7sf1'high, check7sf1'low); report_error ("int rem sf", check7sf1, to_sfixed (5 rem 2, check7sf1'high, check7sf1'low)); check7sf1 := "0010000"; -- 2.0 checkreal := 5.0; check7sf1 := checkreal mod check7sf1; report_error ("REAL mod sf", check7sf1, to_sfixed (5 mod 2, check7sf1'high, check7sf1'low)); check7sf1 := "0101000"; -- 5.0 checkreal := 2.0; check7sf1 := check7sf1 mod checkreal; report_error ("REAL mod sf", check7sf1, to_sfixed (5 mod 2, check7sf1'high, check7sf1'low)); check7sf1 := "0010000"; -- 2.0 checkint := 5; check7sf1 := checkint mod check7sf1; report_error ("int mod sf", check7sf1, to_sfixed (5 mod 2, check7sf1'high, check7sf1'low)); check7sf1 := "0101000"; -- 5.0 checkint := 2; check7sf1 := check7sf1 mod checkint; report_error ("int mod sf", check7sf1, to_sfixed (5 mod 2, check7sf1'high, check7sf1'low)); -- Operations that mix ufixed and sfixed check7uf1 := "1111000"; -- 15.0 check7sf1 := "0111000"; -- +7.0 check7sfx := to_sfixed(check7uf1) + check7sf1; -- size check bigs := resize (check7sfx, bigs'high, bigs'low); report_error ("ufixed + sfixed", bigs, to_sfixed (22, bigs'high, bigs'low)); check7sfx := check7sf1 + to_sfixed(check7uf1); bigs := resize (check7sfx, bigs'high, bigs'low); report_error ("sfixed + ufixed", bigs, to_sfixed (22, bigs'high, bigs'low)); -- Subtract check7uf1 := "1111000"; -- 15.0 check7sf1 := "1000000"; -- -8.0 check7sfx := to_sfixed(check7uf1) - check7sf1; -- size check bigs := resize (check7sfx, bigs'high, bigs'low); report_error ("ufixed - sfixed", bigs, to_sfixed (23, bigs'high, bigs'low)); check7sfx := check7sf1 - to_sfixed(check7uf1); -- size check bigs := resize (check7sfx, bigs'high, bigs'low); report_error ("ufixed - sfixed", bigs, to_sfixed (-23, bigs'high, bigs'low)); check7uf1 := "1111111"; -- 15.875 check7uf2 := "0000000"; -- 0.0 check7sfx := to_sfixed(check7uf2) - to_sfixed(check7uf1); bigs := resize (check7sfx, bigs'high, bigs'low); report_error ("ufixed - ufixed return sfixed", bigs, to_sfixed (-15.875, bigs'high, bigs'low)); -- Multiply check7uf1 := "1111111"; -- 15.875 check7sf1 := "1000000"; -- -8.0 smulresx := to_sfixed(check7uf1) * check7sf1; bigs := resize (smulresx, bigs'high, bigs'low); report_error ("ufixed * sfixed", bigs, to_sfixed (-127, bigs'high, bigs'low)); smulresx := check7sf1 * to_sfixed(check7uf1); bigs := resize (smulresx, bigs'high, bigs'low); report_error ("sfixed * ufixed", bigs, to_sfixed (-127, bigs'high, bigs'low)); check7uf1 := "1111111"; -- 15.875 check7sf1 := "0111111"; -- 7.875 smulresx := to_sfixed(check7uf1) * check7sf1; bigs := resize (smulresx, bigs'high, bigs'low); report_error ("ufixed * sfixed pos", bigs, to_sfixed ((15.875 * 7.875), bigs'high, bigs'low)); smulresx := check7sf1 * to_sfixed(check7uf1); bigs := resize (smulresx, bigs'high, bigs'low); report_error ("sfixed * ufixed pos", bigs, to_sfixed ((15.875 * 7.875), bigs'high, bigs'low)); -- divide check7uf1 := "0000001"; -- 0.125 check7sf1 := "0111111"; -- 7.875 sdivresx := check7sf1 / to_sfixed(check7uf1); bigs := resize (sdivresx, bigs'high, bigs'low); report_error ("sfixed / ufixed overflow", bigs, to_sfixed ((7.875/0.125), bigs'high, bigs'low)); check7uf1 := "0000001"; -- 0.125 check7sf1 := "1000000"; -- -8 sdivresx := check7sf1 / to_sfixed(check7uf1); bigs := resize (sdivresx, bigs'high, bigs'low); report_error ("sfixed / ufixed -overflow", bigs, to_sfixed (((-8.0)/0.125), bigs'high, bigs'low)); -- underflow check7uf1 := "1111111"; -- 15.875 check7sf1 := "0000001"; -- 0.125 sdivresx := check7sf1 / to_sfixed(check7uf1); bigs := resize (sdivresx, bigs'high, bigs'low); report_error ("sfixed / ufixed underflow", bigs, to_sfixed ((0.125/15.875), bigs'high, bigs'low)); -- -underflow bigs := to_sfixed (((-0.125)/15.875), bigs'high, bigs'low); sdivresx := resize (bigs, sdivresx'high, sdivresx'low); assert (-0.0078125 = to_real(bigs)) report "-underflow conversion error to_real(" & to_string(sdivresx) & ") = " & REAL'image(to_real(bigs)) & " not -0.0078125" severity error; check7sf := "01111111"; -- 15.875 check7sf1 := "1111111"; -- -0.125 sdivresx := check7sf1 / check7sf; bigs := resize (sdivresx, bigs'high, bigs'low); report_error ("sfixed / sfixed -underflow", bigs, to_sfixed (((-0.125)/15.875), bigs'high, bigs'low)); check7uf1 := "1111111"; -- 15.875 -- report to_string(check7uf1) & " = " & REAL'image(to_real(check7uf1)) -- severity note; check7sf1 := "1111111"; -- -0.125 -- report to_string(check7sf1) & " = " & REAL'image(to_real(check7sf1)) -- severity note; sdivresx := check7sf1 / to_sfixed(check7uf1); bigs := resize (sdivresx, bigs'high, bigs'low); report_error ("sfixed / ufixed -underflow", bigs, to_sfixed (((-0.125)/15.875), bigs'high, bigs'low)); check7uf1 := "1111111"; -- 15.875 check7sf1 := "0000001"; -- 0.125 sdivresx2 := to_sfixed(check7uf1) / check7sf1; bigs := resize (sdivresx2, bigs'high, bigs'low); report_error ("ufixed / sfixed overflow", bigs, to_sfixed ((15.875/0.125), bigs'high, bigs'low)); check7uf1 := "1111111"; -- 15.875 check7sf1 := "1111111"; -- -0.125 sdivresx2 := to_sfixed(check7uf1) / check7sf1; bigs := resize (sdivresx2, bigs'high, bigs'low); report_error ("ufixed / sfixed -overflow", bigs, to_sfixed ((15.875/(-0.125)), bigs'high, bigs'low)); -- underflow check7uf1 := "0000001"; -- 0.125 check7sf1 := "0111111"; -- 7.825 sdivresx2 := to_sfixed(check7uf1) / check7sf1; bigs := resize (sdivresx2, bigs'high, bigs'low); report_error ("ufixed / sfixed underflow", bigs, to_sfixed ((0.125/7.825), bigs'high, bigs'low)); sdivresx2 := divide (to_sfixed(check7uf1), check7sf1); report_error ("divide (ufixed, sfixed) underflow", sdivresx2, to_sfixed ((0.125/7.825), bigs'high, bigs'low)); check7uf1 := "0000001"; -- 0.125 check7sf1 := "1000000"; -- -8 sdivresx2 := to_sfixed(check7uf1) / check7sf1; bigs := resize (sdivresx2, bigs'high, bigs'low); report_error ("ufixed / sfixed -underflow", bigs, to_sfixed ((0.125/(-8.0)), bigs'high, bigs'low)); sdivresx2 := divide (to_sfixed(check7uf1), check7sf1); report_error ("divide (ufixed, sfixed) -underflow", sdivresx2, to_sfixed ((0.125/(-8.0)), bigs'high, bigs'low)); -- remainder check7uf1 := "1111000"; -- 15 check7sf1 := "0111000"; -- 7 check7sf2 := to_sfixed(check7uf1) rem check7sf1; bigs := resize (