Is there an existing function within the regular std.logic library to convert a boolean data type to std logic in vhdl?
1 Answer
The answer in short: no.
As @Harry pointed out, it isn't possible to map 2 values from boolean to 9 values from std_logic.
The std_logic-type is used, among other things, to detect problems in your code whilst simulating and to have a better representation how the hardware will act later on.
So I would recommend you to not write a function which converts true to '1' and false to '0', because then you'll lose the advantage of the std_logic-type.
It is noted, that converting from std_logic to boolean is allowed and even implemented since the VHDL 2008 standard.
convert(b : boolean) return std_logic. Then whatstd_logicvalues would you expect to result fromconvert(true)andconvert(false)? You could argue that active high and active low logic should give opposite results, so you would want different conversion functions for each case. Conversions in the other direction are even more complicated because you have to decide how to convert 9 differentstd_logicvalues to just two boolean values.