EmbDev.net

Forum: FPGA, VHDL & Verilog vhdl code to find max value from input


Author: basma (Guest)
Posted on:

Rate this post
0 useful
not useful
Hi all,

i want to know how i can find the maximum value from data input
while the data is floating numbers.
i search but didn't find any thing helpe me.
any idea plz....

Author: Pele (Guest)
Posted on:

Rate this post
0 useful
not useful
i search for it too but didn't found something helpful.

Author: Lothar Miller (lkmiller) (Moderator)
Posted on:

Rate this post
1 useful
not useful
basma wrote:
> i search but didn't find any thing helpe me.
What did you search for?

> any idea plz....
This is exaclty what you need (according to your requirements):
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.math_real.ALL;

entity findmax is
  port (
    clk : in std_logic;
    clr : in std_logic;
    din : in real;
    max : out real;
  );
end findmax ;

architecture Behavioral of findmax is
signal m : real := 0.0;
begin
  process begin
    wait until rising_edge(clk);
      if clr='1' then
        m <= 0.0;
      elsif din>m then
        m <= din;
      end if;    
    end if;
  end process;
  
  max <= m;
end Behavioral;
Of course I already added a clock and a clear signal. Otherwise (without 
clock and clear) it would look much less complicated:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.math_real.ALL;

entity findmax is
  port (
    din : in real;
    max : out real;
  );
end findmax ;

architecture Behavioral of findmax is
signal m : real := 0.0;
begin
  m <= din when m<din else m;
  max <= m;
end Behavioral;

Author: jeff (Guest)
Posted on:

Rate this post
0 useful
not useful
No semicolon after max: out real

Author: Lothar Miller (lkmiller) (Moderator)
Posted on:

Rate this post
0 useful
not useful
jeff wrote:
> No semicolon after max: out real
Indeed, but I think that little syntax flaw will not be the biggest 
problem here...

Author: Basma Hassan (Company: bhit) (basma)
Posted on:

Rate this post
0 useful
not useful
thanks a lot lkmiller ,but i want to know how can i gave the floating 
numbers to xilinx simulation program

Author: Lothar Miller (lkmiller) (Moderator)
Posted on:

Rate this post
0 useful
not useful
Basma Hassan wrote:
> but i want to know how can i gave the floating numbers to xilinx
> simulation program
And where do the numbers come from?
Where are the numbers generated and/or stored?

Author: Basma Hassan (Company: bhit) (basma)
Posted on:

Rate this post
0 useful
not useful
Lothar Miller wrote:
> Basma Hassan wrote:
>> but i want to know how can i gave the floating numbers to xilinx
>> simulation program
> And where do the numbers come from?
> Where are the numbers generated and/or stored?

i mean to test the code i should gave numbers from test bench waveform 
instead of write test bench .

Author: Lothar Miller (lkmiller) (Moderator)
Posted on:

Rate this post
0 useful
not useful
Basma Hassan wrote:
> i mean to test the code i should gave numbers from test bench waveform
> instead of write test bench .
I do not understand the problem...  :-/
Please write at least 5 sentences that describe your task (including 
answers to my previous questions).

Author: Basma Hassan (Company: bhit) (basma)
Posted on:

Rate this post
0 useful
not useful
if i want to find the max value in 
(0.3251,0.2536,0.2147,0.3669.............)
how to test it and find the max value

Author: Lothar Miller (lkmiller) (Moderator)
Posted on:

Rate this post
0 useful
not useful
Basma Hassan wrote:
> if i want to find the max value in
> (0.3251,0.2536,0.2147,0.3669.............)
Do you remember my unanswered questions?
Lothar Miller wrote:
> And where do the numbers come from?
> Where are the numbers generated and/or stored?

Basma Hassan wrote:
> how to test it and find the max value
Show the definition of your data at least. Is it an array of floating 
point numbers? How is this array defined?

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [vhdl]VHDL code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.