title: Frequency of the Multiplier
body: <p>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.</p>
  
  <p>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. </p>
  
  <p>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.</p>
  
  <p>The code is given below</p>
  
  <pre><code>////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 &lt;= a; y &lt;= b; count= 6'd0; end       // first operands given
  else begin                                    // and counter started 
  
   if (count == 11)                       // first multiplication completed
  reg2 &lt;= p;                              // result moved to register
  if (count == 12)
  begin x &lt;= reg0[15:0]; y &lt;=`mbar; end   // new operands
  if (count == 27)                       // second multiplication completed
  reg1 &lt;= p;                            // second result to register
  else if (count == 28)
  begin                              // new operands for 3rd multiplication
  x &lt;= reg1[15:0];
  y &lt;= `m;
  end
  else if (count == 39)            // multiplication completed
  begin
  reg2 &lt;= 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&lt;= a*b;
  reg1&lt;=reg0;
  reg2&lt;=reg1;         // just to increase some clock cycles- nothing else
  end
  endmodule
  </code></pre>