Maybe it would help to see the code:
// 4-stage pipelined Karatsuba multiplication
// Designed by Chris Matrakidis, coded by Timothy N. Miller
// The original authors claim no liability. Use at your own risk.
// Uses the Karatsuba multiplication formula: (A1*2^M+A0)*(B1*2^M+B0)=
// ((A0+A1)*(B0+B1)-A0*B0-A1*B1)*2^M+A0*B0+A1*B1*2^(2*M)
module multiply_nxn #(parameter M=16)
(input [2*M:0] A, // Inputs are 2*M+1 bits wide, signed
input [2*M:0] B,
output [4*M+1:0] C); // Output is 4*M+2 bits wide, signed
// Slices of inputs
wire [M-1:0] A0, B0;
wire signed [M:0] A1, B1;
assign A0 = A[M-1:0]; // M bits unsigned
assign B0 = B[M-1:0];
assign A1 = A[2*M:M]; // M+1 bits, including sign
assign B1 = B[2*M:M];
// Stage 1: A0+A1, B0+B1, A0*B0, A1*B1
reg signed [M+1:0] A0pA1;
reg signed [M+1:0] B0pB1;
reg [2*M-1:0] A0tB0;
reg signed [2*M+1:0] A1tB1;
always @(posedge clock) begin
A0pA1 <= A0 + A1;
B0pB1 <= B0 + B1;
A0tB0 <= A0 * B0;
A1tB1 <= A1 * B1;
end
// Stage 2: A0pA1tB0pB1, middle1
reg signed [2*M+2:0] A0pA1tB0pB1;
reg signed [2*M+1:0] middle1;
reg [2*M-1:0] A0tB0_s2;
reg signed [2*M+1:0] A1tB1_s2;
always @(posedge clock) begin
A0pA1tB0pB1 <= A0pA1 * B0pB1;
middle1 <= A0tB0 + A1tB1;
A0tB0_s2 <= A0tB0;
A1tB1_s2 <= A1tB1;
end
// Stage 3: middle
reg signed [2*M+1:0] middle;
reg [2*M-1:0] A0tB0_s3;
reg signed [2*M+1:0] A1tB1_s3;
always @(posedge clock) begin
middle <= A0pA1tB0pB1 - {middle1[2*M+1], middle1};
A0tB0_s3 <= A0tB0_s2;
A1tB1_s3 <= A1tB1_s2;
end
// Stage 4: total
wire signed [3*M+1:0] middle_ext = {{M{middle[2*M+1]}}, middle};
wire signed [4*M+1:0] outer = {A1tB1_s3, A0tB0_s3};
reg signed [4*M+1:0] total;
always @(posedge clock) begin
total[M-1:0] <= outer[M-1:0];
total[4*M+1:M] <= outer[4*M+1:M] + middle_ext;
end
// Output
assign C = total;
endmodule
On Wed, Jan 23, 2013 at 11:43 AM, Eitan Adler <[email protected]> wrote:
> On 23 January 2013 11:35, Timothy Normand Miller <[email protected]>
> wrote:
> > I think one of the reasons to use a permissive license is to include a
> > liability disclaimer. If you just put something into the public domain,
> you
> > run the risk of someone blaming you for their misuse.
> >
> > So, what license is the closest to public domain as possible?
>
> CC0. This is not recommended for use by software by either the CC or
> the OSI for a variety of reasons.
>
> Better choices: MIT/X11 or 2-clause BSD license.
>
> Okay choices: 3-clause BSD
>
>
> --
> Eitan Adler
>
--
Timothy Normand Miller, PhD
Assistant Professor of Computer Science, Binghamton University
http://www.cs.binghamton.edu/~millerti/
Open Graphics Project
_______________________________________________
Open-graphics mailing list
[email protected]
http://lists.duskglow.com/mailman/listinfo/open-graphics
List service provided by Duskglow Consulting, LLC (www.duskglow.com)