If slice names were extended to multi-dimensional arrays, then slices for one or more dimensions could work:
signal matrix : array(4 downto 0, 7 downto 0) of std_logic;
my_vector <= matrix(3 downto 1, 3);
-- This would slice off the 3rd bit of the 2nd dimension for each "row"
-- in the sliced matrix of (3 downto 1, 7 downto 0).
But, this syntax would not automatically have extended meaning for the array of arrays declaration that Jim provided below. I'd be concerned that such extension would cause syntactic ambiguities or other problems.
Perhaps what is needed is some form of repetition syntax that can be combined with the slice/index names we already have:
my_vector <= i in (3 downto 1) generate matrix(i, 3);
And for Jim's example:
col <= i in (0 to 4) generate Matrix_5x4(i)(3) ;
This could be defined such that nesting is possible. Consider an arbitrary 3D array:
z_axis_slice <= x in (2 to 5) generate (y in (0 to 2) generate threeD(x, y, 1));
If this is a bit cumbersome, consider the use of a "function call syntax":
my_vector <= matrix(generate(3 downto 1), 3);
col <= Matrix_5x4(generate(0 to 4), 3);
z_axis_slice <= threeD(generate(2 to 5), generate(0 to 2), 1);
This form could cause parsing problems due to the function call syntax. I'm hopeful that the (re)use of the keyword generate would disambiguate any parsing problems. (Actually, in re-reading it, the parsing ambiguity would probably be in trying to interpret "generate(x to/downto y)" as a slice name.) But, compiler gurus would know better. (BTW, I like this form because it is more concise and easy to read while leaving the existing slice and index name definitions alone -- thus ensuring backward compatibility.)
-Steve Bailey
> -----Original Message-----
> From: owner-vhdl-200x-ft@eda.org
> [mailto:owner-vhdl-200x-ft@eda.org <mailto:owner-vhdl-200x-ft@eda.org> ] On Behalf Of Jim Lewis
> Sent: Saturday, May 29, 2004 11:58 PM
> To: vhdl-200x-ft@eda.org
> Subject: [vhdl-200x-ft] FT14 arrays of arrays and slices
>
> With FT14/FT15, we can constrain array ports and signals
> using the following syntax:
> type std_logic_matrix is array (natural range<>) of
> std_logic_vector ;
> subtype Matrix_5x5 is std_logic_matrix(4 downto 0)(4 downto 0) ;
> signal A : std_logic_matrix(7 downto 0)(5 downto 0) ;
>
>
> Is there anything that can be done to make indexing of arrays
> of arrays more consistent with the above syntax?
>
> constant Matrix_5x4 : std_logic_matrix (0 to 4) := (
> 0 => "0000",
> 1 => "0001",
> 2 => "0010",
> 3 => "0011",
> 4 => "0100"
> ) ;
>
> signal row : std_logic_vector(3 downto 0) := (others => '0') ;
> signal partial_row1 : std_logic_vector(1 downto 0) :=
> (others => '0') ;
> signal partial_row2 : std_logic_vector(1 downto 0) :=
> (others => '0') ;
> signal col : std_logic_vector(0 to 4) := (others => '0') ; . . .
>
> row <= Matrix_5x4(4) ; -- "0100"
> partial_row1 <= Matrix_5x4(3)(1 downto 0) ; -- "11"
> partial_row2 <= Matrix_5x4(3)(2 downto 1) ; -- "01"
> -- col <= Matrix_5x4(0 to 4)(3) ; -- "0011"
> -- not what I want
>
> I would like Matrix_5x4(0 to 4)(3) = "00000" an array of std_logic.
>
> Is there a practical application of where the current syntax
> does something that is useful and in use?
>
> Do we need to consider additional syntax when constraining
> arrays of arrays so we can indicate what we are doing?
>
> For example:
> signal A : std_logic_matrix(7 downto 0).(5 downto 0) ;
>
> and:
> col <= Matrix_5x4(0 to 4).(3) ;
>
>
> For the full example, see the attached code.
>
> Cheers,
> Jim
> --
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Jim Lewis
> Director of Training mailto:Jim@SynthWorks.com <mailto:Jim@SynthWorks.com>
> SynthWorks Design Inc. http://www.SynthWorks.com <http://www.SynthWorks.com>
> 1-503-590-4787
>
> Expert VHDL Training for Hardware Design and Verification
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
------------
Stephen Bailey
ModelSim Verification TME
Mentor Graphics
sbailey@model.com
303-775-1655 (mobile, preferred)
720-494-1202 (office)
www.model.com <www.model.com>
Received on Sun May 30 08:06:09 2004
This archive was generated by hypermail 2.1.8 : Sun May 30 2004 - 08:06:13 PDT