aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils_io.adb
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2022-05-27 09:52:21 +0200
committerTristan Gingold <tgingold@free.fr>2022-05-27 09:52:21 +0200
commite8c9722ebc2b610d6bd6f70fc88e04ea6ec4041c (patch)
tree1cf59bb20f75293208161bd752ff12dbf6e4f1d6 /src/utils_io.adb
parentba126785e1ce562f242b1a104ada9cfb554f62e8 (diff)
downloadghdl-e8c9722ebc2b610d6bd6f70fc88e04ea6ec4041c.tar.gz
ghdl-e8c9722ebc2b610d6bd6f70fc88e04ea6ec4041c.tar.bz2
ghdl-e8c9722ebc2b610d6bd6f70fc88e04ea6ec4041c.zip
utils_io: add put_addr (to display addresses)
Diffstat (limited to 'src/utils_io.adb')
-rw-r--r--src/utils_io.adb20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/utils_io.adb b/src/utils_io.adb
index d883ccddf..78b9a9d7b 100644
--- a/src/utils_io.adb
+++ b/src/utils_io.adb
@@ -14,6 +14,8 @@
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <gnu.org/licenses>.
+with Ada.Unchecked_Conversion;
+
with Simple_IO; use Simple_IO;
package body Utils_IO is
@@ -46,4 +48,22 @@ package body Utils_IO is
begin
Put_Trim (Int64'Image (V));
end Put_Int64;
+
+ Hex_Map : constant array (0 .. 15) of Character := "0123456789ABCDEF";
+
+ procedure Put_Addr (V : System.Address)
+ is
+ type Integer_Address is mod System.Memory_Size;
+ function To_Integer is new Ada.Unchecked_Conversion
+ (Source => System.Address, Target => Integer_Address);
+ Res : String (1 .. System.Word_Size / 4);
+ Val : Integer_Address := To_Integer (V);
+ begin
+ for I in reverse Res'Range loop
+ Res (I) := Hex_Map (Natural (Val and 15));
+ Val := Val / 16;
+ end loop;
+ Put (Res);
+ end Put_Addr;
+
end Utils_IO;