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?

  • 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\$ – pipe Feb 13 '18 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\$ – stanri Feb 13 '18 at 11:56
  • \$\begingroup\$ Also have a look here: electronics.stackexchange.com/questions/51848/… \$\endgroup\$ – Oldfart Feb 13 '18 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\$ – TonyM Feb 13 '18 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\$ – stanri Feb 13 '18 at 12:22

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.

  • 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\$ – user8352 Feb 13 '18 at 19:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.