Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
16556 Discussions

finding single max value in an input signal having 1000 decimal values

Altera_Forum
Honored Contributor II
1,156 Views

I want to find max in input file, read from a memory. This input file size 1000 decimal sample values. I have written the following code to find max value but it didn't give the correct result .plzzz help me so i can find a single max value in this input signal..thanks in advance.. 

 

 

 

 

 

module max_min(input clk, input [15:0]din, output [15:0]dout); reg [15:0]max=0;  

always @(posedge clk)  

begin 

if($signed(din)>max)  

max<=din;  

else 

max<=0;  

end 

assign dout=max;`endmodule 

 

0 Kudos
4 Replies
Altera_Forum
Honored Contributor II
342 Views

Why do you assign 0 to max in the "else" part? You should keep the current value of the max register instead.

0 Kudos
Altera_Forum
Honored Contributor II
342 Views

 

--- Quote Start ---  

Why do you assign 0 to max in the "else" part? You should keep the current value of the max register instead. 

--- Quote End ---  

 

 

dear Daixiwe tanks for time..oky.this may be one problem..but i want that my code should output a single max vlaue an input array of 1000 values which is read from a mem file..will u modify my code so i can get single max value among these 1000 values?
0 Kudos
Altera_Forum
Honored Contributor II
342 Views

plzzz help me out..i m in a disparate situation

0 Kudos
Altera_Forum
Honored Contributor II
342 Views

 

--- Quote Start ---  

plzzz help me out..i m in a disparate situation 

--- Quote End ---  

 

 

People here will not write code for you. we are here to help you fix YOUR code, not provide code for you.
0 Kudos
Reply