I've been able to mitigate an error I received when assigning an inout port.
I would like to know "WHY" my new code works, and why the old code is at fault.
Old Code
Code:
UUT : COMPONENT
PORT MAP( A => PIN_1,
B => PIN_2,
C => PIN_3 & PIN_4,
D => PIN_10 & PIN_61 & PIN_11 & PIN_62 & PIN_12 & PIN_13 & PIN_64 & PIN_14 &
PIN_65 & PIN_15 & PIN_66 & PIN_16 & PIN_67 & PIN_17 & PIN_68 & PIN_18
);
ERROR = (vcom-1454) Formal "D" of mode INOUT cannot be associated with an expression. additional info - port C can be in or out & there is no issue with "pin_3 & pin_4" signal assignment expression.
The concatenation that you're doing on the port map for 'D' in 'Old Code' cannot be applied to an inout pin because when 'D' is driving the output, there really isn't a way to run the concatenation in reverse to assign it to the individual signals. Think of the & as being a function. Functions have inputs and produce an output. But functions don't work in reverse where if you give it an output it will then produce the inputs. You could argue that in this case, one can run the function backwards, but in a more general case, you cannot and that is fundamentally the reason that the language does not allow a function to be placed on the port map of an inout.
While it gives no compiler error, I don't think it will actually work the way you intended. Your new code will have 'Pin_D' always being driven by the "PIN_D <= PIN_10 & PIN_61 & PIN_11..." statement so when the UUT component goes to drive those signals your design will have two drivers that may conflict. As an example, say that 'Pin_10' is currently a '1', then the leftmost bit of Pin_D will also be driven to '1'. But if UUT is driving 'D' with a '0', then the net result will be that the Pin_D bit will be 'X'. Your subsequent lines such as 'Pin_10 <= Pin_D(15)' don't make much sense...but it should end up propagating the 'X' out to Pin_10.
What you want to do in this situation is port map in the following manner:
Code:
UUT : COMPONENT
PORT MAP( A => PIN_1,
B => PIN_2,
C => PIN_3 & PIN_4,
D(15) => PIN_10,
D(14) => PIN_61,
D(13) => PIN_11,
D(12) => PIN_62,
...etc...
);