From 8c4d8fb27eed66ace5aec2b445ef70325fa34c29 Mon Sep 17 00:00:00 2001 From: 1138-4EB <1138-4EB@users.noreply.github.com> Date: Fri, 29 Nov 2019 01:03:47 +0100 Subject: [PATCH] encodings: style --- vunit/vhdl/encodings/src/encodings_pkg.vhd | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/vunit/vhdl/encodings/src/encodings_pkg.vhd b/vunit/vhdl/encodings/src/encodings_pkg.vhd index 494e48aa2..d3d4df6b3 100644 --- a/vunit/vhdl/encodings/src/encodings_pkg.vhd +++ b/vunit/vhdl/encodings/src/encodings_pkg.vhd @@ -6,10 +6,10 @@ library ieee; use ieee.fixed_pkg.from_hex_string; +use ieee.fixed_pkg.to_unsigned; use ieee.fixed_pkg.to_hex_string; -use ieee.fixed_pkg.ufixed; -use ieee.fixed_pkg.to_integer; use ieee.fixed_pkg.to_ufixed; +use ieee.numeric_std.to_integer; use work.string_ops.lower; @@ -25,11 +25,14 @@ package body encodings_pkg is function b16decode(str: string) return string is constant str_i : string(1 to str'length) := str; variable result: string (1 to str'length / 2); - variable character_code : ufixed(7 downto 0); begin for x in result'range loop - character_code := from_hex_string(str_i(2 * x - 1 to 2 * x)); - result(x) := character'val(to_integer(character_code)); + result(x) := character'val(to_integer( + to_unsigned(from_hex_string( + str_i(2 * x - 1 to 2 * x), + 7, 0 + ), 8) + )); end loop; return result; end; @@ -37,11 +40,11 @@ package body encodings_pkg is function b16encode(str: string) return string is constant str_i : string(1 to str'length) := str; variable result: string (1 to str'length * 2); - variable character_code : string(1 to 4); begin for x in str_i'range loop - character_code := to_hex_string(to_ufixed(character'pos(str_i(x)), 7, 0)); - result(2 * x - 1 to 2 * x) := lower(character_code(1 to 2)); + result(2 * x - 1 to 2 * x) := lower(to_hex_string( + to_ufixed(character'pos(str_i(x)), 7, 0) + )(1 to 2)); end loop; return result; end;