I have designed a 16*16 Montgomery multiplier. The code uses a 16*16 multiplier to perform three multiplications. The multiplications are performed one after the other using the same multiplier and the result of each multiplication is stored in the registers. The single 16*16 multiplier performs at a frequency of about 1550 MHz, but the frequency of the Montgomery multiplier (which uses a single 16*16 multiplier three times) is reduced to almost 500 MHz when the three multiplications are carried out in series. I want to avoid the decrease in frequency and want to operate it at the frequency of single multiplier. Need help in this.
The code is provided along with.(only multiplications are provided in this case. Additions, shifting has been excluded for simplicity)
`define m 11
`define mbar 245
module test_mul(a,b,clk,reg2,reset);
input [15:0] a,b;
input clk,reset;
output reg [31:0] reg2;
reg [15:0] x,y;
reg [31:0] reg0,reg1;
reg [5:0] count;
wire [31:0]p;
test_mul16 a1 (x,y,clk, p);
always @ (posedge clk)
begin
if (reset)
begin x <= a; y <= b; count= 6'd0 end
else begin
if (count == 11)
reg2 <= p;
if (count == 12)
begin x <= reg0[15:0]; y <=`mbar; end
if (count == 27)
reg1 <= p;
else if (count == 28)
begin
x <= reg1[15:0];
y <= `m;
end
else if (count == 39)
begin
reg2 <= p;
end
count = count+1;
end
end
endmodule
module test_mul16(a,b,clk,reg2);
input [15:0] a,b;
input clk;
output reg [31:0] reg2;
reg [31:0] reg0, reg1;
always @ (posedge clk)
begin
reg0<= a*b;
reg1<=reg0;
reg2<=reg1;
end
endmodule