dpmlt030m.vmd 2.65 KB
/**************************************************************/
/*    Verilog module of datapath cell DPMLT030M               */
/*    Designed by    Lin Yang    VLSI Technology  Jan. 30, 91 */
/*    Designed by    Chunling Liu   Compass       June 29 92  */
/*    Designed by    Linda J. Xu    Compass       Dec. 11 92  */
/*    Edited by      Paul Hyland    Compass       Feb. 8 93   */
/*                                                            */
/*    The following is the port description                   */
/*    Data ports                                              */
/*        X    : the input port                               */
/*        Y    : the input port                               */
/*        MSB  : the output port                              */
/*        LSB  : the output port                              */
/*    Parameters                                              */
/*        WORDSIZE   : the word size of the datapath cell     */
/*        Y_Bus_Size : the Y input width (also known as the   */
/*                     number_of_columns                      */
/*        unsigned   : the unsigned boolean/2's complement    */
/*        DELAY      : the delay time from input to output    */
/**************************************************************/
module dpmlt030m(X, Y, MSB, LSB);

  parameter WORDSIZE = 8, Y_Bus_Size = 8, unsigned = 1, DELAY = 30, BF = 1;
  input  [WORDSIZE-1:0] X, Y;
  output [WORDSIZE-1:0] MSB, LSB;


  function [2*WORDSIZE-1:0] mlt;
    input [WORDSIZE-1:0] x;
    input [Y_Bus_Size-1:0] y;
    reg [WORDSIZE+Y_Bus_Size-1:0] a;
    reg [WORDSIZE-1:0] sx;
    reg [Y_Bus_Size-1:0] sy;

    begin
      if (unsigned == 0)
      begin
        if (x[WORDSIZE-1]^y[Y_Bus_Size-1])
        begin
          if (x[WORDSIZE-1] == 1)
          begin
            sx = ~x + 1;
            sy = y;
          end
          else if (y[Y_Bus_Size-1] == 1)
          begin
            sx = x;
            sy = ~y + 1;
          end
          a = ~(sx * sy) + 1;
        end
        else if (x[WORDSIZE-1]^~ y[Y_Bus_Size-1])
             begin
               if(x[WORDSIZE-1])
                 begin
                 sx = ~x + 1;
                 sy = ~y + 1;
                 end
               else
                 begin
                 sx = x;
                 sy = y;
                 end
             a = sx * sy;
             end
        else
          a = {WORDSIZE+Y_Bus_Size{1'bx}};
      end
      else
         a = x * y;

      mlt[WORDSIZE-1:0] = {{WORDSIZE-Y_Bus_Size{1'b0}},a[Y_Bus_Size-1:0]};
      mlt[2*WORDSIZE-1:WORDSIZE] = a[WORDSIZE+Y_Bus_Size-1:Y_Bus_Size];
    end
  endfunction

  assign #DELAY {MSB, LSB} = mlt(X,Y);

endmodule