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.

Help me solve some problems with VHDL loops

Status
Not open for further replies.

sunli567

Junior Member level 1
Joined
Jan 4, 2009
Messages
17
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,281
Activity points
1,402
Hi friends,

I write the below codes to execute Z= X1*Y1+X2*Y2+...+X5*Y5
X and Y are both assigned as the array type and I set their each element.
But it always give the error that inputs X1 to X4 and Y1 to Y4 are not used.

process (X, Y)
begin
for i in 0 to 5 loop
r <= r + X(i)*Y(i);
end loop;
Z <= r;
end process;

I think there are some problems with i, but i do not know how to solve it.

And the other problem: I write below kind of code in the testbrench.
X0 <= 3, 7 after 10ns, 1 after 12ns;
but it give the following warning:
(vcom-1207) An abstract literal and an identifier must have a separator between them.

Please help me to solve these problems.
Thanks!

Sunny
 

vcom-1207

To calculate a sum in the iteration, you must use a variable
Code:
r := r + X(i)*Y(i);
A signal in contrast is only updated at the end of the process, the last assignment "wins", others are ignored.
 

vhdl loop array i+1

Thanks for your reply!
But if use ":=" in stead of "<=", it gives error "Cannot assign to signal 'r' " when ido the complie.

Added after 43 minutes:

This error related to the type i assigned. I assign 'r' as a signal, but X and Y must be signal (they are array of inputs). So 'r' should be a signal, too, not a variable. Then, the problem still exist. Waiting...
 

vhdl set loop iteration

I set r as the other array and use following codes to solve the first problem.

process (X, Y)
begin
r(0) <= 0;
for i in 0 to amount - 1 loop
r(i+1) <= r(i) + X(i)*Y(i);
end loop;
Z <= r(amount);
end process;

Is anybody help me solve my second problem?
 

how to write conditinal loop in vhdl

Thanks, I set the variable in out of prosess. Then, it always gives the error.
This one is solved now.

What about the second one?
When i write following codes in testbrench, it gives warning.
X(0) <= 3, 7 after 10ns, 1 after 12ns;
Please help me.
 

vhdl loop identifier

I had to consult IEEE 1076 to understand the warning. I think, it means, that you have to write 10 ns (with a space) instead of 10ns.
 

vhdl loop beispiel

Thank you very much. You are right. It should be 10 ns, not 10ns.
It tends to be difficult to solve the problem, when it does not give the direct reason. :D
 

variable vhdl loop array

can one use a non-continues range for the loop index ? .. in other words, I want to use a loop index that follows this: 0,2,4,6,8,10?
 

vhdl warning an abstract literal and identifier

I am not sure about that. But I think you can put constraint condition inside.
such as
for i in 0 to 8 loop
if (i%2=1) then ...
I does not test it. Hope this concept can hlep you.
 

vhdl looping variables

sunli567 said:
I am not sure about that. But I think you can put constraint condition inside.
such as
for i in 0 to 8 loop
if (i%2=1) then ...
I does not test it. Hope this concept can hlep you.

No, I don't mean that Sunli567.
I'm in a position that needs a discrete range of integers like the one I mentioned to be the loop index.
 

vhdl loop within loop

As far as I see, the VHDL standard doesn't provide non-consecutive discrete ranges. The VHDL term for a similar list of values is choices, but this syntax isn't available with a for iteration scheme. You may want to check with IEEE 1076 yourself.

The suggested conditional execution, is one possible solution, a derived index variable 2*i or a while iteration, that accepts any conditional expression, another.
 

vhdl loop

FvM said:
As far as I see, the VHDL standard doesn't provide non-consecutive discrete ranges. The VHDL term for a similar list of values is choices, but this syntax isn't available with a for iteration scheme. You may want to check with IEEE 1076 yourself.

The suggested conditional execution, is one possible solution, a derived index variable 2*i or a while iteration, that accepts any conditional expression, another.

Thanks FvM .. I managed to get it through to what I wanted .. I just declared an array with the integer values of my interest and I specified the loop like this :

for i in my_int_array'range loop

and it simply worked.

Sometimes, you can't just make it using (2*i) as your range might not follow an equation.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top