-
-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Index range of array aggregate with others choice #641
Comments
Mhm, I have similar code and if I remember correctly had to change it. Questa or Synplify (I don't remember which one) didn't compiled it with a similar error. q <= (others => '0'); changed to q <= (q'range => '0'); Maybe a look into relevant sections of the LRM could help. |
@tmeissner yours is probably a better coding style - but NVC differs from other compilers in this minor respect. Questa is OK with this assignment in my testing. |
@amb5l Ah, okay. Maybe my problematic code was in a different context. I found LCS2016_072b which was incorporated in VHDL-19 standard. It adds functionality that However, |
Changing |
Yep, you're right. Maybe @JimLewis can help? I've looked where I had to use such a coding style and found it. I often use initializer functions for records, which often contain unconstrained vector elements. type t_axi4_m2s is record
VALID : std_logic;
WDATA : std_logic_vector;
...
end record; In the initializer function, I cannot use function initAxi4M2S return t_axi4_m2s is
begin
return (
VALID => '0',
WDATA => (WDATA'range => '0'),
...
);
end function |
Section 9.3 of the 2008 LRM says "The index range of an array aggregate that has an others choice shall be determinable from the context". It then goes on to list various different contexts, the only one of which I think is applicable here is:
But the target here is unconstrained. |
I've been looking at how target is defined in this situation. Section 11.4 Note 1 says:
It seems to me that if this is intention, then the compiler should treat the (in this case fully constrained) actual as the target, rather than the formal parameter. Set against this we have the note at the end of section 4.2.2.1:
This implies that the subprogram should be blind to attributes (like range) of the actual (the fully constrained signal). So I'm left thinking that NVC is LRM compliant and the other tools are relaxed. |
Correction. Section 4.2.2.3 says:
I think this tips the balance back towards the behaviour I see with GHDL, ModelSim etc. |
Does GHDL really not produce an error for this (I can't test at that moment)? See ghdl/ghdl#191 and also the proposal to relax this in -2019 which wasn't accepted: http://www.eda-twiki.org/cgi-bin/view.cgi/P1076/RelaxedOthersAggregate |
It does not. The command line is: |
How about if you remove |
You're absolutely right: What do you think about section 4.2.2.3... "a reference to the formal signal parameter within an expression is equivalent to a reference to the actual signal"... How can they be equivalent if the the unconstrained-ness of the formal trumps the constrained-ness of the actual? EDIT: I guess the word "expression" is key here. |
Yes, there's no expression involving I guess it should be possible to follow GHDL's behaviour and allow this with |
Would be good to add that to the wish list. With that said please feel free to close this one. |
@tmeissner My experience seems to concur with @nickg interpretation. OTOH, it seems like an odd that others is not allowed, but name'range fixes the issue. With 'range, it seems like we are saying, make the expression the exact size of the elaborated port/parameter - because after elaboration, they are no longer unconstrained. So it makes me wonder why when the aggregate uses I have also wondered why we don't have an That said, would I personally write such a change - probably not. Would I support a well written change for this - probably - but a sensible argument from Nick or Tristan could convince me otherwise. One thing we learned when doing 2008 was that some restrictions were added in the original language because they expected them to be needed, but it turned out that the restrictions were not necessary - in particular the case statement expression needing to have a locally static type. |
I am assigning an unconstrained std_logic_vector signal in a procedure:
q <= (others => '0');
NVC does not like this:
Error: index range of array aggregate with others choice cannot be determined from the context
Xilinx XSim is happy with this code, and I think GHDL is too (although it fails for other reasons).
Here's an MCVE, which you can try with
nvc --std=2008 -a --relaxed mcve.vhd
:The text was updated successfully, but these errors were encountered: