Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Synthesis support for 3D HDL arrays

Status
Not open for further replies.

shaiko

Advanced Member level 5
Joined
Aug 20, 2011
Messages
2,644
Helped
303
Reputation
608
Reaction score
297
Trophy points
1,363
Activity points
18,302
Hello,

From your experience,
Do modern FPGA synthesis tools ( Vivado / Quartus Prime ) support 3D (or higher dimension) arrays ?
 

This is what I want to do:

Code:
-- All array elements are intended to be DFFs

----- Entity generics -----
PIXEL_WIDTH 	:	positive := 8 ;
PIXELS_PER_ROW  :	positive := 16 ;
ROWS_PER_FRAME  :	positive := 9 ;
------------------------------

----- The custom types -----
type generic_pixel is std_logic_vector ( PIXEL_WIDTH - 1 downto 0 ) ;
type generic_row is array ( 0 to PIXELS_PER_ROW - 1 ) of generic_pixel ;
type generic_frame is array ( 0 to ROWS_PER_FRAME - 1 ) of generic_row ;
------------------------------

----- Signals declartion of custom type -----
signal pixel : 	generic_pixel ;
signal row :	generic_row ;
signal frame :	generic_frame ;
------------------------------
 

Do modern FPGA synthesis tools ( Vivado / Quartus Prime ) support 3D (or higher dimension) arrays ?
Yes. According to the respective HDL capabilities.
 

Have you ever tried and succeeded synthesizing something similar to what I wrote in #2 ?
 

Whats stopping you from running a small design through synthesis to get a result?
I was using a 2D (real 2d, not 1D of 1D like you example) array of sfixed type in quartus 7 years ago and it compiled and inferred multipliers just fine. I would hope this capability still remains.
 
  • Like
Reactions: shaiko

    shaiko

    Points: 2
    Helpful Answer Positive Rating
Whats stopping you from running a small design through synthesis to get a result?
My next step.

I was using a 2D (real 2d, not 1D of 1D like you example)
Can you please post a short example?
 

code using this type synthesised just fine:

Code:
type filter_array_t is  array(-1 to 1, -1 to 1) of sfixed(9 downto -8);


I suggest trying your own code example.
 
  • Like
Reactions: shaiko

    shaiko

    Points: 2
    Helpful Answer Positive Rating
TrickyDicky,

So if I want to define a 3D array - the syntax is:
Code:
type generic_3d_array is  array( 0 to 15 , 0 to 31 ) of x ( 7 downto 0 );

And if I want to assign a value to an element I write for example :
Code:
generic_3d_array ( 5 ) ( 3 ) <= "01110000" ;
?
 

That is not a 3D array - it is a 2D array of a 1D array type.
N d arrays are indexed using a comma (,).

so in your case:

generic_3d_array_signal(5,3) <= "01110000";

Just so that you know - slicing Nd arrays is illegal
 
So how would you define a true 3d array?
Will it be like this?
type generic_3d_array is array( 0 to 15 , 0 to 31 , 7 downto 0)
 

So how would you define a true 3d array?
Will it be like this?
type generic_3d_array is array( 0 to 15 , 0 to 31 , 7 downto 0)

Yes

Kevin
 
  • Like
Reactions: shaiko

    shaiko

    Points: 2
    Helpful Answer Positive Rating
So how would you define a true 3d array?
Will it be like this?
type generic_3d_array is array( 0 to 15 , 0 to 31 , 7 downto 0)

Kevin, Isn't this a 3D array of some unspecified type? Along with a really strange 7 downto 0 index for one of the array dimensions.

I'll admit I get somewhat confused when people start describing things like:
Code:
type filter_array_t is  array(-1 to 1, -1 to 1) of sfixed(9 downto -8);
as a 3D array, to me it's a 2D array of sfixed types.

So as an example for a Rubik's cube...
Code:
type colors is (red, green, blue, yellow, white, orange);
type rubiks is array(1 to 3, 1 to 3, 1 to 3) of colors;
Not sure if this is correct or not (and admittedly I'm too lazy to try this out).
 
  • Like
Reactions: shaiko

    shaiko

    Points: 2
    Helpful Answer Positive Rating
"IN_FRAME" is an entity input. defined as follows:
Code:
IN_FRAME : generic_3d_array ( 0 to ROWS_PER_FRAME ) - 1 , 0 to PIXELS_PER_ROW - 1 , BITS_PER_PIXEL - 1 downto 0 ) ;

"row" is a signal that's defined as follows:
Code:
signal row : generic_2d_array ( 0 to PIXELS_PER_ROW - 1 , BITS_PER_PIXEL - 1 downto 0 ) ;

"pixel" is a signal that's defined as follows:
Code:
signal pixel : std_logic_vector ( BITS_PER_PIXEL - 1 downto 0 ) ;
I want to do 2 things:

1. Assign a row element from "IN_FRAME" into signal "row" - Is this the correct syntax to do so?
row <= IN_FRAME ( some_row_number ) ;
2. Assign a pixel element from "IN_FRAME" into signal "pixel" - Is this the correct syntax?
pixel <= IN_FRAME ( some_row_number , some_pixel_number ) ;
 

Code:
signal row : generic_2d_array ( 0 to PIXELS_PER_ROW - 1 , BITS_PER_PIXEL - 1 downto 0 ) ;
see this confuses me to no end...

if you access this row array you end up with

Code:
row(1,4)

which in my mind says you are looking at bit-4 of pixel 1 in the row, if that is what you are after, then I agree that this is a 2d array, but if you are trying to get the pixel value (the BITS_PER_PIXEL -1 downto 0 stuff) then I consider this a 1d array with each array element being a pixel value of BITS_PER_PIXEL width.

Tricky help I'm so confused! :)
 
  • Like
Reactions: shaiko

    shaiko

    Points: 2
    Helpful Answer Positive Rating
"IN_FRAME" is an entity input. defined as follows:
Code:
IN_FRAME : generic_3d_array ( 0 to ROWS_PER_FRAME ) - 1 , 0 to PIXELS_PER_ROW - 1 , BITS_PER_PIXEL - 1 downto 0 ) ;

"row" is a signal that's defined as follows:
Code:
signal row : generic_2d_array ( 0 to PIXELS_PER_ROW - 1 , BITS_PER_PIXEL - 1 downto 0 ) ;

"pixel" is a signal that's defined as follows:
Code:
signal pixel : std_logic_vector ( BITS_PER_PIXEL - 1 downto 0 ) ;
I want to do 2 things:

1. Assign a row element from "IN_FRAME" into signal "row" - Is this the correct syntax to do so?
row <= IN_FRAME ( some_row_number ) ;
2. Assign a pixel element from "IN_FRAME" into signal "pixel" - Is this the correct syntax?
pixel <= IN_FRAME ( some_row_number , some_pixel_number ) ;

Neither assignment is correct because you have left off the second and/or third index for IN_FRAME. You need to write some functions like 'Get_Row' and 'Get_Pixel' to do what you intend. Both functions will take as input a generic_3d_array parameter as well as the 'some_row_number' and 'some_pixel_number' parameters that you list. So the assignments would look like this:

Code:
row <= Get_Row(IN_FRAME, some_row_number) ; 
pixel <= Get_Pixel(IN_FRAME, some_row_number ,  some_pixel_number ) ;

Kevin Jennings
 
  • Like
Reactions: shaiko

    shaiko

    Points: 2
    Helpful Answer Positive Rating
see this confuses me to no end...
ads-ee,

I might be wrong calling it a 2d array...
Sorry :)

- - - Updated - - -

Neither assignment is correct because you have left off the second and/or third index for IN_FRAME.

That's what Trickydicky meant by:
Just so that you know - slicing Nd arrays is illegal
?
 

with a 2d array, you cannot slice so the following is illegal:

Code:
IN_FRAME : generic_3d_array ( 0 to ROWS_PER_FRAME  - 1 , 0 to PIXELS_PER_ROW - 1 , BITS_PER_PIXEL - 1 downto 0 ) ;

SOME_SIGNAL <= IN_FRAME(0 to 3, 0 to 1, 7 downto 0);  -- illegal

For what you want to do, I suggest arrays of arrays.
 
  • Like
Reactions: shaiko

    shaiko

    Points: 2
    Helpful Answer Positive Rating
K-J,
In #15 you wrote:
Neither assignment is correct because you have left off the second and/or third index for IN_FRAME.
Assume the following code:

Code:
signal x is array ( 0 to 2 ) of std_logic_vector ( 7 downto 0 ) ;
signal y : std_logic_vector ( 7 downto 0 ) ;  
y <= x ( 1 ) ;

Despite the fact that I left off the second boundary of x - the above will be legal.

How is it any different than:
Code:
row <= IN_FRAME ( some_row_number ) ;
?
 

K-J,
In #15 you wrote:

Assume the following code:

Code:
signal x is array ( 0 to 2 ) of std_logic_vector ( 7 downto 0 ) ;
signal y : std_logic_vector ( 7 downto 0 ) ;  
y <= x ( 1 ) ;

Despite the fact that I left off the second boundary of x - the above will be legal.

How is it any different than:
Code:
row <= IN_FRAME ( some_row_number ) ;
?

The first code returns a known type - a std logic vector.
The second code would return an indeterminant type - you're basically slicing the array. 2+D arrays can only be indexed to individual elements.
 
  • Like
Reactions: shaiko

    shaiko

    Points: 2
    Helpful Answer Positive Rating
So to achieve what I want - I can either:
1. use an array of array.
2. use a custom function like K-J suggested.

Correct?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top