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

Reply

VHDL - loop question

 
Thread Tools Search this Thread
Old 01-14-2005, 03:16 PM   #1
Default loop question


Hello

I have I quick question:

I have a combinatorical process which should be activated everytime the
input changes. In this process the bits should be stored in the following
way:

signal c: std_ulogic_vector(199 downto 0);

comb : process (inp)
begin
for i in 0 to 599 loop
c(i) <= inp(3*i);
end loop;

Unfortunately the compiler doesnt allow loops in this kind of process
(sequentiell statement). Is there any other loop construct which I could use
to perform this easy assignment?

Thanks a lot!






Richard
  Reply With Quote
Old 01-14-2005, 03:43 PM   #2
Nicolas Matringe
 
Posts: n/a
Default Re: loop question
Richard a écrit :
> Hello
>
> I have I quick question:
>
> I have a combinatorical process which should be activated everytime the
> input changes. In this process the bits should be stored in the following
> way:
>
> signal c: std_ulogic_vector(199 downto 0);
>
> comb : process (inp)
> begin
> for i in 0 to 599 loop
> c(i) <= inp(3*i);
> end loop;
>
> Unfortunately the compiler doesnt allow loops in this kind of process
> (sequentiell statement). Is there any other loop construct which I could use
> to perform this easy assignment?


Hello Richard
Loops are allowed inside any process. The problem I see there is that c
is 200 bits long and your loop iterates 600 times.
What exactly do you want to do?
--
____ _ __ ___
| _ \_)/ _|/ _ \ Adresse de retour invalide: retirez le -
| | | | | (_| |_| | Invalid return address: remove the -
|_| |_|_|\__|\___/


Nicolas Matringe
  Reply With Quote
Old 01-14-2005, 03:46 PM   #3
Egbert Molenkamp
 
Posts: n/a
Default Re: loop question

"Richard" <> wrote in message
news:...
> Hello
>
> I have I quick question:
>
> I have a combinatorical process which should be activated everytime the
> input changes. In this process the bits should be stored in the following
> way:
>
> signal c: std_ulogic_vector(199 downto 0);
>
> comb : process (inp)
> begin
> for i in 0 to 599 loop
> c(i) <= inp(3*i);
> end loop;
>
> Unfortunately the compiler doesnt allow loops in this kind of process
> (sequentiell statement). Is there any other loop construct which I could

use
> to perform this easy assignment?
>
> Thanks a lot!


Notice that the index i is out of the range of signal c. Maybe that is the
problem?
The following example simulates and is synthesisable (with the tool I use).

library ieee;
use ieee.std_logic_1164.all;
entity tstlp is
port (a : in std_logic_vector(12 downto 0);
b : out std_logic_vector(4 downto 0));
end tstlp;

architecture beh of tstlp is

begin
comb : process (a)
begin
for i in 0 to 4 loop
b(i) <= a(3*i);
end loop;
end process;

end beh;

Egbert Molenkamp




Egbert Molenkamp
  Reply With Quote
Old 01-14-2005, 04:22 PM   #4
Richard
 
Posts: n/a
Default Re: loop question
Hello

Thanks for your answers, here is the complete code fragment:

comb : process(inp)
begin

for i in 0 to (width/3)-1 loop
c0((2*i+1) downto (2*i))<=inp((6*i+1) downto (6*i));
c1((2*i+1) downto (2*i))<=inp((6*i+3) downto (6*i+2));
c2((2*i+1) downto (2*i))<=inp((6*i+5) downto (6*i+4));
end loop;

term0 <= c2((2*width/3)-1 downto 0) & c1((2*width/3)-1 downto 0) &
c0((2*width/3)-1 downto 0);
term1 <= c1((2*width-19) downto 0) & (17 downto 0 => '0');

adder: for I in 0 to (width-1) generate
add1_I: add port
map(term0(2*I+1),term0(2*I),term1(2*I+1),term1(2*I ),pp1(2*I+1),pp1(2*I));
end generate;

end process;

The problem is since I introduced the first for loop in the comb process I
get an error message with
the generate statement

adder: for I in 0 to (width-1) generate
add1_I: add port
map(term0(2*I+1),term0(2*I),term1(2*I+1),term1(2*I ),pp1(2*I+1),pp1(2*I));

Error message:

Illegal sequential statement.

At the beginning I had the first for-loop in the seqentiel logic, then
everything worked properly! I dont know what is going on now. The adder is a
simple adder module constisting of a few logical gates.

Does anybody of you know what went wrong?

Thanks again!





Richard
  Reply With Quote
Old 01-14-2005, 10:14 PM   #5
Nick
 
Posts: n/a
Default Re: loop question
On Fri, 14 Jan 2005 16:22:03 -0000, "Richard" <>
wrote:

>Hello
>
>Thanks for your answers, here is the complete code fragment:
>
> comb : process(inp)
> begin
>
> for i in 0 to (width/3)-1 loop
> c0((2*i+1) downto (2*i))<=inp((6*i+1) downto (6*i));
> c1((2*i+1) downto (2*i))<=inp((6*i+3) downto (6*i+2));
> c2((2*i+1) downto (2*i))<=inp((6*i+5) downto (6*i+4));
> end loop;


My Quartus doesn't allow things like this...
What i must do is
c0[2*i+1) <= inp(6*i+1);
c0[2*i) <= inp(6*i);
etc

Nick


Nick
  Reply With Quote
Old 01-15-2005, 10:02 AM   #6
Egbert Molenkamp
 
Posts: n/a
Default Re: loop question
Notice that the error message gives exactly the answer.
The generate statement is a concurrent statement. So you may use it as a
sequential statement (in a process, procedure and function).
Maybe the "end process" should move upwards just after the end of the first
loop.
> comb : process(inp)
> begin
>
> for i in 0 to (width/3)-1 loop
> c0((2*i+1) downto (2*i))<=inp((6*i+1) downto (6*i));
> c1((2*i+1) downto (2*i))<=inp((6*i+3) downto (6*i+2));
> c2((2*i+1) downto (2*i))<=inp((6*i+5) downto (6*i+4));
> end loop;

end process; --HERE

Then the first process, with lable COMB, behaves combinational. All input
signals are in the sensitivity list (in this case INP).
Furthermore after this move a change of c0 will change term0 immediatly
(more precily after one delta). In your case term0 is changed after a second
second change of INP.

Egbert Molenkamp

"Richard" <> schreef in bericht
news:...
> Hello
>
> Thanks for your answers, here is the complete code fragment:
>
> comb : process(inp)
> begin
>
> for i in 0 to (width/3)-1 loop
> c0((2*i+1) downto (2*i))<=inp((6*i+1) downto (6*i));
> c1((2*i+1) downto (2*i))<=inp((6*i+3) downto (6*i+2));
> c2((2*i+1) downto (2*i))<=inp((6*i+5) downto (6*i+4));
> end loop;
>
> term0 <= c2((2*width/3)-1 downto 0) & c1((2*width/3)-1 downto 0) &
> c0((2*width/3)-1 downto 0);
> term1 <= c1((2*width-19) downto 0) & (17 downto 0 => '0');
>
> adder: for I in 0 to (width-1) generate
> add1_I: add port
> map(term0(2*I+1),term0(2*I),term1(2*I+1),term1(2*I ),pp1(2*I+1),pp1(2*I));
> end generate;
>
> end process;
>
> The problem is since I introduced the first for loop in the comb process I
> get an error message with
> the generate statement
>
> adder: for I in 0 to (width-1) generate
> add1_I: add port
> map(term0(2*I+1),term0(2*I),term1(2*I+1),term1(2*I ),pp1(2*I+1),pp1(2*I));
>
> Error message:
>
> Illegal sequential statement.
>
> At the beginning I had the first for-loop in the seqentiel logic, then
> everything worked properly! I dont know what is going on now. The adder is
> a simple adder module constisting of a few logical gates.
>
> Does anybody of you know what went wrong?
>
> Thanks again!
>
>
>





Egbert Molenkamp
  Reply With Quote
Old 01-15-2005, 10:04 AM   #7
Egbert Molenkamp
 
Posts: n/a
Default Re: loop question

"Egbert Molenkamp" <> schreef in bericht
news:csapnn$8tk$...
> Notice that the error message gives exactly the answer.
> The generate statement is a concurrent statement. So you may use it as a
> sequential statement (in a process, procedure and function).

.... of course this should be: you may NOT use it ...
Egbert Molenkamp




Egbert Molenkamp
  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
Re: Dial-up Modem Question w_tom A+ Certification 0 09-18-2005 09:12 PM
"Installing two drives" question - what next? Jim A+ Certification 12 08-07-2005 01:19 PM
Re: Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good God DVD Video 3 04-25-2005 04:19 PM
Re: Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good Filthy Mcnasty DVD Video 0 04-25-2005 04:29 AM
Re: Safe Mode Question (A+ question) Gordon Findlay A+ Certification 0 06-16-2004 10:48 AM




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