problem in verilog coding

Joined
Jan 26, 2012
Messages
4
Reaction score
0
Hi..

i want to calculate run length from the binary sequence.
for example if my number is '0001' then my run length is 3.
suppose my number is '1' then my run length is 0.
suppose my run length is '00110001' then my run lengths are 2, 0, 3.
so for that i have written verilog code as follows:


module runcount(i, o);
input [7:0] i;
output [3:0]o;
reg [3:0]o;
integer count=0;
integer j=0;

initial o=4'b0000;
always@(i)
begin
for(j=7;j>=0;j=j-1)
begin
if(i[j]==0)
begin
o=count+1;
end
else if(i[j]==1)
begin
o=count;
count=0;
end
end
end
endmodule


but my output is always zero. so can anyone tell whats the problem???
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top