priyanka24
Advanced Member level 4
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???
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???