Posts

How to convert a std_logic_vector to a hex string?

I was asked how to easily convert a std_logic_vector to a hex string . This is easy: there's a procedure in the ieee.std_logic_textio package caled hwrite which does most of the hard work for us. The ieee.std_logic_textio package is an add on to the std.textio package, which enables std_logic and associated types to be written to files (you need both packages to do this). Both packages first write to a variable of type line , which is declared in the textio package. The line type is an access type , which points to a string ; this is a line of code from the textio package: type line is access string;         So, let's write a function to convert a std_logic_vector to a string . Our input is a std_logic_vector and our return value is a string : function to_hstring (SLV : std_logic_vector) return string is Notice that both the function input and the return type are unconstrained - they are arrays with no bounds. This is legal for function i...