Go Back   Velocity Reviews > Newsgroups > VHDL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

VHDL - Synthesis of variable index array

 
Thread Tools Search this Thread
Old 06-10-2007, 12:11 PM   #1
Default Synthesis of variable index array


Hello everyone,

I am new to VHDL and I am having problems with synthesis.

Is variable indexing of arrays (e.g. std_logic_vector) not really synthesizable?

For example,
-----
VARIABLE x : std_logic_vector(7 DOWNTO 0);
VARIABLE start : natural := 2;
VARIABLE end : natural := 4;
VARIABLE y : std_logic_vector(2 DOWNTO 0);
------
y := x(end DOWNTO start);

-------------------------------------------------

Why is this code not synthesizable? the tool I am using gives me
"Slice indices should be static"?

Is there someway to get around this in hardware?

The solution that I have till now is: Shifiting right and left till the part that we need remains and all others are 0's then ORing the parts that we need together.

Waiting for your replies.

Thank you very much
____
O.S.


oshouman
oshouman is offline   Reply With Quote
Old 06-10-2007, 01:30 PM   #2
Ahmed Samieh
Junior Member
 
Join Date: Mar 2007
Posts: 5
Default
Quote:
Originally Posted by oshouman
Why is this code not synthesizable? the tool I am using gives me
"Slice indices should be static"?

Is there someway to get around this in hardware?

the code is synthesizable, i'm using FPGA Advantage and xilinx ISE 9.1i

alias works too

Code:
ALIAS opcode : std_logic(3 DOWNTO 0) IS instruction(31 DOWNTO 28);


Ahmed Samieh
Ahmed Samieh is offline   Reply With Quote
Old 06-11-2007, 05:10 AM   #3
quantum_dot
Member
 
Join Date: Nov 2006
Posts: 32
Default
Hello Oshouman,
Well the synthesis will definetly show problem with your code. The compiler looks for the defined boundaries while synthesizing the VHDL code. Giving a local variable or global variable parameter would result in error.

So, instead of defining "start" and "end" as variables, define them as constant and then compile.

constant start : natural := 2;
constant end : natural := 4;
VARIABLE x : std_logic_vector(7 DOWNTO 0);
VARIABLE y : std_logic_vector(2 DOWNTO 0);
------
y := x(end DOWNTO start);


Hope this will solve your problem



quantum_dot
quantum_dot is offline   Reply With Quote
Old 06-24-2007, 11:04 PM   #4
oshouman
Junior Member
 
Join Date: Jun 2007
Posts: 6
Default
Dear Quantum_dot,

The idea is that I need to access a variable part (i.e. a slice of the vector) each time. In other words, the range changes each time the code executes.

Actually, I found a way to get around this, I do not really know if it is a stupid solution or a good one.

The idea is to have a separate function that copies a certain slice of a vector with start and end indeces to a target vector with different start and range indeces.

Here is the code (hint: I am new to VHDL and converting from programming):

Code:
FUNCTION copySliceN(input : std_logic_vector; leftIndexInput, rightIndexInput : natural; target : std_logic_vector; leftIndexTarget, rightIndexTarget : natural) RETURN std_logic_vector IS VARIABLE inputSlice : std_logic_vector(target'left TO target'right) := (OTHERS => '0'); VARIABLE conservedLeftPart : std_logic_vector(target'left TO target'right) := (OTHERS => '0'); VARIABLE conservedRightPart : std_logic_vector(target'left TO target'right) := (OTHERS => '0'); VARIABLE output : std_logic_vector(target'left TO target'right) := (OTHERS => '0'); BEGIN conservedLeftPart := SHR(target, conv_std_logic_vector(target'length-leftIndexTarget, 6)); conservedLeftPart := SHL(conservedLeftPart, conv_std_logic_vector(target'length-leftIndexTarget, 6)); conservedRightPart := SHL(target, conv_std_logic_vector(rightIndexTarget+1, 6)); conservedRightPart := SHR(conservedRightPart, conv_std_logic_vector(rightIndexTarget+1, 6)); inputSlice := conv_std_logic_vector(getSlice(input, leftIndexInput, rightIndexInput), target'length); inputSlice := SHL(inputSlice, conv_std_logic_vector(target'length-(rightIndexInput-leftIndexInput+1)-leftIndexTarget, target'length)); output := or3(conservedLeftPart, conservedRightPart, inputSlice); RETURN output; END;

The function or3 just ORs three vectors.

When I use this functon, it does what I need and it is synthesizable.

Thanks for your reply and concern.


oshouman

Last edited by oshouman : 06-24-2007 at 11:49 PM.
oshouman is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
constants as of array of integers, for loops octavsly Hardware 0 04-25-2009 11:53 AM
Array Programme rits Software 2 03-04-2009 05:18 PM
Passing value with out using variable in query string in PHP! Ali_ggl General Help Related Topics 0 11-29-2008 12:22 PM
synthesis error sekhar_kollati Hardware 0 11-13-2007 04:48 AM
Variable Scope in asp.Net jansi_rk Software 1 09-18-2006 06:05 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46