module try2(p,d,q1,q2,q3,q4,q5,q6,q7,q8,c,a);
input p,c;
output [15:0]q1,q2,q3,q4,q5,q6,q7,q8,d,a;
reg [15:0] d=16'b0;//may be error
reg [15:0]a;
always @ (posedge p) begin
d<=d+1;
end
DFF dff0(q1,d,p);
DFF dff1(q2,q1,p);
DFF dff2(q3,q2,p);
DFF dff3(q4,q3,p);
DFF dff4(q5,q4,p);
DFF dff5(q6,q5,p);
DFF dff6(q7,q6,p);
DFF dff7(q8,q7,p);
always @ ( posedge c )begin
a = ( q1 + q2 + q3 + q4 + q5 + q6 + q7 + q8 )/8;
end
endmodule
module DFF(q,d,clk);
input [15:0]d;
input clk;
output [15:0]q;
reg [15:0]q;
always @ (posedge clk)begin
q <=d;
end
endmodule
Here I am counting the high of pulse p and showing the value in 16 bit d. And whenever another input c goes from 0 to 1 I am showing the average of last 8 values of d.
Problem:Here everything is working fine but the average value showing deviation of 1 and program is stimulating but not synthesizing .