array 2d in vhdl data transfer

Status
Not open for further replies.

p11

Banned
Joined
Jan 25, 2014
Messages
177
Helped
0
Reputation
0
Reaction score
0
Trophy points
16
Visit site
Activity points
0
Code:
architecture Behavioral of rom is  


type memory is array (0 to 7) of STD_LOGIC_VECTOR (3 DOWNTO 0);
constant dat : memory := (x"3", x"2",x"4", x"0",x"6",x"0",x"5",x"0");



now if i want to assign the 1st value of the array then how to do it ??? i mean if i write


dout (3 downto 0)<=dat (0) ( 3 downto 0);


is it ok ???
 

It's O.K. if dout type is std_logic_vector and 3 downto 0 a valid subrange. If dout is defined as std_logic_vector (3 downto 0), you can simply write
Code:
dout <= dat(0);
 
Reactions: p11

    p11

    Points: 2
    Helpful Answer Positive Rating
Code:
dout (3 downto 0)<=dat (0) [COLOR="#FF0000"](3 downto 0)[/COLOR] ;
It's fine.
But you can do without the part marked in red - this is because the array element is already defined as ( 3 downto 0 ) .
As long as the target of the assignment is of the same width as the source - there's no need to explicitly define the boundaries at the time of assignment.
 
Reactions: p11

    p11

    Points: 2
    Helpful Answer Positive Rating
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…