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....
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; |
jeff wrote: > No semicolon after max: out real Indeed, but I think that little syntax flaw will not be the biggest problem here...
thanks a lot lkmiller ,but i want to know how can i gave the floating numbers to xilinx simulation program
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?
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 .
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).
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
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?