0
\$\begingroup\$
X: std_logic_vector(3 down to 0);
c : Std_logic;
d : bit;
s : std_logic_vector(1 down to 0);

In architecture

x <= c&d&s;

so is this signal assignment in Architecture is correct or wrong

IS bit and std_logic having same condition and is it possible to assign the same to std_logic_vector as in assignment?

TonyM
25.2k4 gold badges41 silver badges68 bronze badges
asked Feb 13, 2018 at 11:46
\$\endgroup\$
7
  • 1
    \$\begingroup\$ 1. Please use the preview before posting, especially for code. 2. Does the value of the question increase for every question mark added? \$\endgroup\$ Commented Feb 13, 2018 at 11:49
  • 2
    \$\begingroup\$ This looks like homework so I'm not going to write an answer. It's incorrect, you need to convert at least one of the types. I have also edited the code to look nicer. In the future, remember to add four spaces on to the beginning of the parts that are code. \$\endgroup\$ Commented Feb 13, 2018 at 11:56
  • \$\begingroup\$ Also have a look here: electronics.stackexchange.com/questions/51848/… \$\endgroup\$ Commented Feb 13, 2018 at 11:57
  • \$\begingroup\$ @stanri, indentation advice is subjective but since we're here: I recommend to OP use 2 spaces, not 4. Avoids wasting line width. \$\endgroup\$ Commented Feb 13, 2018 at 12:21
  • 3
    \$\begingroup\$ @TonyM the four spaces are defined by the markup. If you use two it doesn't put the code in a code block. See electronics.stackexchange.com/editing-help: "Indent four spaces to create an escaped <pre> <code> block" \$\endgroup\$ Commented Feb 13, 2018 at 12:22

1 Answer 1

1
\$\begingroup\$

VHDL is a strongly typed language. All vectors which you concatanate on the right side should be of same data type. And the data type of the result of the right side expression should match with the data type of the left side expression. In VHDL, "bit" is a 2-valued data type and "std_logic" is an 8-valued data type. They both are different.

answered Feb 13, 2018 at 13:20
\$\endgroup\$
1
  • 1
    \$\begingroup\$ std_logic is a resolved std_ulogic which is a character enumerated type having 9 values ('U', 'X', '0', '1', 'Z', 'W', 'L', 'H', '-') count 'em. Enumerated means the values are named, character means at least some names are character literals. The value is positional (which doesn't correspond between the two types). Those 'vectors' are single dimensional array types with an element type that is a character enumerated type. The concatenation operator is predefined for all single dimensional array types. \$\endgroup\$ Commented Feb 13, 2018 at 19:35

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.