// Copyright 2007 Altera Corporation. All rights reserved. // Altera products are protected under numerous U.S. and foreign patents, // maskwork rights, copyrights and other intellectual property laws. // // This reference design file, and your use thereof, is subject to and governed // by the terms and conditions of the applicable Altera Reference Design // License Agreement (either as signed by you or found at www.altera.com). By // using this reference design file, you indicate your acceptance of such terms // and conditions between you and Altera Corporation. In the event that you do // not agree with such terms and conditions, you may not use the reference // design file and please promptly destroy any copies you have made. // // This reference design file is being provided on an "as-is" basis and as an // accommodation and therefore all warranties, representations or guarantees of // any kind (whether express, implied or statutory) including, without // limitation, warranties of merchantability, non-infringement, or fitness for // a particular purpose, are specifically disclaimed. By making this reference // design file available, Altera expressly does not recommend, suggest or // require that this reference design file be used in combination with any // other product not provided by Altera. ///////////////////////////////////////////////////////////////////////////// // baeckler, liu - 06-14-2007 module karatsuba_mult (clk, a, b, o); parameter IN_WIDTH = 64; // must be even localparam OUT_WIDTH = 2*IN_WIDTH; localparam WORD_WIDTH = IN_WIDTH / 2; input [IN_WIDTH-1:0] a, b; input clk; output [OUT_WIDTH-1:0] o; wire [WORD_WIDTH-1:0] a_h, a_l, b_h, b_l; assign {a_h,a_l} = a; assign {b_h,b_l} = b; // tick 0 - Input registers reg [WORD_WIDTH-1:0] a_hr,a_lr,b_hr,b_lr; always @(posedge clk) begin a_hr <= a_h; a_lr <= a_l; b_hr <= b_h; b_lr <= b_l; end wire [WORD_WIDTH:0] a_hl, b_hl; assign a_hl = a_hr + a_lr; assign b_hl = b_hr + b_lr; // ticks 0 1 2 wire [IN_WIDTH-1:0] pphh, ppll; mult_3tick mx (.clk(clk),.a_in(a_h),.b_in(b_h),.o(pphh)); defparam mx .IN_WIDTH = WORD_WIDTH; mult_3tick my (.clk(clk),.a_in(a_l),.b_in(b_l),.o(ppll)); defparam my .IN_WIDTH = WORD_WIDTH; // ticks 1 2 3 wire [IN_WIDTH+1:0] pphl; mult_3tick mz (.clk(clk),.a_in(a_hl),.b_in(b_hl),.o(pphl)); defparam mz .IN_WIDTH = WORD_WIDTH+1; // desired function is Out = // {pphh,ppll} - pphh<