• VHDL, easy peasy, right?

    From Rick C@21:1/5 to All on Thu Sep 24 13:46:58 2020
    Another day, another syntax issue...

    In my project library file.

    constant LED_Data_Max : natural := 23;
    subtype LED_Data_Type is unsigned (LED_Data_Max downto 0);
    type LED_RED_rng is range 23 downto 16;
    type LED_GRN_rng is range 15 downto 8;
    type LED_BLU_rng is range 7 downto 0;

    In the entity...

    procedure CommonAssert (
    LED_addr : natural;
    RGB : LED_Data_Type;
    Color_Ref : LED_Data_Type
    ) is
    begin
    assert (RGB = Color_Ref)
    report " LED " & integer'image(LED_addr) &
    " error, time = " & time'image(now) &
    ", Red = " & to_hstring(RGB(LED_RED_rng)) & ...

    The error complains about LED_RED_rng
    "Type of discrete range is different from the corresponding index"

    I just don't get what I am doing wrong. What would the discrete range "type" be??? Is this the same sort of problem I had previously where a non-constant can't be used to select a bit from a vector? Or is it so restrictive that I can't even use a
    fixed range of bits that aren't the entire vector?

    I would say I'm ready to use Verilog but I think that might be even more clumsy when trying to do things like this particular detail.

    --

    Rick C.

    - Get 1,000 miles of free Supercharging
    - Tesla referral code - https://ts.la/richard11209

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From andrew_b@21:1/5 to All on Thu Sep 24 22:26:16 2020
    0YfQtdGC0LLQtdGA0LMsIDI0INGB0LXQvdGC0Y/QsdGA0Y8gMjAyMCDQsy4sIDIzOjQ3OjAxIFVU QyszINC/0L7Qu9GM0LfQvtCy0LDRgtC10LvRjCBSaWNrIEMg0L3QsNC/0LjRgdCw0Ls6DQo+ICAg dHlwZSBMRURfUkVEX3JuZwlpcyByYW5nZSAyMyBkb3dudG8gMTY7DQoNCnN1YnR5cGUgTEVEX1JF RF9ybmcgaXMgaW50ZWdlciByYW5nZSAyMyBkb3dudG8gMTY7DQoNCi0tIA0KQW5kcmV3DQo=

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rick C@21:1/5 to All on Fri Sep 25 09:03:42 2020
    On Friday, September 25, 2020 at 1:26:20 AM UTC-4, andrew_b wrote:
    четверг, 24 сентября 2020 г., 23:47:01 UTC+3 пользователь Rick C написал:
    type LED_RED_rng is range 23 downto 16;

    subtype LED_RED_rng is integer range 23 downto 16;

    That doesn't do what I want. RGB is 24 bit data and I wish to extract the upper 8 bits. That requires a range. I don't want to do the math in every use, so a named range.

    This is provided in the standard. But I am not using it correctly and I don't understand why.

    To make it more clear, there are two more named ranges and two more lines of similar code.

    ", Green = " & to_hstring(RGB(LED_GRN_rng)) &
    ", Blue = " & to_hstring(RGB(LED_BLU_rng)) &

    To use the subtype you've defined it would need to be

    ", Red = " & to_hstring(RGB(LED_RED_rng'range)) &

    which is still more complexity than desired.

    --

    Rick C.

    + Get 1,000 miles of free Supercharging
    + Tesla referral code - https://ts.la/richard11209

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Nicolas Matringe@21:1/5 to Rick C on Fri Sep 25 23:24:55 2020
    On 9/25/20 6:03 PM, Rick C wrote:
    On Friday, September 25, 2020 at 1:26:20 AM UTC-4, andrew_b wrote:
    четверг, 24 сентября 2020 г., 23:47:01 UTC+3 пользователь Rick C
    написал:
    type LED_RED_rng is range 23 downto 16;

    subtype LED_RED_rng is integer range 23 downto 16;

    That doesn't do what I want.
    Well I really think it does.


    [...]
    To use the subtype you've defined it would need to be

    ", Red = " & to_hstring(RGB(LED_RED_rng'range)) &

    which is still more complexity than desired.

    No, the range attribute is only defined for objects of the array types.
    Again, I really think Andrew's suggestion is the way to go (I would have
    used natural instead of integer but it doesn't change anything)

    Nicolas

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rick C@21:1/5 to Nicolas Matringe on Fri Sep 25 16:24:31 2020
    On Friday, September 25, 2020 at 5:24:58 PM UTC-4, Nicolas Matringe wrote:
    On 9/25/20 6:03 PM, Rick C wrote:
    On Friday, September 25, 2020 at 1:26:20 AM UTC-4, andrew_b wrote:
    четверг, 24 сентября 2020 г., 23:47:01 UTC+3 пользователь Rick C
    написал:
    type LED_RED_rng is range 23 downto 16;

    subtype LED_RED_rng is integer range 23 downto 16;

    That doesn't do what I want.
    Well I really think it does.


    [...]
    To use the subtype you've defined it would need to be

    ", Red = " & to_hstring(RGB(LED_RED_rng'range)) &

    which is still more complexity than desired.

    No, the range attribute is only defined for objects of the array types. Again, I really think Andrew's suggestion is the way to go (I would have used natural instead of integer but it doesn't change anything)

    Nicolas

    Please show me what you mean. I don't see how to use an integer subtype to select the bits 23 downto 16 in the array RGB. Is it just

    RGB(LED_RED_rng)

    ???

    I would not expect that to work. Perhaps you can explain?

    I did see an example showing

    type Field_Range is range UPPER_BOUND downto LOWER_BOUND;

    It was in a discussion rather than from an authoritative source.

    --

    Rick C.

    -- Get 1,000 miles of free Supercharging
    -- Tesla referral code - https://ts.la/richard11209

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Nicolas Matringe@21:1/5 to Rick C on Sat Sep 26 11:14:10 2020
    On 9/26/20 1:24 AM, Rick C wrote:
    On Friday, September 25, 2020 at 5:24:58 PM UTC-4, Nicolas Matringe
    wrote:
    On 9/25/20 6:03 PM, Rick C wrote:
    > On Friday, September 25, 2020 at 1:26:20 AM UTC-4, andrew_b wrote:
    >> четверг, 24 сентября 2020 г., 23:47:01 UTC+3 пользователь Rick C
    написал:
    >>> type LED_RED_rng is range 23 downto 16;
    >>
    >> subtype LED_RED_rng is integer range 23 downto 16;
    >
    > That doesn't do what I want.
    Well I really think it does.


    [...]
    > To use the subtype you've defined it would need to be
    >
    > ", Red = " & to_hstring(RGB(LED_RED_rng'range)) &
    >
    > which is still more complexity than desired.

    No, the range attribute is only defined for objects of the array types.
    Again, I really think Andrew's suggestion is the way to go (I would have
    used natural instead of integer but it doesn't change anything)

    Nicolas

    Please show me what you mean. I don't see how to use an integer
    subtype to select the bits 23 downto 16 in the array RGB. Is it just

    RGB(LED_RED_rng)

    ???

    I would not expect that to work. Perhaps you can explain?
    Well I'm sorry I can't explain the reasons behind this, I'm not an LRM
    expert. I am absolutely no authoritative source.
    I know, because I've used it in the past, that you can define a subtype
    and use it as a range, at least in the declaration of an array object :

    subtype my_range is natural range 23 downto 16;
    signal my_vector is std_logic_vector(my_range);

    I see no reason why this wouldn't work in your case. Why don't you give
    it a try ?

    Nicolas

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rick C@21:1/5 to Nicolas Matringe on Sat Sep 26 17:43:58 2020
    On Saturday, September 26, 2020 at 5:14:14 AM UTC-4, Nicolas Matringe wrote:
    On 9/26/20 1:24 AM, Rick C wrote:
    On Friday, September 25, 2020 at 5:24:58 PM UTC-4, Nicolas Matringe
    wrote:
    On 9/25/20 6:03 PM, Rick C wrote:
    > On Friday, September 25, 2020 at 1:26:20 AM UTC-4, andrew_b wrote:
    >> четверг, 24 сентября 2020 г., 23:47:01 UTC+3 пользователь Rick C
    написал:
    >>> type LED_RED_rng is range 23 downto 16;
    >>
    >> subtype LED_RED_rng is integer range 23 downto 16;
    >
    > That doesn't do what I want.
    Well I really think it does.


    [...]
    > To use the subtype you've defined it would need to be
    >
    > ", Red = " & to_hstring(RGB(LED_RED_rng'range)) &
    >
    > which is still more complexity than desired.

    No, the range attribute is only defined for objects of the array types.
    Again, I really think Andrew's suggestion is the way to go (I would have
    used natural instead of integer but it doesn't change anything)

    Nicolas

    Please show me what you mean. I don't see how to use an integer
    subtype to select the bits 23 downto 16 in the array RGB. Is it just

    RGB(LED_RED_rng)

    ???

    I would not expect that to work. Perhaps you can explain?
    Well I'm sorry I can't explain the reasons behind this, I'm not an LRM expert. I am absolutely no authoritative source.
    I know, because I've used it in the past, that you can define a subtype
    and use it as a range, at least in the declaration of an array object :

    subtype my_range is natural range 23 downto 16;
    signal my_vector is std_logic_vector(my_range);

    I see no reason why this wouldn't work in your case. Why don't you give
    it a try ?

    Nicolas

    Ok, but you aren't saying it will work, you are saying it might work, try it. Sort of the hydroxychloroquine approach.

    I've worked around the issue now and have moved onto other parts of the design. When I have the time I may try it.

    Thanks,

    --

    Rick C.

    -+ Get 1,000 miles of free Supercharging
    -+ Tesla referral code - https://ts.la/richard11209

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)