vhdl programming for multiplicative inverse inverse modulo 2^4+1

Status
Not open for further replies.

manasa4

Newbie level 3
Joined
Feb 25, 2012
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,326
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:

Why is debugging your code my job?
Why not try writing a testbench and running it in a simulator?

---------- Post added at 17:48 ---------- Previous post was at 17:48 ----------

PS. This code is clearly written by a software programmer. It will be useless for an FPGA.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…