UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Observer daldoul
Observer
8,158 Views
Registered: ‎05-12-2012

VHDL " range=>'0' "

Hello all! I'm new to VHDL and i need some help to understand a statement
whitch uses range => '0' ; that's a part of the code

architecture Behavioral of hb_fir is

..............
..............

type tab_reg is array (K downto 0) of signed(15 downto 0)
signal reg2 :tab_reg;

.............
.............
reg2(1) <= (reg2(1)'range => '0'); whats this do?

............
............
............

end Behavioral;
 
 
0 Kudos
2 Replies
Mentor hgleamon1
Mentor
8,139 Views
Registered: ‎11-14-2011

Re: VHDL " range=>'0' "

I think the "range" descriptor refers to the size of the vector in number of bits. That is, the "range" of reg2 is 16 bits. This statement has the effect of assigning all bits in that vector (in this case, reg2(1)) to 0.

 

It is similar, I believe, to writing

 

reg2(1) <= (others => '0');

 

Hope this is true and therefore helps!

 

Regards,

 

Howard

 

----------
"That which we must learn to do, we learn by doing." - Aristotle
0 Kudos
Historian
Historian
8,129 Views
Registered: ‎02-25-2008

Re: VHDL " range=>'0' "


@daldoul wrote:
Hello all! I'm new to VHDL and i need some help to understand a statement
whitch uses range => '0' ; that's a part of the code

architecture Behavioral of hb_fir is

..............
..............

type tab_reg is array (K downto 0) of signed(15 downto 0)
signal reg2 :tab_reg;

.............
.............
reg2(1) <= (reg2(1)'range => '0'); whats this do?

............
............
............

end Behavioral;
 
 

If you have a signal declared like the following:

 

    signal foo : std_logic_vector(7 downto 0);

 

and you use the 'range attribute with it, like foo'range, the 'range has the value (7 downto 0).

 

A signal like this:

 

    signal bar: std_logic_vector(0 to 3);

 

has a 'range attribute foo'range as (0 to 3).

 

So say, for instance, you have a big vector and you want to assign a smaller vector to that bigger vector:

 

    signal bletch : std_logic_vector(31 downto 0);

 

you could do

 

    bletch(foo'range) <= foo;

 

if you want to assign the value of foo to the lower byte of bletch.

 

You can also loop over a range:

 

    thisloop : for bc in foo'range loop 

        foo(bc) <= something;

    end loop thisloop;

 

Attributes are useful conveniences. Use them!

----------------------------Yes, I do this for a living.