VHDL, easy peasy, right?...

R

Rick C

Guest
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
 
четверг, 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;

--
Andrew
 
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
 
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
 
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
 
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
 
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
 

Welcome to EDABoard.com

Sponsor

Back
Top