cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Newbie
Newbie
286 Views
Registered: ‎05-04-2020

How to generate a succession of sums outside of a process

Jump to solution

Hi guys I'm new on the forum. I want to generate a succession of sums in vhdl like this:

Name : for k in 1 to precision generate

A <= A + shift_right(B,2*k-1) -shift_right(B,2*k);

end Generate;

But in this way it fails in implementation with error multiple driven pins. If I write all the succession manually it works but I need that the precision can be modified by a generic. Any advise?

Thanks

0 Kudos
1 Solution

Accepted Solutions
Highlighted
Voyager
Voyager
250 Views
Registered: ‎06-20-2012

Re: How to generate a succession of sums outside of a process

Jump to solution
Name : for k in 1 to precision generate
N1:IF (k = 1) GENERATE
A(1) <= shift_right(B,2*k-1) -shift_right(B,2*k);
End generate N1;
N2:IF (k /= 1) GENERATE
A(k) <= A(k-1) + shift_right(B,2*k-1) -shift_right(B,2*k);
End generate N2; 
end Generate Name;
SUM <= A(precision) ;
== If this was helpful, please feel free to give Kudos, and close if it answers your question ==

View solution in original post

0 Kudos
5 Replies
Highlighted
Scholar
Scholar
271 Views
Registered: ‎05-21-2015

Re: How to generate a succession of sums outside of a process

Jump to solution

@stemac00,

First piece of advice: "for" loops in RTL don't do what they do in software.  In software, a "for" loop will run something multiple times on successive time steps.  In RTL, N iterations created from a "for" loop will create N copies of the hardware described by the loop.  All of that hardware then operates on the same clock cycle.

This is probably not what you are interested in doing.

The other thing you are missing is the answer to the question: how does the data to get summed come into your core?  FPGAs are really good at streaming data.  If you want to sum a series of data values streamed into a core, then something like this might be closer to what you are looking for.

Dan

0 Kudos
Highlighted
Voyager
Voyager
255 Views
Registered: ‎06-20-2012

Re: How to generate a succession of sums outside of a process

Jump to solution

Why outside of a process ?

== If this was helpful, please feel free to give Kudos, and close if it answers your question ==
0 Kudos
Highlighted
Voyager
Voyager
251 Views
Registered: ‎06-20-2012

Re: How to generate a succession of sums outside of a process

Jump to solution
Name : for k in 1 to precision generate
N1:IF (k = 1) GENERATE
A(1) <= shift_right(B,2*k-1) -shift_right(B,2*k);
End generate N1;
N2:IF (k /= 1) GENERATE
A(k) <= A(k-1) + shift_right(B,2*k-1) -shift_right(B,2*k);
End generate N2; 
end Generate Name;
SUM <= A(precision) ;
== If this was helpful, please feel free to give Kudos, and close if it answers your question ==

View solution in original post

0 Kudos
Highlighted
Newbie
Newbie
233 Views
Registered: ‎05-04-2020

Re: How to generate a succession of sums outside of a process

Jump to solution

Outside a process because has to be an asynchronous module to implement a division by 3. I think that in this way it will work. Tomorrow I will try it. Thanks

0 Kudos
Highlighted
Voyager
Voyager
151 Views
Registered: ‎06-20-2012

Re: How to generate a succession of sums outside of a process

Jump to solution

A process can be also combinational or "asynchronous" as you said.

 

== If this was helpful, please feel free to give Kudos, and close if it answers your question ==
0 Kudos