array slice notation

B

Brad Smallridge

Guest
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
 
On Sun, 14 Dec 2008 11:24:04 -0800, "Brad Smallridge" wrote:

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;
Because your newly-declared "bond_type" doesn't match the
"natural" subscript type of mem_do and mem_di_8.
Consider instead:

subtype type bond_range is natural range 15 downto 8;

Also, <= rather than <: but I guess that's just a typo.

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
That should be fine. Are you *sure* you wrote <= rather
than <: in the code????
--
Jonathan Bromley, Consultant

DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services

Doulos Ltd., 22 Market Place, Ringwood, BH24 1AW, UK
jonathan.bromley@MYCOMPANY.com
http://www.MYCOMPANY.com

The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.
 
On Sun, 14 Dec 2008 20:04:27 +0000, Jonathan Bromley wrote:

[I blame the drink...]

Because your newly-declared "bond_type" doesn't match
....

ah phooey, you called it "bond_range", sorry, my mistake.

Consider instead:

subtype type bond_range is natural range 15 downto 8;
Now that would be _really_ interesting syntax.
Let's try again, with feeling:

subtype bond_range is natural range 15 downto 8;

Apologies for the ramblings.
--
Jonathan Bromley, Consultant

DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services

Doulos Ltd., 22 Market Place, Ringwood, BH24 1AW, UK
jonathan.bromley@MYCOMPANY.com
http://www.MYCOMPANY.com

The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.
 
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
 
Brad Smallridge schrieb:
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
 
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
 
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
 

Welcome to EDABoard.com

Sponsor

Back
Top