Enter into Zilicon Zone


RocketTheme Joomla Templates


Read more...
VLSI WORLD FORUM
Welcome, Guest
Please Login or Register.
Lost Password?
problem in verilog coding (1 viewing)
_GEN_GOTOBOTTOM Post Reply

TOPIC: problem in verilog coding

#604
priyanka87 (User)
Fresh Boarder
Posts: 1
graphgraph
problem in verilog coding 2012/01/26 15:57 Karma: 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???
Ed
  The administrator has disabled public write access.
_GEN_GOTOTOP Post Reply
VLSI-world.com