mahmood.n
Member level 5
I want to read some numbers in multiple clock cycles and put them in an array. The code is simple
Due to the global clock signal in my design, I want to terminate this read operation after reading 20 numbers. With that code, it is not possible. I have another version of such reading with for loop inside the clock event. There I can write
That means, in one clock read all numbers and assign them to the array elements. For large numbers (large inputSize), that becomes a bottleneck since all assign and increment (due to the array logic) have to be replicated.
Code:
package types is
constant inputSize: integer := 20;
constant maxNumber: integer := 8;
type intArray is array (0 to inputSize-1) of integer range 0 to maxNumber-1;
end;
entity read is
port( a: in integer range 0 to maxNumber-1;
clk: in std_logic;
z: out intArray);
end;
architecture arch1 of read is
begin
process( clk )
variable i: integer range 0 to inputSize-1 := 0;
variable myAr: intArray;
begin
if (clk'event and clk = '1') then
myAr(i) := a;
i := i + 1;
end if;
z <= myAr;
end process;
end;
Due to the global clock signal in my design, I want to terminate this read operation after reading 20 numbers. With that code, it is not possible. I have another version of such reading with for loop inside the clock event. There I can write
Code:
exit when i = inputSize;
That means, in one clock read all numbers and assign them to the array elements. For large numbers (large inputSize), that becomes a bottleneck since all assign and increment (due to the array logic) have to be replicated.