gnoble29
Member level 1
- Joined
- Jun 30, 2010
- Messages
- 38
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,286
- Location
- india
- Activity points
- 1,528
I have written a verilog code using 'for' loop..My aim is to display 2,3,4 in three consecutive clock cycle.But for the first clock cycle itself,my 'for' loop is executing fully and showing output as 4.How can I avoid this??
(I studied that for loop will execute sequentially only.But I am not getting output sequentially.)
I am including my code below...Plz help me...
module for_test(clk,n,m); //programe for testing the for loop
input clk;
output [7:0] m;
output n;
reg [7:0] m;
integer n;
always @(posedge clk)
begin
for(n=2;n>=0;n=n-1)
begin
if(n==2)
begin
m <=8'h02;
end
else
if(n==1)
begin
m <=8'h03;
end
else
if(n==0)
begin
m <=8'h04;
end
end
end
endmodule
(I studied that for loop will execute sequentially only.But I am not getting output sequentially.)
I am including my code below...Plz help me...
module for_test(clk,n,m); //programe for testing the for loop
input clk;
output [7:0] m;
output n;
reg [7:0] m;
integer n;
always @(posedge clk)
begin
for(n=2;n>=0;n=n-1)
begin
if(n==2)
begin
m <=8'h02;
end
else
if(n==1)
begin
m <=8'h03;
end
else
if(n==0)
begin
m <=8'h04;
end
end
end
endmodule