3

Is there an existing function within the regular std.logic library to convert a boolean data type to std logic in vhdl?

1
  • I don't think there is, because I don't know for sure how you would expect it to behave. Let's say the conversion function is convert(b : boolean) return std_logic. Then what std_logic values would you expect to result from convert(true) and convert(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 different std_logic values to just two boolean values. Commented Jun 4, 2021 at 8:19

1 Answer 1

-3

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.