Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] 2D ARRAY problem (VHDL)

Status
Not open for further replies.

nikhilsigma

Full Member level 2
Joined
Jun 19, 2010
Messages
142
Helped
17
Reputation
34
Reaction score
16
Trophy points
1,298
Location
Delhi, India
Activity points
2,584
hi everyone....

i am having problem in reading the value of an 1D-1D array....
problematic lines are marked with comments in the following 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
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
 
 
entity arrr is
    Port (  clk : in std_logic;
            data : out  STD_LOGIC_VECTOR (15 downto 0));
end arrr;
 
architecture Behavioral of arrr is
 
type m1 is array (0 to 1) of std_logic_vector(15 downto 0);
signal mem : m1;
 
begin
 
process(clk)
variable q : integer:=0;
variable r : std_logic_vector(15 downto 0);
begin
    if (rising_edge(clk))
        then
        if(q=0)
            then
            mem<=(others => (others => '0'));
            mem(0)<="1111111111001111";
            mem(1)(15 downto 0)<=mem(0)(15 downto 0);   -- THIS LINE IS NOT WORKING
            q:=1;
                        r:=mem(0)(15 downto 0);                     -- THIS IS ALSO NOT WORKING
 
         else
            data<=mem(1);
        end if;
    end if;
end process;
        
        
        
        
end Behavioral;




please tell me why the above assignment is not working.......

Note : this type of assignment is also illustrated in pedroni [VHDL BOOK] in section 3.4
 

THIS LINE IS NOT WORKING should be rephrased into not doing what you expect it to do?

But I guess it's behaving according to the VHDL specification as follows:
- in the first clock cycle assigning the constant to mem(0) and the previous value of mem(0) (usually all zero) to mem(1)
- in all succeeding cycles assigning the value of mem(1) (all zero) to data

Some compilers may remove the initial value q:=0 in optimization, because the value is never assigned again.
 
that statement is not assigning anything to the mem(1) !!!
here is the simulation result....

Untitled.jpg

- - - Updated - - -

also if I change line no.35 to

Code VHDL - [expand]
1
data<=mem(0);

then the output comes and the data shows the value of mem(0) .i.e. the initialized one......

- - - Updated - - -

here is the result for that...

Untitled.jpg

- - - Updated - - -

here are also some proofs that it should work !!
http://vhdlguru.blogspot.in/2010/02/arrays-and-records-in-vhdl.html
http://vhdlguru.blogspot.in/2010/03/some-tricky-coding-methods-using-vhdl.html

so why it is NOT working for me ????? :-?

- - - Updated - - -

OH I AM REALLY SORRY !!!!

I AM SO STUPID !!! :idea:

sorry guys.... and thanks FvM.. :)
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top