hello.I've written a code for multiplicative inverse modulo 2^4+1.there are no syntax errors.but at the time of simulation its showing no result not even an error.could u solve this.
here is the code.
Code VHDL - [expand ] 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
library IEEE ;
use IEEE .STD_LOGIC_1164 .ALL ;
use IEEE .STD_LOGIC_ARITH.ALL ;
use IEEE .STD_LOGIC_UNSIGNED.ALL ;
entity mulinv is
port ( x: in std_logic_vector ( 3 downto 0 ) ;
z: out std_logic_vector ( 3 downto 0 ) ) ;
end mulinv;
architecture Behavioral of mulinv is
signal xi,zi,t1,t2,y,q: integer ;
begin
process ( x)
begin
xi<= conv_integer( x) ;
t2<= 1 ;
if ( xi= 1 ) then zi<= 1 ;
elsif ( xi= 0 ) then zi<= 0 ;
else
t1<= 17 / xi;
y<= 17 mod xi;
if ( y= 1 ) then zi<= ( 1 - t1) ;
else
while ( y/= 1 ) loop
q<= xi/ y;
xi<= xi mod y;
t2<= t2+ ( q* t1) ;
if xi= 1 then zi<= t2;
else q<= y/ xi;
y<= y mod xi;
t1<= t1+ ( q* t2) ;
end if ;
end loop ;
end if ;
zi<= ( 1 - t1) ;
end if ;
z<= conv_std_logic_vector( zi,4 ) ;
end process ;
end Behavioral;
The code should be written between the syntax tags not after them.
Use preview to make sure that you use them correctly before posting
Last edited by a moderator: Mar 14, 2012