array slice notation

B

Brad Smallridge

Why can't I do this:
type bond_range is range 15 downto 8;
begin
mem_do(bond_range)<:mem_di_8(bond_range); -- wrong slice type;

or this:
constant bond_hi:integer:=15;
constant bond_lo:integer:=8;
begin
mem_do(bond_hi downto bond_lo)<:mem_di_8(bond_hi downto bond_lo);
-- not the name of a procedure

instead of this:
begin
mem_do(15 downto 8)<:mem_di_8(15 downto 8);


I would use a record for mem_do but mem_do
slices change depending on when I write to it.

Brad Smallridge
AiVision
 
B

Brad Smallridge

Apologies for the ramblings. Jonathan Bromley DOULOS

Yes <: was an email typo and the constants method failed
because I left off the right end therefore the "not a
procedure" message. I don't fully understand the subtype
natural range syntax but it works. Thanks for your ramblings.

Brad Smallridge
Ai Vision
 
B

backhus

Brad said:
Why can't I do this:
type bond_range is range 15 downto 8;
begin
mem_do(bond_range)<:mem_di_8(bond_range); -- wrong slice type;

or this:
constant bond_hi:integer:=15;
constant bond_lo:integer:=8;
begin
mem_do(bond_hi downto bond_lo)<:mem_di_8(bond_hi downto bond_lo);
-- not the name of a procedure

instead of this:
begin
mem_do(15 downto 8)<:mem_di_8(15 downto 8);


I would use a record for mem_do but mem_do
slices change depending on when I write to it.

Brad Smallridge
AiVision

Hi Brad,
maybe the 'range is useful for your purposes:

eg:
signal mem_do_1 : std_logic_vector (15 downto 8);
signal mem_do_2 : std_logic_vector (7 downto 0);
signal mem_di : std_logic_vector (15 downto 0)
....

mem_do_1(mem_do_1'range) <= mem_di(mem_do_1'range);
mem_do_2(mem_do_2'range) <= mem_di(mem_do_2'range);

Have a nice synthesis
Eilert
 
A

Andy

I use that trick a lot. Note that "mem_do_1(mem_do_1'range)" is
superfluous; "mem_do_1" is sufficient.

Sometimes I define the smaller elemnts, or aliases thereof, to have
non-zero-justified ranges:

variable smaller_slice: std_logic_vector(15 downto 8);

bigger_slice(smaller_slice'range) := smaller_slice;

Andy
 
B

Brad Smallridge

Yeah, 'range and aliases are good techniques,
but I think Bromley hit best for me since I am
reading and writing a lot of fields to and from
memory, so the mem_do(x)<=mem_di(x); format is
really clean and is self documenting.

Brad Smallridge
AiVision
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top