git-svn-id: http://moon:8086/svn/vhdl/trunk@1329 cc03376c-175c-47c8-b038-4cd826a8556b
1034 lines
62 KiB
VHDL
1034 lines
62 KiB
VHDL
----------------------------------------------------------------------------------
|
|
-- Company:
|
|
-- Engineer:
|
|
--
|
|
-- Create Date: 00:28:57 07/10/2006
|
|
-- Design Name:
|
|
-- Module Name: tb_eval_fixed_ja - Behavioral
|
|
-- Project Name:
|
|
-- Target Devices:
|
|
-- Tool versions:
|
|
-- Description:
|
|
--
|
|
-- Dependencies:
|
|
--
|
|
-- Revision:
|
|
-- Revision 0.01 - File Created
|
|
-- Additional Comments:
|
|
--
|
|
----------------------------------------------------------------------------------
|
|
library IEEE;
|
|
|
|
USE ieee.std_logic_1164.ALL;
|
|
USE ieee.numeric_std.ALL;
|
|
use IEEE.MATH_REAL.ALL;
|
|
use std.textio.all; -- Imports the standard textio package.
|
|
|
|
library work;
|
|
use work.fixed_ja.all;
|
|
use work.PCK_FIO.all;
|
|
|
|
---- Uncomment the following library declaration if instantiating
|
|
---- any Xilinx primitives in this code.
|
|
--library UNISIM;
|
|
--use UNISIM.VComponents.all;
|
|
|
|
entity tb_eval_fixed_ja is
|
|
Generic (
|
|
nbits : integer := 32;
|
|
nbits_int : integer := 2;
|
|
halt_on_error : boolean := true);
|
|
|
|
end tb_eval_fixed_ja;
|
|
|
|
architecture Behavioral of tb_eval_fixed_ja is
|
|
---------------------------------------------------------------------
|
|
|
|
type my_range is range 0 downto -10;
|
|
|
|
---------------------------------------------------------------------
|
|
procedure PerformRoundTest (op1 : in ufixed_t; required : in ufixed_t; rnd : in round_mode_t; sat : in saturate_mode_t) is
|
|
variable result : ufixed_t(required'range);
|
|
variable bad_result : boolean := false;
|
|
|
|
variable L : line;
|
|
begin
|
|
|
|
result := to_ufixed(op1, required, rnd, sat);
|
|
bad_result := not(result = required);
|
|
|
|
write (L, "U: " & to_string(op1) & " => " & to_string(result));
|
|
|
|
if bad_result then
|
|
write (L, String'(" ...failed"));
|
|
writeline (output, L);
|
|
writeline (output, L);
|
|
write (L, String'("Bad result. Should be:") & CR & LF);
|
|
write (L, to_string(op1) & " => " & to_string(required));
|
|
writeline (output, L);
|
|
writeline (output, L);
|
|
else
|
|
write (L, String'(" ...passed"));
|
|
writeline (output, L);
|
|
end if;
|
|
|
|
assert not (bad_result and halt_on_error) report "Test failed" severity error;
|
|
|
|
end PerformRoundTest;
|
|
|
|
---------------------------------------------------------------------
|
|
procedure PerformRoundTest (op1 : in sfixed_t; required : in sfixed_t; rnd : in round_mode_t; sat : in saturate_mode_t) is
|
|
variable result : sfixed_t(required'range);
|
|
variable bad_result : boolean := false;
|
|
|
|
variable L : line;
|
|
begin
|
|
|
|
result := to_sfixed(op1, required, rnd, sat);
|
|
bad_result := not(result = required);
|
|
|
|
write (L, "S: " & to_string(op1) & " => " & to_string(result));
|
|
|
|
if bad_result then
|
|
write (L, String'(" ...failed"));
|
|
writeline (output, L);
|
|
writeline (output, L);
|
|
write (L, String'("Bad result. Should be:") & CR & LF);
|
|
write (L, to_string(op1) & " => " & to_string(required));
|
|
writeline (output, L);
|
|
writeline (output, L);
|
|
else
|
|
write (L, String'(" ...passed"));
|
|
writeline (output, L);
|
|
end if;
|
|
|
|
assert not (bad_result and halt_on_error) report "Test failed" severity error;
|
|
|
|
end PerformRoundTest;
|
|
|
|
---------------------------------------------------------------------
|
|
procedure PerformArithTest (op1 : in ufixed_t; op : in character; op2 : in ufixed_t; required : in ufixed_t) is
|
|
variable result : ufixed_t(required'range);
|
|
variable bad_result : boolean := false;
|
|
|
|
variable L : line;
|
|
begin
|
|
|
|
case op is
|
|
when '+' =>
|
|
result := op1 + op2;
|
|
|
|
when '-' =>
|
|
result := op1 - op2;
|
|
|
|
when '*' =>
|
|
result := op1 * op2;
|
|
|
|
when others =>
|
|
assert false report "PerformArithTest: Bad operand" severity error;
|
|
|
|
end case;
|
|
|
|
bad_result := not(result = required);
|
|
|
|
write (L, "U: " & to_string(op1) & " " & op & " " & to_string(op2) & " = " & to_string(result));
|
|
|
|
if bad_result then
|
|
write (L, String'(" ...failed"));
|
|
writeline (output, L);
|
|
writeline (output, L);
|
|
write (L, String'("Bad result. Should be:") & CR & LF);
|
|
write (L, to_string(op1) & " " & op & " " & to_string(op2) & " = " & to_string(required));
|
|
writeline (output, L);
|
|
writeline (output, L);
|
|
else
|
|
write (L, String'(" ...passed"));
|
|
writeline (output, L);
|
|
end if;
|
|
|
|
assert not (bad_result and halt_on_error) report "Test failed" severity error;
|
|
|
|
end PerformArithTest;
|
|
|
|
---------------------------------------------------------------------
|
|
procedure PerformArithTest (op1 : in sfixed_t; op : in character; op2 : in sfixed_t; required : in sfixed_t) is
|
|
variable result : sfixed_t(required'range);
|
|
variable bad_result : boolean := false;
|
|
|
|
variable L : line;
|
|
begin
|
|
|
|
case op is
|
|
when '+' =>
|
|
result := op1 + op2;
|
|
|
|
when '-' =>
|
|
result := op1 - op2;
|
|
|
|
when '*' =>
|
|
result := op1 * op2;
|
|
|
|
when others =>
|
|
assert false report "PerformArithTest: Bad operand" severity error;
|
|
|
|
end case;
|
|
|
|
bad_result := not(result = required);
|
|
|
|
write (L, "S: " & to_string(op1) & " " & op & " " & to_string(op2) & " = " & to_string(result));
|
|
|
|
if bad_result then
|
|
write (L, String'(" ...failed"));
|
|
writeline (output, L);
|
|
writeline (output, L);
|
|
write (L, String'("Bad result. Should be:") & CR & LF);
|
|
write (L, to_string(op1) & " " & op & " " & to_string(op2) & " = " & to_string(required));
|
|
writeline (output, L);
|
|
writeline (output, L);
|
|
else
|
|
write (L, String'(" ...passed"));
|
|
writeline (output, L);
|
|
end if;
|
|
|
|
assert not (bad_result and halt_on_error) report "Test failed" severity error;
|
|
|
|
end PerformArithTest;
|
|
|
|
---------------------------------------------------------------------
|
|
begin
|
|
|
|
process
|
|
|
|
variable rnd : round_mode_t := none;
|
|
variable sat : saturate_mode_t := none;
|
|
file RESULT: text open write_mode is "STD_OUTPUT";
|
|
file file_sum_test_u: text open write_mode is "sum_test_u.txt";
|
|
file file_sum_test_s: text open write_mode is "sum_test_s.txt";
|
|
variable L, STR: line;
|
|
constant uconst0 : ufixed_t := to_ufixed(string'("1.000"));
|
|
constant sconst0 : sfixed_t := to_sfixed(string'("1.000"));
|
|
constant uconst1 : ufixed_t := to_ufixed(string'("1.001"));
|
|
constant sconst1 : sfixed_t := to_sfixed(string'("1.001"));
|
|
constant s1 : sfixed_t := to_sfixed(string'("0111101010101.01100010110111010011100101101101011111010101101000110100101010101010111011010000111011000110000101000001010010100111"));
|
|
constant s2 : sfixed_t := to_sfixed(string'("0010110111011.11100001100111000100101000110101111111101101000100001110010011100111000110110110010100101001010010100111100011000010"));
|
|
variable r1 : sfixed_t(sproto(s1, '*', s2)'range);
|
|
variable ures : ufixed_t(uconst0'range);
|
|
variable sres : sfixed_t(sconst0'range);
|
|
constant incu : ufixed_t := to_ufixed(string'(".0000001"));
|
|
variable yu : ufixed_t(uproto(4,0)'range);
|
|
variable xu : ufixed_t(uproto(8,1)'range);
|
|
constant incs : sfixed_t := to_sfixed(string'(".0000001"));
|
|
variable ys : sfixed_t(sproto(5,0)'range);
|
|
variable xs : sfixed_t(sproto(9,1)'range);
|
|
begin
|
|
|
|
-- slv := (1 => '1', 2 => 'J', jens'range => jens(jens'range), others => '1');
|
|
|
|
rnd := round_nearest;
|
|
sat := saturate;
|
|
|
|
-- 1.) Sum test
|
|
xu := to_ufixed(0, xu);
|
|
for i in 0 to 2**xu'length-1 loop
|
|
yu := to_ufixed(xu, yu, rnd, sat);
|
|
fprint(file_sum_test_u, L,"%s %s\n", REAL'image(to_real(xu)), REAL'image(to_real(yu)));
|
|
-- fprint(file_sum_test_u, L,"%s %s\n", to_string(xu), to_string(yu));
|
|
xu := xu + 1;
|
|
end loop;
|
|
xs := to_sfixed(-(2**(xs'length-1)-1), xs);
|
|
for i in 0 to 2**xs'length-1 loop
|
|
ys := to_sfixed(xs, ys, rnd, sat);
|
|
fprint(file_sum_test_s, L,"%s %s\n", REAL'image(to_real(xs)), REAL'image(to_real(ys)));
|
|
-- fprint(file_sum_test_s, L,"%s %s\n", to_string(xs), to_string(ys));
|
|
xs := xs + 1;
|
|
end loop;
|
|
|
|
write (L, String'("Fixed Point Library Testbench 0.1"));
|
|
writeline (output, L);
|
|
|
|
write (L, String'("----------------------" & CR & LF));
|
|
write (L, String'(" Without saturation " & CR & LF));
|
|
write (L, String'("----------------------" & CR & LF));
|
|
writeline (output, L);
|
|
|
|
---------------------------------------------------------------------
|
|
write (L, String'("* No rounding" & CR & LF));
|
|
writeline (output, L);
|
|
|
|
rnd := none;
|
|
sat := none;
|
|
|
|
PerformRoundTest (to_ufixed(string'("101.0011")), to_ufixed(string'("01.0011")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1.001101")), to_ufixed(string'("001.")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("101.01")), to_ufixed(string'("1.0")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1010.1")), to_ufixed(string'("10.")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("101.11")), to_ufixed(string'("101.")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'(".11")), to_ufixed(string'("0.")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'(".1011")), to_ufixed(string'("0.10")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("0.0000000001")), to_ufixed(string'("0.")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1.0000000001")), to_ufixed(string'("1.0")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1.0000000001")), to_ufixed(string'("1.")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("10.000000001")), to_ufixed(string'("10.000")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1.")), to_ufixed(string'("1.00000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("0.")), to_ufixed(string'("0.00000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1.")), to_ufixed(string'(".000000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("0.")), to_ufixed(string'(".000000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("10.101")), to_ufixed(string'("010.1010")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("10.101")), to_ufixed(string'("10.10")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("10.101")), to_ufixed(string'("10.1010")), rnd, sat);
|
|
|
|
PerformRoundTest (to_sfixed(string'("101.0011")), to_sfixed(string'("01.0011")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-1.001101")), to_sfixed(string'("-001.")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-101.01")), to_sfixed(string'("-1.0")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("1010.1")), to_sfixed(string'("10.")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("101.11")), to_sfixed(string'("101.")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-.11")), to_sfixed(string'("0.")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-.1011")), to_sfixed(string'("-0.10")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("0.0000000001")), to_sfixed(string'("0.")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-1.0000000001")), to_sfixed(string'("-1.0")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-1.0000000001")), to_sfixed(string'("-1.")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-10.000000001")), to_sfixed(string'("-10.000")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("1.")), to_sfixed(string'("1.00000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("0.")), to_sfixed(string'("0.00000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("1.")), to_sfixed(string'(".000000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("0.")), to_sfixed(string'(".000000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("10.101")), to_sfixed(string'("010.1010")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-10.101")), to_sfixed(string'("-10.10")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("10.101")), to_sfixed(string'("10.1010")), rnd, sat);
|
|
|
|
---------------------------------------------------------------------
|
|
writeline (output, L);
|
|
write (L, String'("* Round to zero" & CR & LF));
|
|
writeline (output, L);
|
|
|
|
rnd := round_to_zero;
|
|
sat := none;
|
|
|
|
PerformRoundTest (to_ufixed(string'("101.0011")), to_ufixed(string'("01.0011")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1.001101")), to_ufixed(string'("001.")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("101.01")), to_ufixed(string'("1.0")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1010.1")), to_ufixed(string'("10.")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("101.11")), to_ufixed(string'("101.")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'(".11")), to_ufixed(string'("0.")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'(".1011")), to_ufixed(string'("0.10")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("0.0000000001")), to_ufixed(string'("0.")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1.0000000001")), to_ufixed(string'("1.0")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1.0000000001")), to_ufixed(string'("1.")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("10.000000001")), to_ufixed(string'("10.000")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1.")), to_ufixed(string'("1.00000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("0.")), to_ufixed(string'("0.00000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1.")), to_ufixed(string'(".000000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("0.")), to_ufixed(string'(".000000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("10.101")), to_ufixed(string'("010.1010")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("10.101")), to_ufixed(string'("10.10")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("10.101")), to_ufixed(string'("10.1010")), rnd, sat);
|
|
|
|
PerformRoundTest (to_sfixed(string'("101.0011")), to_sfixed(string'("01.0011")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-1.001101")), to_sfixed(string'("-001.")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-101.01")), to_sfixed(string'("-1.0")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("1010.1")), to_sfixed(string'("10.")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("101.11")), to_sfixed(string'("101.")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-.11")), to_sfixed(string'("0.")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-.1011")), to_sfixed(string'("-0.10")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("0.0000000001")), to_sfixed(string'("0.")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-1.0000000001")), to_sfixed(string'("-1.0")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-1.0000000001")), to_sfixed(string'("-1.")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-10.000000001")), to_sfixed(string'("-10.000")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("1.")), to_sfixed(string'("1.00000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("0.")), to_sfixed(string'("0.00000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("1.")), to_sfixed(string'(".000000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("0.")), to_sfixed(string'(".000000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("10.101")), to_sfixed(string'("010.1010")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-10.101")), to_sfixed(string'("-10.10")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("10.101")), to_sfixed(string'("10.1010")), rnd, sat);
|
|
|
|
---------------------------------------------------------------------
|
|
|
|
writeline (output, L);
|
|
write (L, String'("* Round to infinity" & CR & LF));
|
|
writeline (output, L);
|
|
|
|
rnd := round_pos_infinity;
|
|
sat := none;
|
|
|
|
PerformRoundTest (to_ufixed(string'("101.0011")), to_ufixed(string'("01.0011")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1.001101")), to_ufixed(string'("010.")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("101.01")), to_ufixed(string'("1.1")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1010.1")), to_ufixed(string'("11.")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("101.11")), to_ufixed(string'("110.")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'(".11")), to_ufixed(string'("1.")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'(".1011")), to_ufixed(string'("0.11")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("0.0000000001")), to_ufixed(string'("1.")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1.0000000001")), to_ufixed(string'("1.1")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1.0000000001")), to_ufixed(string'("0.")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("10.000000001")), to_ufixed(string'("10.001")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1.")), to_ufixed(string'("1.00000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("0.")), to_ufixed(string'("0.00000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1.")), to_ufixed(string'(".000000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("0.")), to_ufixed(string'(".000000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("10.101")), to_ufixed(string'("010.1010")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("10.101")), to_ufixed(string'("10.11")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("10.101")), to_ufixed(string'("10.1010")), rnd, sat);
|
|
|
|
PerformRoundTest (to_sfixed(string'("101.0011")), to_sfixed(string'("01.0011")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-10.001101")), to_sfixed(string'("-010.")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-101.01")), to_sfixed(string'("-1.0")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("1010.1")), to_sfixed(string'("11.")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("101.11")), to_sfixed(string'("110.")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-.11")), to_sfixed(string'("0.")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-.1011")), to_sfixed(string'("-0.10")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("0.0000000001")), to_sfixed(string'("1.")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-1.0000000001")), to_sfixed(string'("-1.0")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("1.0000000001")), to_sfixed(string'("0.")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-10.000000001")), to_sfixed(string'("-10.000")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("1.")), to_sfixed(string'("1.00000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("0.")), to_sfixed(string'("0.00000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("1.")), to_sfixed(string'(".000000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("0.")), to_sfixed(string'(".000000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("10.101")), to_sfixed(string'("010.1010")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-10.101")), to_sfixed(string'("-10.10")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("10.101")), to_sfixed(string'("10.1010")), rnd, sat);
|
|
|
|
---------------------------------------------------------------------
|
|
writeline (output, L);
|
|
write (L, String'("* Round half up" & CR & LF));
|
|
writeline (output, L);
|
|
|
|
rnd := round_half_up;
|
|
sat := none;
|
|
|
|
PerformRoundTest (to_ufixed(string'("101.0011")), to_ufixed(string'("01.0011")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1.001101")), to_ufixed(string'("001.")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("101.01")), to_ufixed(string'("1.1")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1010.1")), to_ufixed(string'("11.")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("101.11")), to_ufixed(string'("110.")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'(".11")), to_ufixed(string'("1.")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'(".1011")), to_ufixed(string'("0.11")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("0.0000000001")), to_ufixed(string'("0.")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1.0000000001")), to_ufixed(string'("1.0")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1.0000000001")), to_ufixed(string'("1.")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("10.000000001")), to_ufixed(string'("10.000")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1.")), to_ufixed(string'("1.00000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("0.")), to_ufixed(string'("0.00000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1.")), to_ufixed(string'(".000000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("0.")), to_ufixed(string'(".000000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("10.101")), to_ufixed(string'("010.1010")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("10.101")), to_ufixed(string'("10.11")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("10.101")), to_ufixed(string'("10.1010")), rnd, sat);
|
|
|
|
PerformRoundTest (to_sfixed(string'("101.0011")), to_sfixed(string'("01.0011")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-10.001101")), to_sfixed(string'("-010.")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-101.01")), to_sfixed(string'("-1.0")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("1010.1")), to_sfixed(string'("11.")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("101.11")), to_sfixed(string'("110.")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-.11")), to_sfixed(string'("-1.")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-.1011")), to_sfixed(string'("-0.11")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("0.0000000001")), to_sfixed(string'("0.")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-1.0000000001")), to_sfixed(string'("-1.0")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("1.0000000001")), to_sfixed(string'("1.")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-10.000000001")), to_sfixed(string'("-10.000")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("1.")), to_sfixed(string'("1.00000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("0.")), to_sfixed(string'("0.00000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("1.")), to_sfixed(string'(".000000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("0.")), to_sfixed(string'(".000000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("10.101")), to_sfixed(string'("010.1010")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-10.1011")), to_sfixed(string'("-10.11")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-10.101")), to_sfixed(string'("-10.10")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-0.1111")), to_sfixed(string'("-0.111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-0.11110")), to_sfixed(string'("-0.111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-0.11111")), to_sfixed(string'("-1.000")), rnd, sat);
|
|
|
|
---------------------------------------------------------------------
|
|
writeline (output, L);
|
|
write (L, String'("* Round convergent" & CR & LF));
|
|
writeline (output, L);
|
|
|
|
rnd := round_convergent;
|
|
sat := none;
|
|
|
|
PerformRoundTest (to_ufixed(string'("01.001")), to_ufixed(string'("01.00")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("01.0010")), to_ufixed(string'("01.00")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("01.0011")), to_ufixed(string'("01.01")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("01.011")), to_ufixed(string'("01.10")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("01.0110")), to_ufixed(string'("01.10")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("01.0111")), to_ufixed(string'("01.10")), rnd, sat);
|
|
|
|
PerformRoundTest (to_sfixed(string'("01.001")), to_sfixed(string'("01.00")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("01.0010")), to_sfixed(string'("01.00")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("01.0011")), to_sfixed(string'("01.01")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("01.011")), to_sfixed(string'("01.10")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("01.0110")), to_sfixed(string'("01.10")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("01.0111")), to_sfixed(string'("01.10")), rnd, sat);
|
|
|
|
PerformRoundTest (to_sfixed(string'("-01.001")), to_sfixed(string'("-01.00")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-01.0010")), to_sfixed(string'("-01.00")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-01.0011")), to_sfixed(string'("-01.01")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-01.011")), to_sfixed(string'("-01.10")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-01.0110")), to_sfixed(string'("-01.10")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-01.0111")), to_sfixed(string'("-01.10")), rnd, sat);
|
|
|
|
---------------------------------------------------------------------
|
|
|
|
writeline (output, L);
|
|
write (L, String'("----------------------" & CR & LF));
|
|
write (L, String'(" With saturation " & CR & LF));
|
|
write (L, String'("----------------------" & CR & LF));
|
|
writeline (output, L);
|
|
|
|
write (L, String'("* No rounding" & CR & LF));
|
|
writeline (output, L);
|
|
|
|
rnd := none;
|
|
sat := saturate;
|
|
|
|
PerformRoundTest (to_ufixed(string'("101.0011")), to_ufixed(string'("11.1111")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1.001101")), to_ufixed(string'("001.")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("101.01")), to_ufixed(string'("1.1")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1010.1")), to_ufixed(string'("11.")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("101.11")), to_ufixed(string'("101.")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'(".11")), to_ufixed(string'("0.")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'(".1011")), to_ufixed(string'("0.10")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("0.0000000001")), to_ufixed(string'("0.")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1.0000000001")), to_ufixed(string'("1.0")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1.0000000001")), to_ufixed(string'("1.")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("10.000000001")), to_ufixed(string'("10.000")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1.")), to_ufixed(string'("1.00000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("0.")), to_ufixed(string'("0.00000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1.")), to_ufixed(string'(".111111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("0.")), to_ufixed(string'(".000000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("10.101")), to_ufixed(string'("010.1010")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("10.101")), to_ufixed(string'("10.10")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("10.101")), to_ufixed(string'("10.1010")), rnd, sat);
|
|
|
|
PerformRoundTest (to_ufixed(string'("1.0000")), to_ufixed(string'(".11111")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("01.000")), to_ufixed(string'(".11111")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("11.000")), to_ufixed(string'(".11111")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("0.1000")), to_ufixed(string'(".10000")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("00.100")), to_ufixed(string'(".10000")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1.0001")), to_ufixed(string'(".11111")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("01.001")), to_ufixed(string'(".11111")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("01.010")), to_ufixed(string'(".11111")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("11.001")), to_ufixed(string'(".11111")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("0.1001")), to_ufixed(string'(".10010")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("00.101")), to_ufixed(string'(".10100")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1.000000000000000001")), to_ufixed(string'(".111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("01.00000000000000001")), to_ufixed(string'(".111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1.00000000000000")), to_ufixed(string'(".111111111111111")), rnd, sat);
|
|
|
|
|
|
PerformRoundTest (to_sfixed(string'("-101.0011")), to_sfixed(string'("-11.1111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("1.001101")), to_sfixed(string'("001.")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("101.01")), to_sfixed(string'("1.1")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("1010.1")), to_sfixed(string'("11.")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("101.11")), to_sfixed(string'("101.")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'(".11")), to_sfixed(string'("0.")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'(".1011")), to_sfixed(string'("0.10")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-0.0000000001")), to_sfixed(string'("0.")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-1.0000000001")), to_sfixed(string'("-1.0")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("1.0000000001")), to_sfixed(string'("1.")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("10.000000001")), to_sfixed(string'("10.000")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("1.")), to_sfixed(string'("1.00000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("0.")), to_sfixed(string'("0.00000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-1.")), to_sfixed(string'("-.111111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-0.")), to_sfixed(string'(".000000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-10.101")), to_sfixed(string'("-010.1010")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-10.101")), to_sfixed(string'("-10.10")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-10.101")), to_sfixed(string'("-10.1010")), rnd, sat);
|
|
|
|
PerformRoundTest (to_sfixed(string'("-1.0000")), to_sfixed(string'("-.11111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-01.000")), to_sfixed(string'("-.11111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-11.000")), to_sfixed(string'("-.11111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-0.1000")), to_sfixed(string'("-.10000")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-00.100")), to_sfixed(string'("-.10000")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-1.0001")), to_sfixed(string'("-.11111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-01.001")), to_sfixed(string'("-.11111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-01.010")), to_sfixed(string'("-.11111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-11.001")), to_sfixed(string'("-.11111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-0.1001")), to_sfixed(string'("-.10010")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-00.101")), to_sfixed(string'("-.10100")), rnd, sat);
|
|
|
|
PerformRoundTest (to_sfixed(string'("-1.000000000000000001")), to_sfixed(string'("-.111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-01.00000000000000001")), to_sfixed(string'("-.111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-1.00000000000000")), to_sfixed(string'("-.111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("1.000000000000000001")), to_sfixed(string'(".111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("01.00000000000000001")), to_sfixed(string'(".111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("1.00000000000000")), to_sfixed(string'(".111111111111111")), rnd, sat);
|
|
|
|
PerformRoundTest (to_sfixed(string'("1.0000")), to_sfixed(string'(".11111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("01.000")), to_sfixed(string'(".11111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("0.1000")), to_sfixed(string'(".10000")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("00.100")), to_sfixed(string'(".10000")), rnd, sat);
|
|
|
|
|
|
---------------------------------------------------------------------
|
|
|
|
writeline (output, L);
|
|
write (L, String'("* Round to zero" & CR & LF));
|
|
writeline (output, L);
|
|
|
|
rnd := round_to_zero;
|
|
sat := saturate;
|
|
|
|
PerformRoundTest (to_ufixed(string'("101.0011")), to_ufixed(string'("11.1111")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1.001101")), to_ufixed(string'("001.")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("101.01")), to_ufixed(string'("1.1")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1010.1")), to_ufixed(string'("11.")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("101.11")), to_ufixed(string'("101.")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'(".11")), to_ufixed(string'("0.")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'(".1011")), to_ufixed(string'("0.10")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("0.0000000001")), to_ufixed(string'("0.")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1.0000000001")), to_ufixed(string'("1.0")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1.0000000001")), to_ufixed(string'("1.")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("10.000000001")), to_ufixed(string'("10.000")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1.")), to_ufixed(string'("1.00000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("0.")), to_ufixed(string'("0.00000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1.")), to_ufixed(string'(".111111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("0.")), to_ufixed(string'(".000000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("10.101")), to_ufixed(string'("010.1010")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("10.101")), to_ufixed(string'("10.10")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("10.101")), to_ufixed(string'("10.1010")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1.000000000000000001")), to_ufixed(string'(".111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("01.00000000000000001")), to_ufixed(string'(".111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1.00000000000000")), to_ufixed(string'(".111111111111111")), rnd, sat);
|
|
|
|
PerformRoundTest (to_sfixed(string'("101.0011")), to_sfixed(string'("11.1111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("1.001101")), to_sfixed(string'("001.")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("101.01")), to_sfixed(string'("1.1")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("1010.1")), to_sfixed(string'("11.")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("101.11")), to_sfixed(string'("101.")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'(".11")), to_sfixed(string'("0.")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'(".1011")), to_sfixed(string'("0.10")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("0.0000000001")), to_sfixed(string'("0.")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("1.0000000001")), to_sfixed(string'("1.0")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("1.0000000001")), to_sfixed(string'("1.")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("10.000000001")), to_sfixed(string'("10.000")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("1.")), to_sfixed(string'("1.00000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("0.")), to_sfixed(string'("0.00000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("1.")), to_sfixed(string'(".111111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("0.")), to_sfixed(string'(".000000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("10.101")), to_sfixed(string'("010.1010")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("10.101")), to_sfixed(string'("10.10")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("10.101")), to_sfixed(string'("10.1010")), rnd, sat);
|
|
|
|
PerformRoundTest (to_sfixed(string'("-1.000000000000000001")), to_sfixed(string'("-.111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-01.00000000000000001")), to_sfixed(string'("-.111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-1.00000000000000")), to_sfixed(string'("-.111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("1.000000000000000001")), to_sfixed(string'(".111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("01.00000000000000001")), to_sfixed(string'(".111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("1.00000000000000")), to_sfixed(string'(".111111111111111")), rnd, sat);
|
|
|
|
PerformRoundTest (to_sfixed(string'("1.0000")), to_sfixed(string'(".11111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("01.000")), to_sfixed(string'(".11111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("0.1000")), to_sfixed(string'(".10000")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("00.100")), to_sfixed(string'(".10000")), rnd, sat);
|
|
|
|
---------------------------------------------------------------------
|
|
|
|
writeline (output, L);
|
|
write (L, String'("* Round to infinity" & CR & LF));
|
|
writeline (output, L);
|
|
|
|
rnd := round_pos_infinity;
|
|
sat := saturate;
|
|
|
|
PerformRoundTest (to_ufixed(string'("101.0011")), to_ufixed(string'("11.1111")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1.001101")), to_ufixed(string'("010.")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("101.01")), to_ufixed(string'("1.1")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1010.1")), to_ufixed(string'("11.")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("101.11")), to_ufixed(string'("110.")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'(".11")), to_ufixed(string'("1.")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'(".1011")), to_ufixed(string'("0.11")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("0.0000000001")), to_ufixed(string'("1.")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1.0000000001")), to_ufixed(string'("1.1")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1.0000000001")), to_ufixed(string'("1.")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("10.000000001")), to_ufixed(string'("10.001")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1.")), to_ufixed(string'("1.00000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("0.")), to_ufixed(string'("0.00000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1.")), to_ufixed(string'(".111111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("0.")), to_ufixed(string'(".000000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("10.101")), to_ufixed(string'("010.1010")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("10.101")), to_ufixed(string'("10.11")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("10.101")), to_ufixed(string'("10.1010")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1.000000000000000001")), to_ufixed(string'(".111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("01.00000000000000001")), to_ufixed(string'(".111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1.00000000000000")), to_ufixed(string'(".111111111111111")), rnd, sat);
|
|
|
|
PerformRoundTest (to_sfixed(string'("101.0011")), to_sfixed(string'("11.1111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("1.001101")), to_sfixed(string'("010.")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("101.01")), to_sfixed(string'("1.1")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("1010.1")), to_sfixed(string'("11.")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("101.11")), to_sfixed(string'("110.")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'(".11")), to_sfixed(string'("1.")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'(".1011")), to_sfixed(string'("0.11")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("0.0000000001")), to_sfixed(string'("1.")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("1.0000000001")), to_sfixed(string'("1.1")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("1.0000000001")), to_sfixed(string'("1.")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("10.000000001")), to_sfixed(string'("10.001")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("1.")), to_sfixed(string'("1.00000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("0.")), to_sfixed(string'("0.00000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("1.")), to_sfixed(string'(".111111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("0.")), to_sfixed(string'(".000000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("10.101")), to_sfixed(string'("010.1010")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("10.101")), to_sfixed(string'("10.11")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("10.101")), to_sfixed(string'("10.1010")), rnd, sat);
|
|
|
|
PerformRoundTest (to_sfixed(string'("-1.000000000000000001")), to_sfixed(string'("-.111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-01.00000000000000001")), to_sfixed(string'("-.111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-1.00000000000000")), to_sfixed(string'("-.111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("1.000000000000000001")), to_sfixed(string'(".111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("01.00000000000000001")), to_sfixed(string'(".111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("1.00000000000000")), to_sfixed(string'(".111111111111111")), rnd, sat);
|
|
|
|
PerformRoundTest (to_sfixed(string'("1.0000")), to_sfixed(string'(".11111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("01.000")), to_sfixed(string'(".11111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("0.1000")), to_sfixed(string'(".10000")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("00.100")), to_sfixed(string'(".10000")), rnd, sat);
|
|
|
|
---------------------------------------------------------------------
|
|
|
|
writeline (output, L);
|
|
write (L, String'("* Round half up" & CR & LF));
|
|
writeline (output, L);
|
|
|
|
rnd := round_half_up;
|
|
sat := saturate;
|
|
|
|
PerformRoundTest (to_ufixed(string'("101.0011")), to_ufixed(string'("11.1111")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1.001101")), to_ufixed(string'("001.")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("101.01")), to_ufixed(string'("1.1")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1010.1")), to_ufixed(string'("11.")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("101.11")), to_ufixed(string'("110.")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'(".11")), to_ufixed(string'("1.")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'(".1011")), to_ufixed(string'("0.11")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("0.0000000001")), to_ufixed(string'("0.")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1.0000000001")), to_ufixed(string'("1.0")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1.0000000001")), to_ufixed(string'("1.")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("10.000000001")), to_ufixed(string'("10.000")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1.")), to_ufixed(string'("1.00000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("0.")), to_ufixed(string'("0.00000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1.")), to_ufixed(string'(".111111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("0.")), to_ufixed(string'(".000000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("10.101")), to_ufixed(string'("010.1010")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("10.101")), to_ufixed(string'("10.11")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("10.101")), to_ufixed(string'("10.1010")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1.000000000000000001")), to_ufixed(string'(".111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("01.00000000000000001")), to_ufixed(string'(".111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_ufixed(string'("1.00000000000000")), to_ufixed(string'(".111111111111111")), rnd, sat);
|
|
|
|
PerformRoundTest (to_sfixed(string'("101.0011")), to_sfixed(string'("11.1111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("1.001101")), to_sfixed(string'("001.")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("101.01")), to_sfixed(string'("1.1")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("1010.1")), to_sfixed(string'("11.")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("101.11")), to_sfixed(string'("110.")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-.11")), to_sfixed(string'("-1.")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-.1")), to_sfixed(string'("0.")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'(".1011")), to_sfixed(string'("0.11")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("0.0000000001")), to_sfixed(string'("0.")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("1.0000000001")), to_sfixed(string'("1.0")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("1.0000000001")), to_sfixed(string'("1.")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("10.000000001")), to_sfixed(string'("10.000")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("1.")), to_sfixed(string'("1.00000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("0.")), to_sfixed(string'("0.00000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("1.")), to_sfixed(string'(".111111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("0.")), to_sfixed(string'(".000000000000000000")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("10.101")), to_sfixed(string'("010.1010")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("10.101")), to_sfixed(string'("10.11")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("10.101")), to_sfixed(string'("10.1010")), rnd, sat);
|
|
|
|
PerformRoundTest (to_sfixed(string'("-1.000000000000000000")), to_sfixed(string'("-.111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-1.000000000000000001")), to_sfixed(string'("-.111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-01.00000000000000000")), to_sfixed(string'("-.111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-01.00000000000000001")), to_sfixed(string'("-.111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-01.0000000000000")), to_sfixed(string'("-.111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-01.0000000000001")), to_sfixed(string'("-.111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-01.0000000000000")), to_sfixed(string'("-.11111111111111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-01.0000000000001")), to_sfixed(string'("-.11111111111111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-01.0000000000000")), to_sfixed(string'("-.1111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-01.0000000000001")), to_sfixed(string'("-.1111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-00.1111111111111")), to_sfixed(string'("-.111111111111100")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-00.111111111111111")), to_sfixed(string'("-.11111111111111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-00.111111111111111")), to_sfixed(string'("-1.0000000000000")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-1.000000000000000001")), to_sfixed(string'("-.111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-01.00000000000000001")), to_sfixed(string'("-.111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-1.0000000000000000001")), to_sfixed(string'("-.111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-01.000000000000000001")), to_sfixed(string'("-.111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-1.00000000000000000001")), to_sfixed(string'("-.111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-01.0000000000000000001")), to_sfixed(string'("-.111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-1.000000000000000000001")), to_sfixed(string'("-.111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-01.00000000000000000001")), to_sfixed(string'("-.111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-1.0000000000000000000001")), to_sfixed(string'("-.111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-01.000000000000000000001")), to_sfixed(string'("-.111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-1.000000000000000011")), to_sfixed(string'("-.111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-01.00000000000000011")), to_sfixed(string'("-.111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-1.0000000000000000011")), to_sfixed(string'("-.111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-01.000000000000000011")), to_sfixed(string'("-.111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-1.00000000000000000011")), to_sfixed(string'("-.111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-01.0000000000000000011")), to_sfixed(string'("-.111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-1.000000000000000000011")), to_sfixed(string'("-.111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-01.00000000000000000011")), to_sfixed(string'("-.111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-1.0000000000000000000011")), to_sfixed(string'("-.111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-01.000000000000000000011")), to_sfixed(string'("-.111111111111111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("-1.00000000000000")), to_sfixed(string'("-.111111111111111")), rnd, sat);
|
|
|
|
PerformRoundTest (to_sfixed(string'("1.0000")), to_sfixed(string'(".11111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("01.000")), to_sfixed(string'(".11111")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("0.1000")), to_sfixed(string'(".10000")), rnd, sat);
|
|
PerformRoundTest (to_sfixed(string'("00.100")), to_sfixed(string'(".10000")), rnd, sat);
|
|
|
|
---------------------------------------------------------------------
|
|
|
|
writeline (output, L);
|
|
write (L, String'("----------------------" & CR & LF));
|
|
write (L, String'(" Arithmetic Test " & CR & LF));
|
|
write (L, String'("----------------------" & CR & LF));
|
|
|
|
if true then
|
|
|
|
PerformArithTest(to_ufixed(0.500, 8, 0), '+', to_ufixed(0.250, 8, 0), to_ufixed(0.500 + 0.250, 9, 1));
|
|
PerformArithTest(to_ufixed(0.375, 8, 0), '+', to_ufixed(0.250, 8, 0), to_ufixed(0.375 + 0.250, 9, 1));
|
|
PerformArithTest(to_ufixed(0.375, 8, 1), '-', to_ufixed(0.250, 8, 0), to_ufixed(0.375 - 0.250, 9, 1));
|
|
PerformArithTest(to_ufixed(0.500, 8, 0), '+', to_ufixed(0.250, 8, 0), to_ufixed(0.500 + 0.250, 9, 1));
|
|
PerformArithTest(to_ufixed(0.500, 8, 0), '-', to_ufixed(0.250, 8, 0), to_ufixed(0.500 - 0.250, 8, 0));
|
|
PerformArithTest(to_ufixed(0.250, 8, 0), '+', to_ufixed(0.250, 8, 0), to_ufixed(0.250 + 0.250, 9, 1));
|
|
PerformArithTest(to_ufixed(0.250, 8, 0), '-', to_ufixed(0.250, 8, 0), to_ufixed(0.250 - 0.250, 8, 0));
|
|
PerformArithTest(to_ufixed(0.250, 4, 0), '+', to_ufixed(0.250, 8, 3), to_ufixed(0.250 + 0.250, 8, 3));
|
|
|
|
PerformArithTest(to_ufixed(string'("1.0000")), '+', to_ufixed(string'("1.0000")), to_ufixed(string'("10.0000")));
|
|
PerformArithTest(to_ufixed(string'("0.1001")), '+', to_ufixed(string'("0.0110")), to_ufixed(string'("00.1111")));
|
|
PerformArithTest(to_ufixed(string'("0.0011")), '+', to_ufixed(string'("0.0110")), to_ufixed(string'("00.1001")));
|
|
PerformArithTest(to_ufixed(string'("0.1111")), '+', to_ufixed(string'("1.0001")), to_ufixed(string'("10.0000")));
|
|
PerformArithTest(to_ufixed(string'("10.0000")), '-', to_ufixed(string'("1.0000")), to_ufixed(string'("01.0000")));
|
|
PerformArithTest(to_ufixed(string'("00.1111")), '-', to_ufixed(string'("0.1001")), to_ufixed(string'("00.0110")));
|
|
PerformArithTest(to_ufixed(string'("00.1001")), '-', to_ufixed(string'("0.0011")), to_ufixed(string'("00.0110")));
|
|
PerformArithTest(to_ufixed(string'("10.0000")), '-', to_ufixed(string'("0.1111")), to_ufixed(string'("01.0001")));
|
|
|
|
PerformArithTest(to_ufixed(0.500, 8, 0), '*', to_ufixed(4.500, 8, 3), to_ufixed(0.500 * 4.500, 16, 2));
|
|
PerformArithTest(to_ufixed(0.500, 8, 0), '*', to_ufixed(0.500, 8, 0), to_ufixed(0.500 * 0.500, 16, 0));
|
|
PerformArithTest(to_ufixed(0.500, 8, 1), '*', to_ufixed(0.500, 8, 0), to_ufixed(0.500 * 0.500, 16, 0));
|
|
PerformArithTest(to_ufixed(0.500, 8, 1), '*', to_ufixed(0.500, 8, 1), to_ufixed(0.500 * 0.500, 16, 2));
|
|
|
|
PerformArithTest(to_ufixed(0.500, 8, 1), '*', to_ufixed(0.500, 8, 0), to_ufixed(0.500 * 0.500, 16, 0));
|
|
PerformArithTest(to_ufixed(0.500, 8, 2), '*', to_ufixed(0.500, 8, 1), to_ufixed(0.500 * 0.500, 16, 3));
|
|
PerformArithTest(to_ufixed(1.500, 9, 2), '*', to_ufixed(0.500, 8, 0), to_ufixed(1.500 * 0.500, 17, 1));
|
|
PerformArithTest(to_ufixed(0.500, 8, 0), '*', to_ufixed(1.500, 9, 2), to_ufixed(1.500 * 0.500, 17, 1));
|
|
PerformArithTest(to_ufixed(1.500, 8, 2), '*', to_ufixed(0.500, 9, 0), to_ufixed(1.500 * 0.500, 17, 1));
|
|
PerformArithTest(to_ufixed(0.500, 9, 0), '*', to_ufixed(1.500, 8, 2), to_ufixed(1.500 * 0.500, 17, 1));
|
|
|
|
PerformArithTest(to_sfixed(0.375, 4, 0), '+', to_sfixed(0.250, 8, 0), to_sfixed(0.375 + 0.250, 9, 1));
|
|
PerformArithTest(to_sfixed(0.375, 8, 0), '-', to_sfixed(0.250, 8, 0), to_sfixed(0.375 - 0.250, 8, 0));
|
|
PerformArithTest(to_sfixed(0.500, 8, 0), '+', to_sfixed(0.250, 8, 0), to_sfixed(0.500 + 0.250, 9, 1));
|
|
PerformArithTest(to_sfixed(0.500, 8, 0), '-', to_sfixed(0.250, 8, 0), to_sfixed(0.500 - 0.250, 8, 0));
|
|
PerformArithTest(to_sfixed(0.250, 8, 0), '+', to_sfixed(0.250, 8, 0), to_sfixed(0.250 + 0.250, 9, 1));
|
|
PerformArithTest(to_sfixed(0.250, 8, 0), '-', to_sfixed(0.250, 8, 0), to_sfixed(0.250 - 0.250, 8, 0));
|
|
PerformArithTest(to_sfixed(0.250, 4, 0), '+', to_sfixed(0.250, 8, 3), to_sfixed(0.250 + 0.250, 8, 3));
|
|
PerformArithTest(to_sfixed(-0.500, 4, 0), '*', to_sfixed(4.500, 8, 3), to_sfixed(-0.500 * 4.500, 12, 2));
|
|
PerformArithTest(to_sfixed(-0.500, 8, 0), '*', to_sfixed(0.500, 8, 0), to_sfixed(-0.500 * 0.500, 16, 0));
|
|
PerformArithTest(to_sfixed(-0.500, 8, 1), '*', to_sfixed(0.500, 8, 0), to_sfixed(-0.500 * 0.500, 16, 0));
|
|
PerformArithTest(to_sfixed(-0.500, 8, 1), '*', to_sfixed(0.500, 8, 1), to_sfixed(-0.500 * 0.500, 16, 2));
|
|
PerformArithTest(to_sfixed(0.500, 4, 0), '*', to_sfixed(4.500, 8, 3), to_sfixed(0.500 * 4.500, 12, 2));
|
|
PerformArithTest(to_sfixed(0.500, 8, 0), '*', to_sfixed(0.500, 8, 0), to_sfixed(0.500 * 0.500, 16, 0));
|
|
PerformArithTest(to_sfixed(0.500, 8, 1), '*', to_sfixed(0.500, 8, 0), to_sfixed(0.500 * 0.500, 16, 0));
|
|
PerformArithTest(to_sfixed(0.500, 8, 1), '*', to_sfixed(0.500, 8, 1), to_sfixed(0.500 * 0.500, 16, 2));
|
|
|
|
fprint(RESULT, L, "Test finished\n\n");
|
|
|
|
end if;
|
|
if true then
|
|
|
|
fprint(RESULT, L, "\nPositive ufixed\n");
|
|
for i in 0 to uconst0'length loop
|
|
ures := uconst0 sla i;
|
|
fprint(RESULT, L, "%s sla %d = %s\n", to_string(uconst0), fo(i), to_string(ures));
|
|
end loop;
|
|
fprint(RESULT, L, "\n");
|
|
for i in 0 to uconst0'length loop
|
|
ures := uconst0 sla -i;
|
|
fprint(RESULT, L, "%s sla %d = %s\n", to_string(uconst0), fo(-i), to_string(ures));
|
|
end loop;
|
|
fprint(RESULT, L, "\n");
|
|
for i in 0 to uconst0'length loop
|
|
ures := uconst0 sra i;
|
|
fprint(RESULT, L, "%s sra %d = %s\n", to_string(uconst0), fo(i), to_string(ures));
|
|
end loop;
|
|
fprint(RESULT, L, "\n");
|
|
for i in 0 to uconst0'length loop
|
|
ures := uconst0 sra -i;
|
|
fprint(RESULT, L, "%s sra %d = %s\n", to_string(uconst0), fo(-i), to_string(ures));
|
|
end loop;
|
|
|
|
fprint(RESULT, L, "\nPositive sfixed\n");
|
|
for i in 0 to sconst0'length loop
|
|
sres := sconst0 sla i;
|
|
fprint(RESULT, L, "%s sla %d = %s\n", to_string(sconst0), fo(i), to_string(sres));
|
|
end loop;
|
|
fprint(RESULT, L, "\n");
|
|
for i in 0 to sconst0'length loop
|
|
sres := sconst0 sla -i;
|
|
fprint(RESULT, L, "%s sla %d = %s\n", to_string(sconst0), fo(-i), to_string(sres));
|
|
end loop;
|
|
fprint(RESULT, L, "\n");
|
|
for i in 0 to sconst0'length loop
|
|
sres := sconst0 sra i;
|
|
fprint(RESULT, L, "%s sra %d = %s\n", to_string(sconst0), fo(i), to_string(sres));
|
|
end loop;
|
|
fprint(RESULT, L, "\n");
|
|
for i in 0 to sconst0'length loop
|
|
sres := sconst0 sra -i;
|
|
fprint(RESULT, L, "%s sra %d = %s\n", to_string(sconst0), fo(-i), to_string(sres));
|
|
end loop;
|
|
|
|
fprint(RESULT, L, "\nNegative sfixed\n");
|
|
for i in 0 to sconst0'length loop
|
|
sres := -sconst0 sla i;
|
|
fprint(RESULT, L, "%s sla %d = %s\n", to_string(-sconst0), fo(i), to_string(sres));
|
|
end loop;
|
|
fprint(RESULT, L, "\n");
|
|
for i in 0 to sconst0'length loop
|
|
sres := -sconst0 sla -i;
|
|
fprint(RESULT, L, "%s sla %d = %s\n", to_string(-sconst0), fo(-i), to_string(sres));
|
|
end loop;
|
|
fprint(RESULT, L, "\n");
|
|
for i in 0 to sconst0'length loop
|
|
sres := -sconst0 sra i;
|
|
fprint(RESULT, L, "%s sra %d = %s\n", to_string(-sconst0), fo(i), to_string(sres));
|
|
end loop;
|
|
fprint(RESULT, L, "\n");
|
|
for i in 0 to sconst0'length loop
|
|
sres := -sconst0 sra -i;
|
|
fprint(RESULT, L, "%s sra %d = %s\n", to_string(-sconst0), fo(-i), to_string(sres));
|
|
end loop;
|
|
|
|
|
|
fprint(RESULT, L, "\nPositive ufixed\n");
|
|
for i in 0 to uconst1'length loop
|
|
ures := uconst1 sla i;
|
|
fprint(RESULT, L, "%s sla %d = %s\n", to_string(uconst1), fo(i), to_string(ures));
|
|
end loop;
|
|
fprint(RESULT, L, "\n");
|
|
for i in 0 to uconst1'length loop
|
|
ures := uconst1 sla -i;
|
|
fprint(RESULT, L, "%s sla %d = %s\n", to_string(uconst1), fo(-i), to_string(ures));
|
|
end loop;
|
|
fprint(RESULT, L, "\n");
|
|
for i in 0 to uconst1'length loop
|
|
ures := uconst1 sra i;
|
|
fprint(RESULT, L, "%s sra %d = %s\n", to_string(uconst1), fo(i), to_string(ures));
|
|
end loop;
|
|
fprint(RESULT, L, "\n");
|
|
for i in 0 to uconst1'length loop
|
|
ures := uconst1 sra -i;
|
|
fprint(RESULT, L, "%s sra %d = %s\n", to_string(uconst1), fo(-i), to_string(ures));
|
|
end loop;
|
|
|
|
fprint(RESULT, L, "\nPositive sfixed\n");
|
|
for i in 0 to sconst1'length loop
|
|
sres := sconst1 sla i;
|
|
fprint(RESULT, L, "%s sla %d = %s\n", to_string(sconst1), fo(i), to_string(sres));
|
|
end loop;
|
|
fprint(RESULT, L, "\n");
|
|
for i in 0 to sconst1'length loop
|
|
sres := sconst1 sla -i;
|
|
fprint(RESULT, L, "%s sla %d = %s\n", to_string(sconst1), fo(-i), to_string(sres));
|
|
end loop;
|
|
fprint(RESULT, L, "\n");
|
|
for i in 0 to sconst1'length loop
|
|
sres := sconst1 sra i;
|
|
fprint(RESULT, L, "%s sra %d = %s\n", to_string(sconst1), fo(i), to_string(sres));
|
|
end loop;
|
|
fprint(RESULT, L, "\n");
|
|
for i in 0 to sconst1'length loop
|
|
sres := sconst1 sra -i;
|
|
fprint(RESULT, L, "%s sra %d = %s\n", to_string(sconst1), fo(-i), to_string(sres));
|
|
end loop;
|
|
|
|
fprint(RESULT, L, "\nNegative sfixed\n");
|
|
for i in 0 to sconst1'length loop
|
|
sres := -sconst1 sla i;
|
|
fprint(RESULT, L, "%s sla %d = %s\n", to_string(-sconst1), fo(i), to_string(sres));
|
|
end loop;
|
|
fprint(RESULT, L, "\n");
|
|
for i in 0 to sconst1'length loop
|
|
sres := -sconst1 sla -i;
|
|
fprint(RESULT, L, "%s sla %d = %s\n", to_string(-sconst1), fo(-i), to_string(sres));
|
|
end loop;
|
|
fprint(RESULT, L, "\n");
|
|
for i in 0 to sconst1'length loop
|
|
sres := -sconst1 sra i;
|
|
fprint(RESULT, L, "%s sra %d = %s\n", to_string(-sconst1), fo(i), to_string(sres));
|
|
end loop;
|
|
fprint(RESULT, L, "\n");
|
|
for i in 0 to sconst1'length loop
|
|
sres := -sconst1 sra -i;
|
|
fprint(RESULT, L, "%s sra %d = %s\n", to_string(-sconst1), fo(-i), to_string(sres));
|
|
end loop;
|
|
|
|
end if;
|
|
|
|
if true then
|
|
write (L, String'("Positive ufixed"));writeline (output, L);
|
|
print_info(to_ufixed(0.5,5,0)*to_ufixed(0.5,5,0), string'("U"));
|
|
print_info(to_ufixed(0.5,5,1)*to_ufixed(0.5,5,0), string'("U"));
|
|
print_info(to_ufixed(0.5,5,0)*to_ufixed(0.5,5,1), string'("U"));
|
|
print_info(to_ufixed(0.5,5,1)*to_ufixed(0.5,5,1), string'("U"));
|
|
print_info(to_ufixed(0.5,5,0)*to_ufixed(0.5,5,2), string'("U"));
|
|
print_info(to_ufixed(0.5,5,2)*to_ufixed(0.5,5,0), string'("U"));
|
|
|
|
write (L, String'("Positive sfixed"));writeline (output, L);
|
|
print_info(to_sfixed(0.5,5,0)*to_sfixed(0.5,5,0), string'("S"));
|
|
print_info(to_sfixed(0.5,5,1)*to_sfixed(0.5,5,0), string'("S"));
|
|
print_info(to_sfixed(0.5,5,0)*to_sfixed(0.5,5,1), string'("S"));
|
|
print_info(to_sfixed(0.5,5,1)*to_sfixed(0.5,5,1), string'("S"));
|
|
print_info(to_sfixed(0.5,5,0)*to_sfixed(0.5,5,2), string'("S"));
|
|
print_info(to_sfixed(0.5,5,2)*to_sfixed(0.5,5,0), string'("S"));
|
|
|
|
write (L, String'("Neg/Pos sfixed"));writeline (output, L);
|
|
print_info(to_sfixed(-0.5,5,0)*to_sfixed(0.5,5,0), string'("S"));
|
|
print_info(to_sfixed(-0.5,5,1)*to_sfixed(0.5,5,0), string'("S"));
|
|
print_info(to_sfixed(-0.5,5,0)*to_sfixed(0.5,5,1), string'("S"));
|
|
print_info(to_sfixed(-0.5,5,1)*to_sfixed(0.5,5,1), string'("S"));
|
|
print_info(to_sfixed(-0.5,5,0)*to_sfixed(0.5,5,2), string'("S"));
|
|
print_info(to_sfixed(-0.5,5,2)*to_sfixed(0.5,5,0), string'("S"));
|
|
|
|
write (L, String'("Pos/Neg sfixed"));writeline (output, L);
|
|
print_info(to_sfixed(0.5,5,0)*to_sfixed(-0.5,5,0), string'("S"));
|
|
print_info(to_sfixed(0.5,5,1)*to_sfixed(-0.5,5,0), string'("S"));
|
|
print_info(to_sfixed(0.5,5,0)*to_sfixed(-0.5,5,1), string'("S"));
|
|
print_info(to_sfixed(0.5,5,1)*to_sfixed(-0.5,5,1), string'("S"));
|
|
print_info(to_sfixed(0.5,5,0)*to_sfixed(-0.5,5,2), string'("S"));
|
|
print_info(to_sfixed(0.5,5,2)*to_sfixed(-0.5,5,0), string'("S"));
|
|
|
|
write (L, String'("Neg/Neg sfixed"));writeline (output, L);
|
|
print_info(to_sfixed(-0.5,5,0)*to_sfixed(-0.5,5,0), string'("S"));
|
|
print_info(to_sfixed(-0.5,5,1)*to_sfixed(-0.5,5,0), string'("S"));
|
|
print_info(to_sfixed(-0.5,5,0)*to_sfixed(-0.5,5,1), string'("S"));
|
|
print_info(to_sfixed(-0.5,5,1)*to_sfixed(-0.5,5,1), string'("S"));
|
|
print_info(to_sfixed(-0.5,5,0)*to_sfixed(-0.5,5,2), string'("S"));
|
|
print_info(to_sfixed(-0.5,5,2)*to_sfixed(-0.5,5,0), string'("S"));
|
|
|
|
fprint(RESULT, L,"Test %s:\n", to_string(to_sfixed(to_ufixed(to_ufixed(0.785398, 8, 0),8,1) sla 1)));
|
|
fprint(RESULT, L,"Test %s:\n", to_string(to_sfixed(to_sfixed(0.785398, 8, 0),8,1) sla 1));
|
|
fprint(RESULT, L,"Test %s:\n", to_string(to_sfixed(to_sfixed(-0.785398, 8, 0),8,1) sla 1));
|
|
fprint(RESULT, L,"Test %s:\n", to_string(to_ufixed(to_ufixed(0.785398, 8, 0),8,2) sla -1));
|
|
fprint(RESULT, L,"Test %s:\n", to_string(to_sfixed(to_sfixed(0.785398, 8, 0),8,2) sla -1));
|
|
fprint(RESULT, L,"Test %s:\n", to_string(to_sfixed(-to_ufixed(-0.785398, 8, 0),8,2) sla -1));
|
|
|
|
fprint(RESULT, L,"Integer Test %s:\n", to_string(to_sfixed(0, 8,2)));
|
|
fprint(RESULT, L,"R: Bit %s:\n", to_string(to_ufixed(3.785398, 8, 2)));
|
|
fprint(RESULT, L,"U: Bit %s.%s:\n", to_string(to_slv(ipart(to_ufixed(3.785398, 8, 2)))), to_string(to_slv(fpart(to_ufixed(3.785398, 8, 2)))));
|
|
fprint(RESULT, L,"S: Bit %s.%s:\n", to_string(to_slv(ipart(to_sfixed(3.785398, 9, 2)))), to_string(to_slv(fpart(to_sfixed(3.785398, 9, 2)))));
|
|
fprint(RESULT, L,"S: Bit %s.%s:\n", to_string(to_slv(ipart(-to_sfixed(3.785398, 9, 2)))), to_string(to_slv(fpart(-to_sfixed(3.785398, 9, 2)))));
|
|
fprint(RESULT, L,"S: Bit %d.%d:\n", fo(to_slv(ipart(to_sfixed(3.785398, 9, 2)))), fo(to_slv(fpart(to_sfixed(3.785398, 9, 2)))));
|
|
fprint(RESULT, L,"S: Bit %d:\n", fo(to_signed(to_sfixed(-3.785398, 9, 2))));
|
|
print_info(s1, "S1");
|
|
print_info(s2, "S2");
|
|
print_info(s1*s2, "R1");
|
|
print_info(to_sfixed(1.0E-6, 32, 0), "precision_test");
|
|
end if;
|
|
|
|
wait;
|
|
end process;
|
|
|
|
---------------------------------------------------------------------
|
|
end Behavioral;
|
|
|