0

I have designed a 16*16 multiplier. (operating at the frequency of 1550 MHz) I then use the same multiplier to perform three multiplications in series by putting registers at input which are used to change input operands. The result of the multiplications are stored in the registers. When three multiplications are performed in series, the frequency reduces to 500 MHz.I want to avoid the decrease in frequency and want to operate it at the frequency of single multiplier.

Since the single multiplier requires certain clock cycles to complete the operation, we therefore wait for few clock cycles before giving multiplier the new operands. A counter in used for this purpose. The counter counts the clock cycles and provides the delay necessary to complete multiplication.

The process is completed as follows: The first multiplication is started, then we wait for few clock cycles to compute the result, the result is then stored in the register and multiplier is provided with new operands, again the multiplier needs some clock cycles, this process continues three times. I just want this whole code to work at the frequency of single multiplier that is almost 1500 MHz.

The code is given below

////3 multiplications are carried out in this module

`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       // first operands given
else begin                                    // and counter started 

 if (count == 11)                       // first multiplication completed
reg2 <= p;                              // result moved to register
if (count == 12)
begin x <= reg0[15:0]; y <=`mbar; end   // new operands
if (count == 27)                       // second multiplication completed
reg1 <= p;                            // second result to register
else if (count == 28)
begin                              // new operands for 3rd multiplication
x <= reg1[15:0];
y <= `m;
end
else if (count == 39)            // multiplication completed
begin
reg2 <= p;                       // result moved to register
end
count = count+1;                 // counter incremented
end
end
endmodule


//// this multiplier operates at a frequency of 1550 MHz
//// This is then called in the upper module

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;         // just to increase some clock cycles- nothing else
end
endmodule
  • 1
    Is there any specific reason it needs to run at 1500MHz? I'm speculating here, but I imagine that the lower level module was probably inferred as a DSP block, on whatever chip you are using. Your Fmax will take a hit as soon as you start adding any other logic around that. There are a few possible options to increase your Fmax from 500MHz (which is already high), but I suspect you will not get anywhere near 1500MHz. – gsm Feb 20 '17 at 13:47
  • 1
    Possible duplicate of [Frequency of Montgomery Multiplier](http://stackoverflow.com/questions/42274589/frequency-of-montgomery-multiplier) – Hida Feb 20 '17 at 14:11
  • If you use 3 sequential stage, then you should be able to run them at the same frequency I think. – Karan Shah Feb 21 '17 at 15:00

1 Answers1

0

There are a few unknowns in your question, so I have made a few assumptions to bridge the gaps. Feel free to correct any incorrect assumptions I have made.

In the initial part of the question, you state:

When three multiplications are performed in series...

I initially thought you were trying to perform three multiplications, sequentially, in a feed through manner (ie. feeding the output of one multiplier into the input of the next, in some manner, bearing in mind that the size of the result is larger than input operands). However, after looking at the code and your later statement:

Since the single multiplier requires certain clock cycles to complete the operation, we therefore wait for few clock cycles before giving multiplier the new operands.

It appears as though you just want to feed multiple values (in this case, three) into a multiplier and get the results. If this is the case, you can simply feed them into the lower level test_mul16 module, on every clock cycle. If the lower level module is being inferred as a DSP (assumption; even if it isn't the following will hold true if designed correctly), it will be capable of taking a new set of operands each clock cycle. The number of cycles required to generate the initial result will depend on the number of registers you infer around the DSP block, as well as the number of stages within the block itself (this can vary, depending on vendor and how it is configured).

Once you get that initial result, you are able to start doing things with it, as well as subsequent values (which will be produced every clock cycle thereafter, assuming you load a new set in each cycle). What you are doing exactly, is unknown (though, I'm assuming it is related to Montgomery multiplication). This concept is known as pipelining, and is what makes FPGAs extremely effective at certain processing tasks.

If subsequent results are related in some way, you can start combining them in some manner. Conversely, if you need to handle the output values separately, you can mux the outputs (possibly using a counter to select) into individual registers to perform further operations on as required.

One last note that is worth mentioning. Under the assumption you are using an underlying DSP block, depending on what "additional logic" you have to implement, it may be possible to implement some of it in the DSP block itself (ie. mult, accumulate, rounding, saturation etc. These features differ between vendors).

gsm
  • 389
  • 2
  • 10