problem in access one bit of array

Status
Not open for further replies.

digital design

Junior Member level 2
Joined
Oct 27, 2012
Messages
20
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,446
Hi every body
I have bellow code:

Code VHDL - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
-- Four-bits divider
library IEEE;
use IEEE.std_logic_1164.all;
 
entity Divider_nBits is
    generic(N : integer :=4);
    port ( divisor   : in  std_logic_vector(N-1 downto 0);     -- divisor
           dividend  : in  std_logic_vector(2*N-2 downto 0);   -- dividend
           remainder : out std_logic_vector(N-1 downto 0);     -- remainder
           quotient  : out std_logic_vector(N-1 downto 0)      -- quotient
         );
end entity ;
 
---------------------- Architecture Section ----------------------------------
 
architecture Stractural of Divider_nBits is
--------------- Signal Declarations for instantiate
 
type   c_array   is array (0 to N-1)  of std_logic_vector(0 downto N)  ;
type   r_array   is array (0 to N-1)  of std_logic_vector(0 downto N-1);
 
signal sig_r : r_array ;
signal sig_c : c_array ;
 
begin
 
  
-- Instantiate N single-bit controlled add/subtract
    LGEN: for i in 0 to N-1 generate
     LGEN2:     for j in 0 to N-1 generate
      First_column:if j=0 and i/=N-1 generate   
       CAS_i3:entity work.CAS(ADD_SUB)           -- First Column
       port map ( divisor       => divisor(j)           ,
                  reminder_in   => dividend(j)          ,
                  T             => not sig_r(i+1)(N-1)  , 
                  cin           => sig_c(i)(j)          ,
                  reminder_out  => sig_r(i)(j)          ,
                  cout          => sig_c(i)(j+1)       );
       end generate;
      Last_stage: if i=N-1 and j/=0 generate     -- Last row
       CAS_ij:entity work.CAS(ADD_SUB)
       port map ( divisor       => divisor(j)      ,
                  reminder_in   => dividend(j+N-1) ,
                  T             => '1'             ,
                  cin           => sig_c(i)(j)     ,
                  reminder_out  => sig_r(i)(j)     ,
                  cout          => sig_c(i)(j+1)  );
       end generate;
      other_stage: if i/=N-1 and j/=0 generate    -- others
       CAS_i2:entity work.CAS(ADD_SUB)
       port map ( divisor       => divisor(j)          ,
                  reminder_in   => sig_r(i+1)(j-1)     ,
                  T             => not sig_r(i+1)(N-1) ,
                  cin           => sig_c(i)(j)         ,
                  reminder_out  => sig_r(i)(j)         ,
                  cout          => sig_c(i)(j+1)      );
       end generate;
  
     end generate;           
    end generate;
 
 
end ;



I have bellow errors in synthesize:

first error is about this line of code :
Code:
                 T             => not sig_r(i+1)(N-1)  , 
N-1 = 3 
type   r_array   is array (0 to N-1)  of std_logic_vector(0 downto N-1);
signal sig_r : r_array ;

3 is in range but I can't find out reason of errors..!!
please help me....
 
Last edited by a moderator:

Taking a brief look at the code, in line...

Code:
T             => not sig_r(i+1)(N-1)  ,

...It looks like the index i inside the for loop is attempting to access the sig_r variable beyond the magnitude of 3 bits, that was declared at the line...

Code:
type   r_array   is array (0 to N-1)  of std_logic_vector(0 downto N-1);
 

Sorry, I can't find out your mean...
Do you mean my code is false ?
 

At line 35, (i+1) goes outside the bounds of the array when i = N-1
 

ah, ok. This might be the issue. From what I can tell, that results in a 0 length vector. Any indexing fails. I suspect the code for reporting the error is shared between VHDL and Verilog, so it reports something that looks like a valid type.
 

ah, ok. This might be the issue. From what I can tell, that results in a 0 length vector. Any indexing fails. I suspect the code for reporting the error is shared between VHDL and Verilog, so it reports something that looks like a valid type.

Certainly looks that way
Im pretty sure with Quartus is warns you about a null array and gives a more useful error message.
 

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…