Increment an array of integers in VHDL

Status
Not open for further replies.

Farid Shamani

Newbie level 6
Joined
Jun 11, 2013
Messages
14
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
95
Hi friends,

I am wondering if there is any other way rather than FOR loop too increment an array of integers by a certain amount. I mean if I have a array of (12, 1, 15, 40, ... , 3) in next iteration all the elements increase by , e.g., one (13, 2, 16, 41, ... , 4).

Thank you
Farid
 

A for loop is the only way to do it. But why not wrap it inside a function?


Code VHDL - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function array_add_1( a : int_array_t) return int_array_t is
  variable ret : int_array_t(a'range);
begin
  for i in a'range loop
    ret(i) := a(i) + 1;
  end loop;
 
  return ret;
end function array_add_1;
 
 
.........
 
--in your code:
 
my_array <= array_add_1(my_array);

 
Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…