vhdl code to find max value from input

Moderator (Company: Titel) #3526956
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):
1
library IEEE;
2
use IEEE.STD_LOGIC_1164.ALL;
3
use IEEE.math_real.ALL;
4

5
entity findmax is
6
  port (
7
    clk : in std_logic;
8
    clr : in std_logic;
9
    din : in real;
10
    max : out real;
11
  );
12
end findmax ;
13

14
architecture Behavioral of findmax is
15
signal m : real := 0.0;
16
begin
17
  process begin
18
    wait until rising_edge(clk);
19
      if clr='1' then
20
        m <= 0.0;
21
      elsif din>m then
22
        m <= din;
23
      end if;    
24
    end if;
25
  end process;
26
  
27
  max <= m;
28
end Behavioral;
Of course I already added a clock and a clear signal. Otherwise (without 
clock and clear) it would look much less complicated:
1
library IEEE;
2
use IEEE.STD_LOGIC_1164.ALL;
3
use IEEE.math_real.ALL;
4

5
entity findmax is
6
  port (
7
    din : in real;
8
    max : out real;
9
  );
10
end findmax ;
11

12
architecture Behavioral of findmax is
13
signal m : real := 0.0;
14
begin
15
  m <= din when m<din else m;
16
  max <= m;
17
end Behavioral;
(Company: bhit) #3530554
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 .
Moderator (Company: Titel) #3530573
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).
Moderator (Company: Titel) #3532513
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

A question of your own? This thread is over 12 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [vhdl]VHDL-Code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.