hi all,,,
i want a code in vhdl to make this equation . like the the following
d(s1,s2)=(1+1+0+1+1)/(n^2/2)=4/12=0.33333 .
(1+1+0+1+1) is the distances between input data use the accumulator to
sum the distances.
n is the number of input data if even multiply n*n if odd n*n-1
then divide accumulator over the numbers of inputs if even or odd
i want a help please in how to make this vhdl code
Duke Scarring wrote:> 1. Show us, what have you done so far.> 2. Ask particular questions.
ok
how i make it in vhdl code
d(s1,s2)=(1+1+0+1+1)/(n^2/2)=4/12=0.33333 .
1
libraryieee;
2
useieee.std_logic_1164.all;
3
libraryieee;
4
useieee.std_logic_1164.all;
5
6
entitytestis
7
port(
8
rst:instd_logic;
9
clk:instd_logic;
10
we:instd_logic;
11
wr_data1:instd_logic_vector(7downto0);
12
wr_data2:instd_logic_vector(7downto0);
13
wr_addr:inintegerrange0to255;
14
N_of_samp:outintegerrange0to255;
15
distance:outintegerrange0to255;
16
sum:outintegerrange0to255;
17
vout:outstd_logic;
18
no_match:outstd_logic
19
);
20
endentity;
21
signalaccum:integerrange0to255:=0;
22
signaldis:integerrange0to255:=0;
23
signaln:integerrange0to255:=0;
24
process(n,accum)
25
begin
26
if(nmod2)/=0then
27
N_of_samp<=(n*n)-1;
28
else
29
N_of_samp<=(n*n);
30
endif;
31
32
endprocess;
33
endrtl;
i try to do it in a part of the code but it calculate n
like(1,2,3,....10)
and test it if even make n*n and if odd make n*n-1
and i want to use the result oonoly i.e i want t use the result of
conter 10 and test it then make division but it gave me result like the
picture attached.
i hope y understand me
The posted code does not match the screenshot.
Pls. add the tokens [ vhdl ] and [ /vhdl ] without the blanks around
your VHDL code. This will give you neat syntax highlighting...
basma wrote:> if rst = '1' then> N <= 0;> ...> if (n mod 2) /= 0 then> ...> else> N_of_samples <= (n*n);> norm_dis <= dis / N_of_samples;> end if;>> also it gave me error divide by zero
Just start thinking: what will happen if if reset is asserted? What is
0*0?
BTW: add the [] around vhdl and /vhdl
So it looks like [/vhdl] after the end and [vhdl] before the beginning
of the VHDL code.
Duke Scarring wrote:> After changing 'norm_dist' to 'norm_dis', and add a missing 'end> architecture', your code compile.>> Did you have a testbench?
sorry for missing it ,but also if i did it gave me error divid by zero
> Just start thinking: what will happen if if reset is asserted? What is> 0*0?
all i want i have a counter count the number of input sample i want to
fatch the result from this counter to test it ,because it gave me
values(0,1,2....100)i want to test if 100 is even oe odd and divide
distance on it. but how i can make it
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.