Hi
I have experienced the following error in the below attached code,
"Bounds of non-constant index addressing array reaches beyond the bounds of array" on line 131.(I have labelled line 131 in the below code).
I think it refers to the statement where i have used a variable "delay_val" as an index of the array "internal_reg". I have declared the variable "delay_val" and according to the code, it does not go beyond the maximum value of the register,"10".
I cannot understand why i am still getting this error. Please help.
CODE
----
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity test is
port(clock,reset,enable : in std_logic;
len : in std_logic_vector(0 to 1);
seq_num : in std_logic_vector(2 downto 0);
output : out std_logic;
delay_output,end_of_sequence : out std_logic;
edge_counter,delay,num_sequence,test5 : out integer
);
end test;
architecture behavioural of test is
signal new_bit: std_logic;
signal internal_reg: std_logic_vector(10 downto 0); "SIZE OF REGISTER = 11"
signal internal_reg_next: std_logic_vector(10 downto 0);
signal seq_indicator,new_seq: std_logic;
begin
code_gen: process(clock,reset)
variable count: integer;
variable delay_val: integer;
variable seq_val: integer;
variable code_length: integer;
variable num_seq: integer;
variable x: integer;
begin
edge_counter <= count;
delay <= delay_val;
end_of_sequence <= seq_indicator;
num_sequence <= seq_val;
test5 <= x;
case seq_num is
when "000" => num_seq := 50; when "001" => num_seq := 100; when "010" => num_seq := 150;
when "011" => num_seq := 200; when "100" => num_seq := 250; when "101" => num_seq := 300;
when "110" => num_seq := 350; when others => num_seq := 400;
end case;
case len is
when "00" =>
-- XOR bits 6,5,2,1
code_length := 64;
new_bit <= internal_reg(5) xor internal_reg(4);
output <= internal_reg(0);
internal_reg_next <= internal_reg(9 downto 0) & new_bit;
when "01" =>
-- XOR bits 7,6
code_length := 128;
new_bit <= internal_reg(6) xor internal_reg(5);
output <= internal_reg(0);
internal_reg_next <= internal_reg(9 downto 0) & new_bit;
when "10" =>
-- XOR bits 8, 4, 3, and 2
code_length := 256;
new_bit <= internal_reg(7) xor internal_reg(5) xor internal_reg(4) xor internal_reg(3);
output <= internal_reg(0);
internal_reg_next <= internal_reg(9 downto 0) & new_bit;
when OTHERS =>
--XOR bits 9,6,4,3
code_length := 512;
new_bit <= internal_reg(8) xor internal_reg(4);
output <= internal_reg(0);
internal_reg_next <= internal_reg(9 downto 0) & new_bit;
end case;
if (reset = '1') then
internal_reg <= (3 => '1', OTHERS => '0');
count := 0;
delay_val := 1;
seq_indicator <= '0';
seq_val := 0;
elsif (clock'EVENT AND clock ='1') then
if(enable = '1') then " LINE 131"
count := count+1;
internal_reg <= internal_reg_next;
delay_output <= internal_reg(delay_val); "PROBABLE ERROR LOCATION"
x:=(code_length*(seq_val+1));
if (count = x) then
seq_val := seq_val+1;
seq_indicator <= '1';
else seq_indicator <= '0';
end if;
if (seq_val = num_seq) then count := 0;
delay_val := delay_val+1;
seq_val := 0;
end if;
if (delay_val = 8) "delay_val" DOES NOT INCREASE TO MORE THAN 8 ACCORDING TO THIS LINE
delay_val := 1;
end if;
end if;
end if;
end process;
end behavioural;
I have experienced the following error in the below attached code,
"Bounds of non-constant index addressing array reaches beyond the bounds of array" on line 131.(I have labelled line 131 in the below code).
I think it refers to the statement where i have used a variable "delay_val" as an index of the array "internal_reg". I have declared the variable "delay_val" and according to the code, it does not go beyond the maximum value of the register,"10".
I cannot understand why i am still getting this error. Please help.
CODE
----
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity test is
port(clock,reset,enable : in std_logic;
len : in std_logic_vector(0 to 1);
seq_num : in std_logic_vector(2 downto 0);
output : out std_logic;
delay_output,end_of_sequence : out std_logic;
edge_counter,delay,num_sequence,test5 : out integer
);
end test;
architecture behavioural of test is
signal new_bit: std_logic;
signal internal_reg: std_logic_vector(10 downto 0); "SIZE OF REGISTER = 11"
signal internal_reg_next: std_logic_vector(10 downto 0);
signal seq_indicator,new_seq: std_logic;
begin
code_gen: process(clock,reset)
variable count: integer;
variable delay_val: integer;
variable seq_val: integer;
variable code_length: integer;
variable num_seq: integer;
variable x: integer;
begin
edge_counter <= count;
delay <= delay_val;
end_of_sequence <= seq_indicator;
num_sequence <= seq_val;
test5 <= x;
case seq_num is
when "000" => num_seq := 50; when "001" => num_seq := 100; when "010" => num_seq := 150;
when "011" => num_seq := 200; when "100" => num_seq := 250; when "101" => num_seq := 300;
when "110" => num_seq := 350; when others => num_seq := 400;
end case;
case len is
when "00" =>
-- XOR bits 6,5,2,1
code_length := 64;
new_bit <= internal_reg(5) xor internal_reg(4);
output <= internal_reg(0);
internal_reg_next <= internal_reg(9 downto 0) & new_bit;
when "01" =>
-- XOR bits 7,6
code_length := 128;
new_bit <= internal_reg(6) xor internal_reg(5);
output <= internal_reg(0);
internal_reg_next <= internal_reg(9 downto 0) & new_bit;
when "10" =>
-- XOR bits 8, 4, 3, and 2
code_length := 256;
new_bit <= internal_reg(7) xor internal_reg(5) xor internal_reg(4) xor internal_reg(3);
output <= internal_reg(0);
internal_reg_next <= internal_reg(9 downto 0) & new_bit;
when OTHERS =>
--XOR bits 9,6,4,3
code_length := 512;
new_bit <= internal_reg(8) xor internal_reg(4);
output <= internal_reg(0);
internal_reg_next <= internal_reg(9 downto 0) & new_bit;
end case;
if (reset = '1') then
internal_reg <= (3 => '1', OTHERS => '0');
count := 0;
delay_val := 1;
seq_indicator <= '0';
seq_val := 0;
elsif (clock'EVENT AND clock ='1') then
if(enable = '1') then " LINE 131"
count := count+1;
internal_reg <= internal_reg_next;
delay_output <= internal_reg(delay_val); "PROBABLE ERROR LOCATION"
x:=(code_length*(seq_val+1));
if (count = x) then
seq_val := seq_val+1;
seq_indicator <= '1';
else seq_indicator <= '0';
end if;
if (seq_val = num_seq) then count := 0;
delay_val := delay_val+1;
seq_val := 0;
end if;
if (delay_val = 8) "delay_val" DOES NOT INCREASE TO MORE THAN 8 ACCORDING TO THIS LINE
delay_val := 1;
end if;
end if;
end if;
end process;
end behavioural;