verilog code for montgomery multiplication module
#1

verilog code for 4 bit montgomery multiplication module
Reply
#2

module MMM42(A1,A2,B1,B2,N,S1,S2,clk);
input clk;
input [3:0]A1,A2,B1,B2,N;
output [6:0]S1,S2;
reg [3:0]a1,a2,b1,b2,n,bd1,bd2,d1,d2,w,y;
reg [6:0]s1,s2,s11,s21,s12,s22;
reg q,A,Ai1,Ai2,qi1,qi2,mbrfa_ctemp,bypass;
reg temp1,temp2;
integer i=0;
initial
begin
assign q=1'h0;
assign A=1'h0;
assign s1=7'h0;
assign s2=7'h0;
assign bd1=(B1<<1)^(B2<<1);
assign bd2=(B1<<1)&(B2<<1);
assign d1=bd1^bd2^n;
assign d2=bd1&bd2&n;
assign mbrfa_ctemp=1'h0;
assign bypass=1'h0;
assign qi1=1'h0;
assign qi2=1'h0;
assign s11=7'h0;
assign s21=7'h0;
assign s12=7'h0;
assign s22=7'h0;
assign w=4'h0;
assign y=4'h0;
assign Ai1=1'h0;
assign Ai2=1'h0;
end
always
begin
assign a1=A1;
assign b1=B1;
assign a2=A2;
assign b2=B2;
assign n=N;
end
always @(posedge clk)
begin
while(i<6)
begin

//mbrfa
assign temp1=(a1[i]&a2[i]);//carry_i+1
assign temp2=(a1[i+1]&a2[i+1]);//carry_i+2
assign mbrfa_ctemp=bypass?temp1:temp2;//mux
assign Ai1=a1[i]^a2[i]^mbrfa_ctemp;//A_i+1
assign Ai2=a1[i+1]^a2[i+1]^temp1;//A_i+2

//look-ahead unit
assign qi1=s11[1];//q_i+1
assign qi2=s21[1]^s11[2];q_i+2
assign bypass=~(qi1|Ai1);
assign q=bypass?qi2:qi1;//q_bar
assign A=bypass?Ai2:Ai1;//A_bar

//iteration variable
i=bypass?i+2:i+1;

//carry save adder 1
assign s11=(s1^s2^w)>>1;//S1'[i]
assign s21=(s1&s2&w)>>1;//S2'[i]

//carry save adder 2
assign s12=(s11^s21^y)>>1;//S1[i+1]
assign s22=(s11&s21&y)>>1;S2[i+1]

//multiplexers 3 and 4
assign s1=bypass?(s21>>1)Confused21;
assign s2=bypass?(s22>>1)Confused22;

//multiplexers 1 and 2
if((A==0)&(q==0))
begin
assign w=4'h0;
assign y=4'h0;
end
else if((A==0)&(q==1))
begin
assign w=N;
assign y=4'h0;
end
else if((A==1)&(q==0))
begin
assign w=bd1;
assign y=bd2;
end
else if((A==1)&(q==1))
begin
assign w=d1;
assign y=d2;
end
end
end
endmodule
Reply

Important Note..!

If you are not satisfied with above reply ,..Please

ASK HERE

So that we will collect data for you and will made reply to the request....OR try below "QUICK REPLY" box to add a reply to this page
Popular Searches: rsa implementation based on montgomery multipliers computer science project, shift and add multiplication verilog code, code of multiplication of bcd in verilog, montgomery county ride, matrix multiplication verilog code, montgomery county tx elections, name dropper montgomery,

[-]
Quick Reply
Message
Type your reply to this message here.

Image Verification
Please enter the text contained within the image into the text box below it. This process is used to prevent automated spam bots.
Image Verification
(case insensitive)

Possibly Related Threads...
Thread Author Replies Views Last Post
  water level alarm using rf module 1 468 15-06-2016, 04:06 PM
Last Post: dhanabhagya
  how to interface lm35 with fpga code in verilog 1 1,072 11-06-2016, 04:04 PM
Last Post: dhanabhagya
  bresenham line algorithm verilog 1 748 11-06-2016, 03:53 PM
Last Post: dhanabhagya
  16 bit kogge stone adder verilog code 1 1,006 08-06-2016, 04:26 PM
Last Post: dhanabhagya
  verilog code for line following robot 1 582 08-06-2016, 04:24 PM
Last Post: dhanabhagya
  verilog source code for elliptic curve cryptography 1 600 03-06-2016, 04:20 PM
Last Post: dhanabhagya
  verilog code for a water level controller 1 751 31-05-2016, 12:33 PM
Last Post: dhanabhagya
  housekeeping training module ppt hindi 1 673 27-05-2016, 12:36 PM
Last Post: dhanabhagya
  4x4 multiplier using compressor verilog code 1 648 27-05-2016, 11:19 AM
Last Post: dhanabhagya
  elevator control source code verilog 1 729 25-05-2016, 12:12 PM
Last Post: dhanabhagya

Forum Jump: