shaiko
Advanced Member level 5
- Joined
- Aug 20, 2011
- Messages
- 2,644
- Helped
- 303
- Reputation
- 608
- Reaction score
- 297
- Trophy points
- 1,363
- Activity points
- 18,302
I have a custom type that's defined as follows:
signal x is declared as follows:
signal x : unconstrained_array ;
I want to write a loop that assignes to x an array of incrementing unsigned numbers as follows:
"0000"
"0001"
"0010"
.
.
.
"1111"
However, becuse x is an unconstrained array, I want the code to be generic and except any width and depth of x.
This is what I wrote so far:
What do you think? Anything I should fix?
Code:
type unconstrained_array is array ( natural range <> ) of unsigned ;
signal x is declared as follows:
signal x : unconstrained_array ;
I want to write a loop that assignes to x an array of incrementing unsigned numbers as follows:
"0000"
"0001"
"0010"
.
.
.
"1111"
However, becuse x is an unconstrained array, I want the code to be generic and except any width and depth of x.
This is what I wrote so far:
Code:
for index in x ' range
loop
x ( index ) <= to_unsigned ( index , ( x ' length ) ) ;
end loop ;
What do you think? Anything I should fix?