i want to find a single max value for an input signal that has 1000 decimal values that is read from a memory once every Positive clk edge.i did the following rough code for finding max value but it didn't give me the correct max value/number please help me so i can find a single max value in these 1000 values of input signal..`thanks in advance
module(input clk, input [15:0]din, output [15:0]dout);
reg [15:0] max=0;
always @ (Posedge clk)
if(din>max)
max<=din;
else
max<=0;
assign dout=max;
endmodule