Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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.

Register Log in

while loop depending on an input argument

Status
Not open for further replies.

treehugger

Member level 2
Joined
Oct 23, 2005
Messages
44
Helped
3
Reputation
6
Reaction score
0
Trophy points
1,286
Activity points
1,705
now this is a very basic question:

The code seen below goes to infinite loop during synthesis, hence my sythesis tool halts (with an error like, "loop has iterated 64 times so i am halting blah blah"). The reason behind this is that "data" is assigned to X (undefined-unknown) and the evaluation (i<data) yields X, and a while loop executes if its condition is X.

Isn't this an apparent problem? Am i missing some point? What is the workaround?


module example(data, trig)

input [4:0] data;
input trig;
output out;
reg out;
integer i;

always @ trig
begin

out=0;
i=0;
while(i<data)
begin
out=~out;
end

end

endmodule


I just need a loop which runs until it hits a variable number given by the user, not until a constant predefined value..

How to?
 

haytham

Full Member level 4
Joined
Jun 6, 2004
Messages
229
Helped
16
Reputation
32
Reaction score
2
Trophy points
1,298
Activity points
1,365
hi
While loop is not synthesiable
Please re-write your code using synthesiable conditional statement

thanks
haytham
 

neo_chip

Member level 1
Joined
Jul 14, 2006
Messages
34
Helped
3
Reputation
6
Reaction score
0
Trophy points
1,286
Location
INDIA
Activity points
1,450
Hi.
Try this one.
Use a LOAD signal to load the value.

module example(data, trig,load)

input [4:0] data;
input trig,load;
output out;
reg [4:0] value;
reg out;
integer i;

always @ trig
begin

out=0;
i=0;
if(load)
value = data;
else
while(i<value)
begin
out=~out;
end

end

endmodule
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search


Welcome to EDABoard.com

Sponsor

Sponsor

Design Fast


×
Top