I'm developing a verilog code for cumulative histogram method , for median filter . it uses nested for loops , that the input of second for loop depends on output of first for loop . the problem lies here .the second for loop is not accepting that input . please help. the code is
module median(a, b,k,n,h);
input [4:0] a;
output [255:0] b;
output k,n,h;
reg [255:0] b;
reg [255:0]k,n,h;
always @(a) begin
for (n=0;n < 256;n=n+1)
b[n]=0;
for (n=0;n<=4;n=n+1) begin
b[a[n]]=b[a[n]]+1;
h=a[n]+1;
for ( k = h;k <=255;k = k+1) begin
b[k]=b[k]+1;
end
end
for (n=0;n<=255 ;n=n+1) begin
if(b[n]==3)begin
$display ("the median is %d",n);
end
end
end
endmodule